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_toggle;
254struct nk_style_slide;
255struct nk_style_progress;
256struct nk_style_scrollbar;
257struct nk_style_edit;
258struct nk_style_property;
259struct nk_style_chart;
260struct nk_style_combo;
261struct nk_style_tab;
263struct nk_style_window;
264
265enum {nk_false, nk_true};
266struct nk_color {nk_byte r,g,b,a;};
267struct nk_colorf {float r,g,b,a;};
268struct nk_vec2 {float x,y;};
269struct nk_vec2i {short x, y;};
270struct nk_rect {float x,y,w,h;};
271struct nk_recti {short x,y,w,h;};
272typedef char nk_glyph[NK_UTF_SIZE];
273typedef union {void *ptr; int id;} nk_handle;
274struct nk_image {nk_handle handle; nk_ushort w, h; nk_ushort region[4];};
275struct nk_nine_slice {struct nk_image img; nk_ushort l, t, r, b;};
276struct nk_cursor {struct nk_image img; struct nk_vec2 size, offset;};
277struct nk_scroll {nk_uint x, y;};
278
279/* Make sure the semantic of nk_true/nk_false is compatible with nk_bool */
280NK_STATIC_ASSERT(!((nk_bool)0) == !(nk_false));
281NK_STATIC_ASSERT(!((nk_bool)1) == !(nk_true));
282
283enum nk_heading {NK_UP, NK_RIGHT, NK_DOWN, NK_LEFT};
284enum nk_button_behavior {NK_BUTTON_DEFAULT, NK_BUTTON_REPEATER};
285enum nk_modify {NK_FIXED = nk_false, NK_MODIFIABLE = nk_true};
286enum nk_orientation {NK_VERTICAL, NK_HORIZONTAL};
287enum nk_collapse_states {NK_MINIMIZED = nk_false, NK_MAXIMIZED = nk_true};
288enum nk_show_states {NK_HIDDEN = nk_false, NK_SHOWN = nk_true};
289enum nk_chart_type {NK_CHART_LINES, NK_CHART_COLUMN, NK_CHART_MAX};
290enum nk_chart_event {NK_CHART_HOVERING = 0x01, NK_CHART_CLICKED = 0x02};
291enum nk_color_format {NK_RGB, NK_RGBA};
292enum nk_popup_type {NK_POPUP_STATIC, NK_POPUP_DYNAMIC};
293enum nk_layout_format {NK_DYNAMIC, NK_STATIC};
294enum nk_tree_type {NK_TREE_NODE, NK_TREE_TAB};
295
296enum nk_tooltip_pos {
297 NK_TOP_LEFT,
298 NK_TOP_CENTER,
299 NK_TOP_RIGHT,
300
301 NK_MIDDLE_LEFT,
302 NK_MIDDLE_CENTER,
303 NK_MIDDLE_RIGHT,
304
305 NK_BOTTOM_LEFT,
306 NK_BOTTOM_CENTER,
307 NK_BOTTOM_RIGHT
308};
309
310typedef void*(*nk_plugin_alloc)(nk_handle, void *old, nk_size);
311typedef void (*nk_plugin_free)(nk_handle, void *old);
312typedef nk_bool(*nk_plugin_filter)(const struct nk_text_edit*, nk_rune unicode);
313typedef void(*nk_plugin_paste)(nk_handle, struct nk_text_edit*);
314typedef void(*nk_plugin_copy)(nk_handle, const char*, int len);
315
317 nk_handle userdata;
318 nk_plugin_alloc alloc;
319 nk_plugin_free free;
320};
321enum nk_symbol_type {
322 NK_SYMBOL_NONE,
323 NK_SYMBOL_X,
324 NK_SYMBOL_UNDERSCORE,
325 NK_SYMBOL_CIRCLE_SOLID,
326 NK_SYMBOL_CIRCLE_OUTLINE,
327 NK_SYMBOL_RECT_SOLID,
328 NK_SYMBOL_RECT_OUTLINE,
329 NK_SYMBOL_TRIANGLE_UP,
330 NK_SYMBOL_TRIANGLE_DOWN,
331 NK_SYMBOL_TRIANGLE_LEFT,
332 NK_SYMBOL_TRIANGLE_RIGHT,
333 NK_SYMBOL_PLUS,
334 NK_SYMBOL_MINUS,
335 NK_SYMBOL_TRIANGLE_UP_OUTLINE,
336 NK_SYMBOL_TRIANGLE_DOWN_OUTLINE,
337 NK_SYMBOL_TRIANGLE_LEFT_OUTLINE,
338 NK_SYMBOL_TRIANGLE_RIGHT_OUTLINE,
339 NK_SYMBOL_CHEVRON_UP,
340 NK_SYMBOL_CHEVRON_RIGHT,
341 NK_SYMBOL_CHEVRON_DOWN,
342 NK_SYMBOL_CHEVRON_LEFT,
343 NK_SYMBOL_HAMBURGER,
344 NK_SYMBOL_MAX
345};
346/* =============================================================================
347 *
348 * CONTEXT
349 *
350 * =============================================================================*/
386#ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
387
404NK_API nk_bool nk_init_default(struct nk_context*, const struct nk_user_font*);
405#endif
429NK_API nk_bool nk_init_fixed(struct nk_context*, void *memory, nk_size size, const struct nk_user_font*);
430
449NK_API nk_bool nk_init(struct nk_context*, const struct nk_allocator*, const struct nk_user_font*);
450
469NK_API nk_bool nk_init_custom(struct nk_context*, struct nk_buffer *cmds, struct nk_buffer *pool, const struct nk_user_font*);
470
484NK_API void nk_clear(struct nk_context*);
485
496NK_API void nk_free(struct nk_context*);
497
498#ifdef NK_INCLUDE_COMMAND_USERDATA
510NK_API void nk_set_user_data(struct nk_context*, nk_handle handle);
511#endif
512/* =============================================================================
513 *
514 * INPUT
515 *
516 * =============================================================================*/
581enum nk_keys {
582 NK_KEY_NONE,
583 NK_KEY_SHIFT,
584 NK_KEY_CTRL,
585 NK_KEY_DEL,
586 NK_KEY_ENTER,
587 NK_KEY_TAB,
588 NK_KEY_BACKSPACE,
589 NK_KEY_COPY,
590 NK_KEY_CUT,
591 NK_KEY_PASTE,
592 NK_KEY_UP,
593 NK_KEY_DOWN,
594 NK_KEY_LEFT,
595 NK_KEY_RIGHT,
596 /* Shortcuts: text field */
597 NK_KEY_TEXT_INSERT_MODE,
598 NK_KEY_TEXT_REPLACE_MODE,
599 NK_KEY_TEXT_RESET_MODE,
600 NK_KEY_TEXT_LINE_START,
601 NK_KEY_TEXT_LINE_END,
602 NK_KEY_TEXT_START,
603 NK_KEY_TEXT_END,
604 NK_KEY_TEXT_UNDO,
605 NK_KEY_TEXT_REDO,
606 NK_KEY_TEXT_SELECT_ALL,
607 NK_KEY_TEXT_WORD_LEFT,
608 NK_KEY_TEXT_WORD_RIGHT,
609 /* Shortcuts: scrollbar */
610 NK_KEY_SCROLL_START,
611 NK_KEY_SCROLL_END,
612 NK_KEY_SCROLL_DOWN,
613 NK_KEY_SCROLL_UP,
614 NK_KEY_ALT,
615 NK_KEY_F1,
616 NK_KEY_F2,
617 NK_KEY_F3,
618 NK_KEY_F4,
619 NK_KEY_F5,
620 NK_KEY_F6,
621 NK_KEY_F7,
622 NK_KEY_F8,
623 NK_KEY_F9,
624 NK_KEY_F10,
625 NK_KEY_F11,
626 NK_KEY_F12,
627 NK_KEY_MAX
628};
629enum nk_buttons {
630 NK_BUTTON_LEFT,
631 NK_BUTTON_MIDDLE,
632 NK_BUTTON_RIGHT,
633 NK_BUTTON_DOUBLE, /* Double click of the Left mouse button. */
634 NK_BUTTON_X1, /* Commonly used for "Back" in UI navigation. Mouse Button 4. */
635 NK_BUTTON_X2, /* Commonly used for "Forward" in UI navigation. Mouse Button 5. */
636 NK_BUTTON_MAX
637};
638
650NK_API void nk_input_begin(struct nk_context*);
651
664NK_API void nk_input_motion(struct nk_context*, int x, int y);
665
678NK_API void nk_input_key(struct nk_context*, enum nk_keys, nk_bool down);
679
694NK_API void nk_input_button(struct nk_context*, enum nk_buttons, int x, int y, nk_bool down);
695
710NK_API void nk_input_scroll(struct nk_context*, struct nk_vec2 val);
711
728NK_API void nk_input_char(struct nk_context*, char);
729
743NK_API void nk_input_glyph(struct nk_context*, const nk_glyph);
744
759NK_API void nk_input_unicode(struct nk_context*, nk_rune);
760
772NK_API void nk_input_end(struct nk_context*);
773
774/* =============================================================================
775 *
776 * DRAWING
777 *
778 * =============================================================================*/
1005enum nk_anti_aliasing {NK_ANTI_ALIASING_OFF, NK_ANTI_ALIASING_ON};
1006enum nk_convert_result {
1007 NK_CONVERT_SUCCESS = 0,
1008 NK_CONVERT_INVALID_PARAM = 1,
1009 NK_CONVERT_COMMAND_BUFFER_FULL = NK_FLAG(1),
1010 NK_CONVERT_VERTEX_BUFFER_FULL = NK_FLAG(2),
1011 NK_CONVERT_ELEMENT_BUFFER_FULL = NK_FLAG(3)
1012};
1014 nk_handle texture;
1015 struct nk_vec2 uv;
1016};
1018 float global_alpha;
1019 enum nk_anti_aliasing line_AA;
1020 enum nk_anti_aliasing shape_AA;
1025 const struct nk_draw_vertex_layout_element *vertex_layout;
1026 nk_size vertex_size;
1028};
1029
1043NK_API const struct nk_command* nk__begin(struct nk_context*);
1044
1058NK_API const struct nk_command* nk__next(struct nk_context*, const struct nk_command*);
1059
1070#define nk_foreach(c, ctx) for((c) = nk__begin(ctx); (c) != 0; (c) = nk__next(ctx,c))
1071
1072#ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
1073
1103NK_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*);
1104
1118NK_API const struct nk_draw_command* nk__draw_begin(const struct nk_context*, const struct nk_buffer*);
1119
1137NK_API const struct nk_draw_command* nk__draw_end(const struct nk_context*, const struct nk_buffer*);
1138
1156NK_API const struct nk_draw_command* nk__draw_next(const struct nk_draw_command*, const struct nk_buffer*, const struct nk_context*);
1157
1173#define nk_draw_foreach(cmd,ctx, b) for((cmd)=nk__draw_begin(ctx, b); (cmd)!=0; (cmd)=nk__draw_next(cmd, b, ctx))
1174#endif
1175
1176/* =============================================================================
1177 *
1178 * WINDOW
1179 *
1180 * =============================================================================*/
1329enum nk_panel_flags {
1330 NK_WINDOW_BORDER = NK_FLAG(0),
1331 NK_WINDOW_MOVABLE = NK_FLAG(1),
1332 NK_WINDOW_SCALABLE = NK_FLAG(2),
1333 NK_WINDOW_CLOSABLE = NK_FLAG(3),
1334 NK_WINDOW_MINIMIZABLE = NK_FLAG(4),
1335 NK_WINDOW_NO_SCROLLBAR = NK_FLAG(5),
1336 NK_WINDOW_TITLE = NK_FLAG(6),
1337 NK_WINDOW_SCROLL_AUTO_HIDE = NK_FLAG(7),
1338 NK_WINDOW_BACKGROUND = NK_FLAG(8),
1339 NK_WINDOW_SCALE_LEFT = NK_FLAG(9),
1340 NK_WINDOW_NO_INPUT = NK_FLAG(10)
1341};
1342
1363NK_API nk_bool nk_begin(struct nk_context *ctx, const char *title, struct nk_rect bounds, nk_flags flags);
1364
1386NK_API nk_bool nk_begin_titled(struct nk_context *ctx, const char *name, const char *title, struct nk_rect bounds, nk_flags flags);
1387
1402NK_API void nk_end(struct nk_context *ctx);
1403
1420NK_API struct nk_window *nk_window_find(const struct nk_context *ctx, const char *name);
1421
1439NK_API struct nk_rect nk_window_get_bounds(const struct nk_context *ctx);
1440
1458NK_API struct nk_vec2 nk_window_get_position(const struct nk_context *ctx);
1459
1477NK_API struct nk_vec2 nk_window_get_size(const struct nk_context *ctx);
1478
1495NK_API float nk_window_get_width(const struct nk_context *ctx);
1496
1514NK_API float nk_window_get_height(const struct nk_context* ctx);
1515
1535NK_API struct nk_panel* nk_window_get_panel(const struct nk_context* ctx);
1536
1556NK_API struct nk_rect nk_window_get_content_region(const struct nk_context* ctx);
1557
1577NK_API struct nk_vec2 nk_window_get_content_region_min(const struct nk_context *ctx);
1578
1598NK_API struct nk_vec2 nk_window_get_content_region_max(const struct nk_context *ctx);
1599
1618NK_API struct nk_vec2 nk_window_get_content_region_size(const struct nk_context *ctx);
1619
1637NK_API struct nk_command_buffer* nk_window_get_canvas(const struct nk_context* ctx);
1638
1655NK_API void nk_window_get_scroll(const struct nk_context *ctx, nk_uint *offset_x, nk_uint *offset_y);
1656
1673NK_API nk_bool nk_window_has_focus(const struct nk_context *ctx);
1674
1691NK_API nk_bool nk_window_is_hovered(const struct nk_context *ctx);
1692
1709NK_API nk_bool nk_window_is_collapsed(const struct nk_context *ctx, const char *name);
1710
1726NK_API nk_bool nk_window_is_closed(const struct nk_context *ctx, const char* name);
1727
1743NK_API nk_bool nk_window_is_hidden(const struct nk_context *ctx, const char* name);
1744
1759NK_API nk_bool nk_window_is_active(const struct nk_context *ctx, const char* name);
1760
1774NK_API nk_bool nk_window_is_any_hovered(const struct nk_context *ctx);
1775
1792NK_API nk_bool nk_item_is_any_active(const struct nk_context *ctx);
1793
1808NK_API void nk_window_set_bounds(struct nk_context *ctx, const char *name, struct nk_rect bounds);
1809
1824NK_API void nk_window_set_position(struct nk_context *ctx, const char *name, struct nk_vec2 pos);
1825
1840NK_API void nk_window_set_size(struct nk_context *ctx, const char *name, struct nk_vec2 size);
1841
1855NK_API void nk_window_set_focus(struct nk_context *ctx, const char *name);
1856
1873NK_API void nk_window_set_scroll(struct nk_context *ctx, nk_uint offset_x, nk_uint offset_y);
1874
1888NK_API void nk_window_close(struct nk_context *ctx, const char *name);
1889
1904NK_API void nk_window_collapse(struct nk_context *ctx, const char *name, enum nk_collapse_states state);
1905
1921NK_API void nk_window_collapse_if(struct nk_context *ctx, const char *name, enum nk_collapse_states state, int cond);
1922
1936NK_API void nk_window_show(struct nk_context *ctx, const char *name, enum nk_show_states state);
1937
1953NK_API void nk_window_show_if(struct nk_context *ctx, const char *name, enum nk_show_states state, int cond);
1954
1968NK_API void nk_rule_horizontal(struct nk_context *ctx, struct nk_color color, nk_bool rounding);
1969
1970/* =============================================================================
1971 *
1972 * LAYOUT
1973 *
1974 * =============================================================================*/
2242enum nk_widget_align {
2243 NK_WIDGET_ALIGN_LEFT = 0x01,
2244 NK_WIDGET_ALIGN_CENTERED = 0x02,
2245 NK_WIDGET_ALIGN_RIGHT = 0x04,
2246 NK_WIDGET_ALIGN_TOP = 0x08,
2247 NK_WIDGET_ALIGN_MIDDLE = 0x10,
2248 NK_WIDGET_ALIGN_BOTTOM = 0x20
2249};
2250enum nk_widget_alignment {
2251 NK_WIDGET_LEFT = NK_WIDGET_ALIGN_MIDDLE|NK_WIDGET_ALIGN_LEFT,
2252 NK_WIDGET_CENTERED = NK_WIDGET_ALIGN_MIDDLE|NK_WIDGET_ALIGN_CENTERED,
2253 NK_WIDGET_RIGHT = NK_WIDGET_ALIGN_MIDDLE|NK_WIDGET_ALIGN_RIGHT
2254};
2255
2268NK_API void nk_layout_set_min_row_height(struct nk_context*, float height);
2269
2278NK_API void nk_layout_reset_min_row_height(struct nk_context*);
2279
2292NK_API struct nk_rect nk_layout_widget_bounds(const struct nk_context *ctx);
2293
2307NK_API float nk_layout_ratio_from_pixel(const struct nk_context *ctx, float pixel_width);
2308
2323NK_API void nk_layout_row_dynamic(struct nk_context *ctx, float height, int cols);
2324
2340NK_API void nk_layout_row_static(struct nk_context *ctx, float height, int item_width, int cols);
2341
2355NK_API void nk_layout_row_begin(struct nk_context *ctx, enum nk_layout_format fmt, float row_height, int cols);
2356
2368NK_API void nk_layout_row_push(struct nk_context*, float value);
2369
2380NK_API void nk_layout_row_end(struct nk_context*);
2381
2395NK_API void nk_layout_row(struct nk_context*, enum nk_layout_format, float height, int cols, const float *ratio);
2396
2409NK_API void nk_layout_row_template_begin(struct nk_context*, float row_height);
2410
2423NK_API void nk_layout_row_template_push_dynamic(struct nk_context*);
2424
2437NK_API void nk_layout_row_template_push_variable(struct nk_context*, float min_width);
2438
2451NK_API void nk_layout_row_template_push_static(struct nk_context*, float width);
2452
2464NK_API void nk_layout_row_template_end(struct nk_context*);
2465
2480NK_API void nk_layout_space_begin(struct nk_context*, enum nk_layout_format, float height, int widget_count);
2481
2494NK_API void nk_layout_space_push(struct nk_context*, struct nk_rect bounds);
2495
2507NK_API void nk_layout_space_end(struct nk_context*);
2508
2522NK_API struct nk_rect nk_layout_space_bounds(const struct nk_context *ctx);
2523
2538NK_API struct nk_vec2 nk_layout_space_to_screen(const struct nk_context* ctx, struct nk_vec2 vec);
2539
2554NK_API struct nk_vec2 nk_layout_space_to_local(const struct nk_context *ctx, struct nk_vec2 vec);
2555
2570NK_API struct nk_rect nk_layout_space_rect_to_screen(const struct nk_context *ctx, struct nk_rect bounds);
2571
2586NK_API struct nk_rect nk_layout_space_rect_to_local(const struct nk_context *ctx, struct nk_rect bounds);
2587
2600NK_API void nk_spacer(struct nk_context *ctx);
2601
2602
2603/* =============================================================================
2604 *
2605 * GROUP
2606 *
2607 * =============================================================================*/
2707NK_API nk_bool nk_group_begin(struct nk_context*, const char *title, nk_flags);
2708
2722NK_API nk_bool nk_group_begin_titled(struct nk_context*, const char *name, const char *title, nk_flags);
2723
2735NK_API void nk_group_end(struct nk_context*);
2736
2755NK_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);
2756
2774NK_API nk_bool nk_group_scrolled_begin(struct nk_context*, struct nk_scroll *off, const char *title, nk_flags);
2775
2787NK_API void nk_group_scrolled_end(struct nk_context*);
2788
2803NK_API void nk_group_get_scroll(struct nk_context*, const char *id, nk_uint *x_offset, nk_uint *y_offset);
2804
2819NK_API void nk_group_set_scroll(struct nk_context*, const char *id, nk_uint x_offset, nk_uint y_offset);
2820
2821/* =============================================================================
2822 *
2823 * TREE
2824 *
2825 * =============================================================================*/
2912#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__)
2913
2931#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)
2932
2953NK_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);
2954
2976#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__)
2977
2998#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)
2999
3021NK_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);
3022
3034NK_API void nk_tree_pop(struct nk_context*);
3035
3052NK_API nk_bool nk_tree_state_push(struct nk_context*, enum nk_tree_type, const char *title, enum nk_collapse_states *state);
3053
3071NK_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);
3072
3084NK_API void nk_tree_state_pop(struct nk_context*);
3085
3086#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__)
3087#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)
3088NK_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);
3089NK_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);
3090NK_API void nk_tree_element_pop(struct nk_context*);
3091
3092/* =============================================================================
3093 *
3094 * LIST VIEW
3095 *
3096 * ============================================================================= */
3098/* public: */
3099 int begin, end, count;
3100/* private: */
3101 int total_height;
3102 struct nk_context *ctx;
3103 nk_uint *scroll_pointer;
3104 nk_uint scroll_value;
3105};
3106NK_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);
3107NK_API void nk_list_view_end(struct nk_list_view*);
3108/* =============================================================================
3109 *
3110 * WIDGET
3111 *
3112 * ============================================================================= */
3113enum nk_widget_layout_states {
3114 NK_WIDGET_INVALID,
3115 NK_WIDGET_VALID,
3116 NK_WIDGET_ROM,
3117 NK_WIDGET_DISABLED
3118};
3119enum nk_widget_states {
3120 NK_WIDGET_STATE_MODIFIED = NK_FLAG(1),
3121 NK_WIDGET_STATE_INACTIVE = NK_FLAG(2),
3122 NK_WIDGET_STATE_ENTERED = NK_FLAG(3),
3123 NK_WIDGET_STATE_HOVER = NK_FLAG(4),
3124 NK_WIDGET_STATE_ACTIVED = NK_FLAG(5),
3125 NK_WIDGET_STATE_LEFT = NK_FLAG(6),
3126 NK_WIDGET_STATE_HOVERED = NK_WIDGET_STATE_HOVER|NK_WIDGET_STATE_MODIFIED,
3127 NK_WIDGET_STATE_ACTIVE = NK_WIDGET_STATE_ACTIVED|NK_WIDGET_STATE_MODIFIED
3128};
3129NK_API enum nk_widget_layout_states nk_widget(struct nk_rect*, const struct nk_context*);
3130#define nk_widget_fitting(bounds, ctx, padding) nk_widget(bounds, ctx)
3131NK_API struct nk_rect nk_widget_bounds(const struct nk_context*);
3132NK_API struct nk_vec2 nk_widget_position(const struct nk_context*);
3133NK_API struct nk_vec2 nk_widget_size(const struct nk_context*);
3134NK_API float nk_widget_width(const struct nk_context*);
3135NK_API float nk_widget_height(const struct nk_context*);
3136NK_API nk_bool nk_widget_is_hovered(const struct nk_context*);
3137NK_API nk_bool nk_widget_is_mouse_clicked(const struct nk_context*, enum nk_buttons);
3138NK_API nk_bool nk_widget_has_mouse_click_down(const struct nk_context*, enum nk_buttons, nk_bool down);
3139NK_API void nk_spacing(struct nk_context*, int cols);
3140NK_API void nk_widget_disable_begin(struct nk_context* ctx);
3141NK_API void nk_widget_disable_end(struct nk_context* ctx);
3142/* =============================================================================
3143 *
3144 * TEXT
3145 *
3146 * ============================================================================= */
3147enum nk_text_align {
3148 NK_TEXT_ALIGN_LEFT = 0x01,
3149 NK_TEXT_ALIGN_CENTERED = 0x02,
3150 NK_TEXT_ALIGN_RIGHT = 0x04,
3151 NK_TEXT_ALIGN_TOP = 0x08,
3152 NK_TEXT_ALIGN_MIDDLE = 0x10,
3153 NK_TEXT_ALIGN_BOTTOM = 0x20
3154};
3155enum nk_text_alignment {
3156 NK_TEXT_LEFT = NK_TEXT_ALIGN_MIDDLE|NK_TEXT_ALIGN_LEFT,
3157 NK_TEXT_CENTERED = NK_TEXT_ALIGN_MIDDLE|NK_TEXT_ALIGN_CENTERED,
3158 NK_TEXT_RIGHT = NK_TEXT_ALIGN_MIDDLE|NK_TEXT_ALIGN_RIGHT
3159};
3160NK_API void nk_text(struct nk_context*, const char*, int, nk_flags);
3161NK_API void nk_text_colored(struct nk_context*, const char*, int, nk_flags, struct nk_color);
3162NK_API void nk_text_wrap(struct nk_context*, const char*, int);
3163NK_API void nk_text_wrap_colored(struct nk_context*, const char*, int, struct nk_color);
3164NK_API void nk_label(struct nk_context*, const char*, nk_flags align);
3165NK_API void nk_label_colored(struct nk_context*, const char*, nk_flags align, struct nk_color);
3166NK_API void nk_label_wrap(struct nk_context*, const char*);
3167NK_API void nk_label_colored_wrap(struct nk_context*, const char*, struct nk_color);
3168NK_API void nk_image(struct nk_context*, struct nk_image);
3169NK_API void nk_image_color(struct nk_context*, struct nk_image, struct nk_color);
3170#ifdef NK_INCLUDE_STANDARD_VARARGS
3171NK_API void nk_labelf(struct nk_context*, nk_flags, NK_PRINTF_FORMAT_STRING const char*, ...) NK_PRINTF_VARARG_FUNC(3);
3172NK_API void nk_labelf_colored(struct nk_context*, nk_flags, struct nk_color, NK_PRINTF_FORMAT_STRING const char*,...) NK_PRINTF_VARARG_FUNC(4);
3173NK_API void nk_labelf_wrap(struct nk_context*, NK_PRINTF_FORMAT_STRING const char*,...) NK_PRINTF_VARARG_FUNC(2);
3174NK_API void nk_labelf_colored_wrap(struct nk_context*, struct nk_color, NK_PRINTF_FORMAT_STRING const char*,...) NK_PRINTF_VARARG_FUNC(3);
3175NK_API void nk_labelfv(struct nk_context*, nk_flags, NK_PRINTF_FORMAT_STRING const char*, va_list) NK_PRINTF_VALIST_FUNC(3);
3176NK_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);
3177NK_API void nk_labelfv_wrap(struct nk_context*, NK_PRINTF_FORMAT_STRING const char*, va_list) NK_PRINTF_VALIST_FUNC(2);
3178NK_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);
3179NK_API void nk_value_bool(struct nk_context*, const char *prefix, int);
3180NK_API void nk_value_int(struct nk_context*, const char *prefix, int);
3181NK_API void nk_value_uint(struct nk_context*, const char *prefix, unsigned int);
3182NK_API void nk_value_float(struct nk_context*, const char *prefix, float);
3183NK_API void nk_value_color_byte(struct nk_context*, const char *prefix, struct nk_color);
3184NK_API void nk_value_color_float(struct nk_context*, const char *prefix, struct nk_color);
3185NK_API void nk_value_color_hex(struct nk_context*, const char *prefix, struct nk_color);
3186#endif
3187/* =============================================================================
3188 *
3189 * BUTTON
3190 *
3191 * ============================================================================= */
3192NK_API nk_bool nk_button_text(struct nk_context*, const char *title, int len);
3193NK_API nk_bool nk_button_label(struct nk_context*, const char *title);
3194NK_API nk_bool nk_button_color(struct nk_context*, struct nk_color);
3195NK_API nk_bool nk_button_symbol(struct nk_context*, enum nk_symbol_type);
3196NK_API nk_bool nk_button_image(struct nk_context*, struct nk_image img);
3197NK_API nk_bool nk_button_symbol_label(struct nk_context*, enum nk_symbol_type, const char*, nk_flags text_alignment);
3198NK_API nk_bool nk_button_symbol_text(struct nk_context*, enum nk_symbol_type, const char*, int, nk_flags alignment);
3199NK_API nk_bool nk_button_image_label(struct nk_context*, struct nk_image img, const char*, nk_flags text_alignment);
3200NK_API nk_bool nk_button_image_text(struct nk_context*, struct nk_image img, const char*, int, nk_flags alignment);
3201NK_API nk_bool nk_button_text_styled(struct nk_context*, const struct nk_style_button*, const char *title, int len);
3202NK_API nk_bool nk_button_label_styled(struct nk_context*, const struct nk_style_button*, const char *title);
3203NK_API nk_bool nk_button_symbol_styled(struct nk_context*, const struct nk_style_button*, enum nk_symbol_type);
3204NK_API nk_bool nk_button_image_styled(struct nk_context*, const struct nk_style_button*, struct nk_image img);
3205NK_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);
3206NK_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);
3207NK_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);
3208NK_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);
3209NK_API void nk_button_set_behavior(struct nk_context*, enum nk_button_behavior);
3210NK_API nk_bool nk_button_push_behavior(struct nk_context*, enum nk_button_behavior);
3211NK_API nk_bool nk_button_pop_behavior(struct nk_context*);
3212/* =============================================================================
3213 *
3214 * CHECKBOX
3215 *
3216 * ============================================================================= */
3217NK_API nk_bool nk_check_label(struct nk_context*, const char*, nk_bool active);
3218NK_API nk_bool nk_check_text(struct nk_context*, const char*, int, nk_bool active);
3219NK_API nk_bool nk_check_text_align(struct nk_context*, const char*, int, nk_bool active, nk_flags widget_alignment, nk_flags text_alignment);
3220NK_API unsigned nk_check_flags_label(struct nk_context*, const char*, unsigned int flags, unsigned int value);
3221NK_API unsigned nk_check_flags_text(struct nk_context*, const char*, int, unsigned int flags, unsigned int value);
3222NK_API nk_bool nk_checkbox_label(struct nk_context*, const char*, nk_bool *active);
3223NK_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);
3224NK_API nk_bool nk_checkbox_text(struct nk_context*, const char*, int, nk_bool *active);
3225NK_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);
3226NK_API nk_bool nk_checkbox_flags_label(struct nk_context*, const char*, unsigned int *flags, unsigned int value);
3227NK_API nk_bool nk_checkbox_flags_text(struct nk_context*, const char*, int, unsigned int *flags, unsigned int value);
3228/* =============================================================================
3229 *
3230 * RADIO BUTTON
3231 *
3232 * ============================================================================= */
3233NK_API nk_bool nk_radio_label(struct nk_context*, const char*, nk_bool *active);
3234NK_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);
3235NK_API nk_bool nk_radio_text(struct nk_context*, const char*, int, nk_bool *active);
3236NK_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);
3237NK_API nk_bool nk_option_label(struct nk_context*, const char*, nk_bool active);
3238NK_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);
3239NK_API nk_bool nk_option_text(struct nk_context*, const char*, int, nk_bool active);
3240NK_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);
3241/* =============================================================================
3242 *
3243 * SELECTABLE
3244 *
3245 * ============================================================================= */
3246NK_API nk_bool nk_selectable_label(struct nk_context*, const char*, nk_flags align, nk_bool *value);
3247NK_API nk_bool nk_selectable_text(struct nk_context*, const char*, int, nk_flags align, nk_bool *value);
3248NK_API nk_bool nk_selectable_image_label(struct nk_context*,struct nk_image, const char*, nk_flags align, nk_bool *value);
3249NK_API nk_bool nk_selectable_image_text(struct nk_context*,struct nk_image, const char*, int, nk_flags align, nk_bool *value);
3250NK_API nk_bool nk_selectable_symbol_label(struct nk_context*,enum nk_symbol_type, const char*, nk_flags align, nk_bool *value);
3251NK_API nk_bool nk_selectable_symbol_text(struct nk_context*,enum nk_symbol_type, const char*, int, nk_flags align, nk_bool *value);
3252
3253NK_API nk_bool nk_select_label(struct nk_context*, const char*, nk_flags align, nk_bool value);
3254NK_API nk_bool nk_select_text(struct nk_context*, const char*, int, nk_flags align, nk_bool value);
3255NK_API nk_bool nk_select_image_label(struct nk_context*, struct nk_image,const char*, nk_flags align, nk_bool value);
3256NK_API nk_bool nk_select_image_text(struct nk_context*, struct nk_image,const char*, int, nk_flags align, nk_bool value);
3257NK_API nk_bool nk_select_symbol_label(struct nk_context*,enum nk_symbol_type, const char*, nk_flags align, nk_bool value);
3258NK_API nk_bool nk_select_symbol_text(struct nk_context*,enum nk_symbol_type, const char*, int, nk_flags align, nk_bool value);
3259
3260/* =============================================================================
3261 *
3262 * SLIDER
3263 *
3264 * ============================================================================= */
3265NK_API float nk_slide_float(struct nk_context*, float min, float val, float max, float step);
3266NK_API int nk_slide_int(struct nk_context*, int min, int val, int max, int step);
3267NK_API nk_bool nk_slider_float(struct nk_context*, float min, float *val, float max, float step);
3268NK_API nk_bool nk_slider_int(struct nk_context*, int min, int *val, int max, int step);
3269
3270/* =============================================================================
3271 *
3272 * KNOB
3273 *
3274 * ============================================================================= */
3275NK_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);
3276NK_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);
3277
3278/* =============================================================================
3279 *
3280 * PROGRESSBAR
3281 *
3282 * ============================================================================= */
3283NK_API nk_bool nk_progress(struct nk_context*, nk_size *cur, nk_size max, nk_bool modifyable);
3284NK_API nk_size nk_prog(struct nk_context*, nk_size cur, nk_size max, nk_bool modifyable);
3285
3286/* =============================================================================
3287 *
3288 * COLOR PICKER
3289 *
3290 * ============================================================================= */
3291NK_API struct nk_colorf nk_color_picker(struct nk_context*, struct nk_colorf, enum nk_color_format);
3292NK_API nk_bool nk_color_pick(struct nk_context*, struct nk_colorf*, enum nk_color_format);
3293/* =============================================================================
3294 *
3295 * PROPERTIES
3296 *
3297 * =============================================================================*/
3391NK_API nk_bool nk_property_int(struct nk_context*, const char *name, int min, int *val, int max, int step, float inc_per_pixel);
3392
3415NK_API nk_bool nk_property_float(struct nk_context*, const char *name, float min, float *val, float max, float step, float inc_per_pixel);
3416
3439NK_API nk_bool nk_property_double(struct nk_context*, const char *name, double min, double *val, double max, double step, float inc_per_pixel);
3440
3461NK_API int nk_propertyi(struct nk_context*, const char *name, int min, int val, int max, int step, float inc_per_pixel);
3462
3483NK_API float nk_propertyf(struct nk_context*, const char *name, float min, float val, float max, float step, float inc_per_pixel);
3484
3505NK_API double nk_propertyd(struct nk_context*, const char *name, double min, double val, double max, double step, float inc_per_pixel);
3506
3507/* =============================================================================
3508 *
3509 * TEXT EDIT
3510 *
3511 * ============================================================================= */
3512enum nk_edit_flags {
3513 NK_EDIT_DEFAULT = 0,
3514 NK_EDIT_READ_ONLY = NK_FLAG(0),
3515 NK_EDIT_AUTO_SELECT = NK_FLAG(1),
3516 NK_EDIT_SIG_ENTER = NK_FLAG(2),
3517 NK_EDIT_ALLOW_TAB = NK_FLAG(3),
3518 NK_EDIT_NO_CURSOR = NK_FLAG(4),
3519 NK_EDIT_SELECTABLE = NK_FLAG(5),
3520 NK_EDIT_CLIPBOARD = NK_FLAG(6),
3521 NK_EDIT_CTRL_ENTER_NEWLINE = NK_FLAG(7),
3522 NK_EDIT_NO_HORIZONTAL_SCROLL = NK_FLAG(8),
3523 NK_EDIT_ALWAYS_INSERT_MODE = NK_FLAG(9),
3524 NK_EDIT_MULTILINE = NK_FLAG(10),
3525 NK_EDIT_GOTO_END_ON_ACTIVATE = NK_FLAG(11)
3526};
3527enum nk_edit_types {
3528 NK_EDIT_SIMPLE = NK_EDIT_ALWAYS_INSERT_MODE,
3529 NK_EDIT_FIELD = NK_EDIT_SIMPLE|NK_EDIT_SELECTABLE|NK_EDIT_CLIPBOARD,
3530 NK_EDIT_BOX = NK_EDIT_ALWAYS_INSERT_MODE| NK_EDIT_SELECTABLE| NK_EDIT_MULTILINE|NK_EDIT_ALLOW_TAB|NK_EDIT_CLIPBOARD,
3531 NK_EDIT_EDITOR = NK_EDIT_SELECTABLE|NK_EDIT_MULTILINE|NK_EDIT_ALLOW_TAB| NK_EDIT_CLIPBOARD
3532};
3533enum nk_edit_events {
3534 NK_EDIT_ACTIVE = NK_FLAG(0),
3535 NK_EDIT_INACTIVE = NK_FLAG(1),
3536 NK_EDIT_ACTIVATED = NK_FLAG(2),
3537 NK_EDIT_DEACTIVATED = NK_FLAG(3),
3538 NK_EDIT_COMMITTED = NK_FLAG(4)
3539};
3540
3541#define NK_EDIT_COMMITED NK_EDIT_COMMITTED
3542
3543NK_API nk_flags nk_edit_string(struct nk_context*, nk_flags, char *buffer, int *len, int max, nk_plugin_filter);
3544NK_API nk_flags nk_edit_string_zero_terminated(struct nk_context*, nk_flags, char *buffer, int max, nk_plugin_filter);
3545NK_API nk_flags nk_edit_buffer(struct nk_context*, nk_flags, struct nk_text_edit*, nk_plugin_filter);
3546NK_API void nk_edit_focus(struct nk_context*, nk_flags flags);
3547NK_API void nk_edit_unfocus(struct nk_context*);
3548/* =============================================================================
3549 *
3550 * CHART
3551 *
3552 * ============================================================================= */
3553NK_API nk_bool nk_chart_begin(struct nk_context*, enum nk_chart_type, int num, float min, float max);
3554NK_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);
3555NK_API void nk_chart_add_slot(struct nk_context *ctx, const enum nk_chart_type, int count, float min_value, float max_value);
3556NK_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);
3557NK_API nk_flags nk_chart_push(struct nk_context*, float);
3558NK_API nk_flags nk_chart_push_slot(struct nk_context*, float, int);
3559NK_API void nk_chart_end(struct nk_context*);
3560NK_API void nk_plot(struct nk_context*, enum nk_chart_type, const float *values, int count, int offset);
3561NK_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);
3562/* =============================================================================
3563 *
3564 * POPUP
3565 *
3566 * ============================================================================= */
3567NK_API nk_bool nk_popup_begin(struct nk_context*, enum nk_popup_type, const char*, nk_flags, struct nk_rect bounds);
3568NK_API void nk_popup_close(struct nk_context*);
3569NK_API void nk_popup_end(struct nk_context*);
3570NK_API void nk_popup_get_scroll(const struct nk_context*, nk_uint *offset_x, nk_uint *offset_y);
3571NK_API void nk_popup_set_scroll(struct nk_context*, nk_uint offset_x, nk_uint offset_y);
3572/* =============================================================================
3573 *
3574 * COMBOBOX
3575 *
3576 * ============================================================================= */
3577NK_API int nk_combo(struct nk_context*, const char *const *items, int count, int selected, int item_height, struct nk_vec2 size);
3578NK_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);
3579NK_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);
3580NK_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);
3581NK_API nk_bool nk_combobox(struct nk_context*, const char *const *items, int count, int *selected, int item_height, struct nk_vec2 size);
3582NK_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);
3583NK_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);
3584NK_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);
3585/* =============================================================================
3586 *
3587 * ABSTRACT COMBOBOX
3588 *
3589 * ============================================================================= */
3590NK_API nk_bool nk_combo_begin_text(struct nk_context*, const char *selected, int, struct nk_vec2 size);
3591NK_API nk_bool nk_combo_begin_label(struct nk_context*, const char *selected, struct nk_vec2 size);
3592NK_API nk_bool nk_combo_begin_color(struct nk_context*, struct nk_color color, struct nk_vec2 size);
3593NK_API nk_bool nk_combo_begin_symbol(struct nk_context*, enum nk_symbol_type, struct nk_vec2 size);
3594NK_API nk_bool nk_combo_begin_symbol_label(struct nk_context*, const char *selected, enum nk_symbol_type, struct nk_vec2 size);
3595NK_API nk_bool nk_combo_begin_symbol_text(struct nk_context*, const char *selected, int, enum nk_symbol_type, struct nk_vec2 size);
3596NK_API nk_bool nk_combo_begin_image(struct nk_context*, struct nk_image img, struct nk_vec2 size);
3597NK_API nk_bool nk_combo_begin_image_label(struct nk_context*, const char *selected, struct nk_image, struct nk_vec2 size);
3598NK_API nk_bool nk_combo_begin_image_text(struct nk_context*, const char *selected, int, struct nk_image, struct nk_vec2 size);
3599NK_API nk_bool nk_combo_item_label(struct nk_context*, const char*, nk_flags alignment);
3600NK_API nk_bool nk_combo_item_text(struct nk_context*, const char*,int, nk_flags alignment);
3601NK_API nk_bool nk_combo_item_image_label(struct nk_context*, struct nk_image, const char*, nk_flags alignment);
3602NK_API nk_bool nk_combo_item_image_text(struct nk_context*, struct nk_image, const char*, int,nk_flags alignment);
3603NK_API nk_bool nk_combo_item_symbol_label(struct nk_context*, enum nk_symbol_type, const char*, nk_flags alignment);
3604NK_API nk_bool nk_combo_item_symbol_text(struct nk_context*, enum nk_symbol_type, const char*, int, nk_flags alignment);
3605NK_API void nk_combo_close(struct nk_context*);
3606NK_API void nk_combo_end(struct nk_context*);
3607/* =============================================================================
3608 *
3609 * CONTEXTUAL
3610 *
3611 * ============================================================================= */
3612NK_API nk_bool nk_contextual_begin(struct nk_context*, nk_flags, struct nk_vec2, struct nk_rect trigger_bounds);
3613NK_API nk_bool nk_contextual_item_text(struct nk_context*, const char*, int,nk_flags align);
3614NK_API nk_bool nk_contextual_item_label(struct nk_context*, const char*, nk_flags align);
3615NK_API nk_bool nk_contextual_item_image_label(struct nk_context*, struct nk_image, const char*, nk_flags alignment);
3616NK_API nk_bool nk_contextual_item_image_text(struct nk_context*, struct nk_image, const char*, int len, nk_flags alignment);
3617NK_API nk_bool nk_contextual_item_symbol_label(struct nk_context*, enum nk_symbol_type, const char*, nk_flags alignment);
3618NK_API nk_bool nk_contextual_item_symbol_text(struct nk_context*, enum nk_symbol_type, const char*, int, nk_flags alignment);
3619NK_API void nk_contextual_close(struct nk_context*);
3620NK_API void nk_contextual_end(struct nk_context*);
3621/* =============================================================================
3622 *
3623 * TOOLTIP
3624 *
3625 * ============================================================================= */
3626NK_API void nk_tooltip(struct nk_context*, const char*);
3627NK_API void nk_tooltip_offset(struct nk_context *ctx, const char *text, enum nk_tooltip_pos position, struct nk_vec2 offset);
3628NK_API void nk_do_tooltip(struct nk_context*, const char*, struct nk_rect);
3629NK_API void nk_do_tooltip_delay(struct nk_context*, const char*, struct nk_rect, float*);
3630NK_API void nk_do_tooltip_delay_clicked(struct nk_context*, const char*, struct nk_rect, float* timer, nk_bool*);
3631#ifdef NK_INCLUDE_STANDARD_VARARGS
3632NK_API void nk_tooltipf(struct nk_context*, NK_PRINTF_FORMAT_STRING const char*, ...) NK_PRINTF_VARARG_FUNC(2);
3633NK_API void nk_tooltipfv(struct nk_context*, NK_PRINTF_FORMAT_STRING const char*, va_list) NK_PRINTF_VALIST_FUNC(2);
3634NK_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);
3635NK_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);
3636#endif
3637NK_API nk_bool nk_tooltip_begin(struct nk_context*, float width);
3638NK_API nk_bool nk_tooltip_begin_offset(struct nk_context*, float, enum nk_tooltip_pos, struct nk_vec2);
3639NK_API void nk_tooltip_end(struct nk_context*);
3640/* =============================================================================
3641 *
3642 * MENU
3643 *
3644 * ============================================================================= */
3645NK_API void nk_menubar_begin(struct nk_context*);
3646NK_API void nk_menubar_end(struct nk_context*);
3647NK_API nk_bool nk_menu_begin_text(struct nk_context*, const char* title, int title_len, nk_flags align, struct nk_vec2 size);
3648NK_API nk_bool nk_menu_begin_label(struct nk_context*, const char*, nk_flags align, struct nk_vec2 size);
3649NK_API nk_bool nk_menu_begin_image(struct nk_context*, const char*, struct nk_image, struct nk_vec2 size);
3650NK_API nk_bool nk_menu_begin_image_text(struct nk_context*, const char*, int,nk_flags align,struct nk_image, struct nk_vec2 size);
3651NK_API nk_bool nk_menu_begin_image_label(struct nk_context*, const char*, nk_flags align,struct nk_image, struct nk_vec2 size);
3652NK_API nk_bool nk_menu_begin_symbol(struct nk_context*, const char*, enum nk_symbol_type, struct nk_vec2 size);
3653NK_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);
3654NK_API nk_bool nk_menu_begin_symbol_label(struct nk_context*, const char*, nk_flags align,enum nk_symbol_type, struct nk_vec2 size);
3655NK_API nk_bool nk_menu_item_text(struct nk_context*, const char*, int,nk_flags align);
3656NK_API nk_bool nk_menu_item_label(struct nk_context*, const char*, nk_flags alignment);
3657NK_API nk_bool nk_menu_item_image_label(struct nk_context*, struct nk_image, const char*, nk_flags alignment);
3658NK_API nk_bool nk_menu_item_image_text(struct nk_context*, struct nk_image, const char*, int len, nk_flags alignment);
3659NK_API nk_bool nk_menu_item_symbol_text(struct nk_context*, enum nk_symbol_type, const char*, int, nk_flags alignment);
3660NK_API nk_bool nk_menu_item_symbol_label(struct nk_context*, enum nk_symbol_type, const char*, nk_flags alignment);
3661NK_API void nk_menu_close(struct nk_context*);
3662NK_API void nk_menu_end(struct nk_context*);
3663/* =============================================================================
3664 *
3665 * STYLE
3666 *
3667 * ============================================================================= */
3668
3669#define NK_WIDGET_DISABLED_FACTOR 0.5f
3670
3671enum nk_style_colors {
3672 NK_COLOR_TEXT,
3673 NK_COLOR_WINDOW,
3674 NK_COLOR_HEADER,
3675 NK_COLOR_BORDER,
3676 NK_COLOR_BUTTON,
3677 NK_COLOR_BUTTON_HOVER,
3678 NK_COLOR_BUTTON_ACTIVE,
3679 NK_COLOR_TOGGLE,
3680 NK_COLOR_TOGGLE_HOVER,
3681 NK_COLOR_TOGGLE_CURSOR,
3682 NK_COLOR_SELECT,
3683 NK_COLOR_SELECT_ACTIVE,
3684 NK_COLOR_SLIDER,
3685 NK_COLOR_SLIDER_CURSOR,
3686 NK_COLOR_SLIDER_CURSOR_HOVER,
3687 NK_COLOR_SLIDER_CURSOR_ACTIVE,
3688 NK_COLOR_PROPERTY,
3689 NK_COLOR_EDIT,
3690 NK_COLOR_EDIT_CURSOR,
3691 NK_COLOR_COMBO,
3692 NK_COLOR_CHART,
3693 NK_COLOR_CHART_COLOR,
3694 NK_COLOR_CHART_COLOR_HIGHLIGHT,
3695 NK_COLOR_SCROLLBAR,
3696 NK_COLOR_SCROLLBAR_CURSOR,
3697 NK_COLOR_SCROLLBAR_CURSOR_HOVER,
3698 NK_COLOR_SCROLLBAR_CURSOR_ACTIVE,
3699 NK_COLOR_TAB_HEADER,
3700 NK_COLOR_KNOB,
3701 NK_COLOR_KNOB_CURSOR,
3702 NK_COLOR_KNOB_CURSOR_HOVER,
3703 NK_COLOR_KNOB_CURSOR_ACTIVE,
3704 NK_COLOR_COUNT
3705};
3706enum nk_style_cursor {
3707 NK_CURSOR_ARROW,
3708 NK_CURSOR_TEXT,
3709 NK_CURSOR_MOVE,
3710 NK_CURSOR_RESIZE_VERTICAL,
3711 NK_CURSOR_RESIZE_HORIZONTAL,
3712 NK_CURSOR_RESIZE_TOP_LEFT_DOWN_RIGHT,
3713 NK_CURSOR_RESIZE_TOP_RIGHT_DOWN_LEFT,
3714 NK_CURSOR_COUNT
3715};
3716NK_API void nk_style_default(struct nk_context*);
3717NK_API void nk_style_from_table(struct nk_context*, const struct nk_color*);
3718NK_API void nk_style_load_cursor(struct nk_context*, enum nk_style_cursor, const struct nk_cursor*);
3719NK_API void nk_style_load_all_cursors(struct nk_context*, const struct nk_cursor*);
3720NK_API const char* nk_style_get_color_by_name(enum nk_style_colors);
3721NK_API void nk_style_set_font(struct nk_context*, const struct nk_user_font*);
3722NK_API nk_bool nk_style_set_cursor(struct nk_context*, enum nk_style_cursor);
3723NK_API void nk_style_show_cursor(struct nk_context*);
3724NK_API void nk_style_hide_cursor(struct nk_context*);
3725
3726NK_API nk_bool nk_style_push_font(struct nk_context*, const struct nk_user_font*);
3727NK_API nk_bool nk_style_push_float(struct nk_context*, float*, float);
3728NK_API nk_bool nk_style_push_vec2(struct nk_context*, struct nk_vec2*, struct nk_vec2);
3729NK_API nk_bool nk_style_push_style_item(struct nk_context*, struct nk_style_item*, struct nk_style_item);
3730NK_API nk_bool nk_style_push_flags(struct nk_context*, nk_flags*, nk_flags);
3731NK_API nk_bool nk_style_push_color(struct nk_context*, struct nk_color*, struct nk_color);
3732
3733NK_API nk_bool nk_style_pop_font(struct nk_context*);
3734NK_API nk_bool nk_style_pop_float(struct nk_context*);
3735NK_API nk_bool nk_style_pop_vec2(struct nk_context*);
3736NK_API nk_bool nk_style_pop_style_item(struct nk_context*);
3737NK_API nk_bool nk_style_pop_flags(struct nk_context*);
3738NK_API nk_bool nk_style_pop_color(struct nk_context*);
3739/* =============================================================================
3740 *
3741 * COLOR
3742 *
3743 * ============================================================================= */
3744NK_API struct nk_color nk_rgb(int r, int g, int b);
3745NK_API struct nk_color nk_rgb_iv(const int *rgb);
3746NK_API struct nk_color nk_rgb_bv(const nk_byte* rgb);
3747NK_API struct nk_color nk_rgb_f(float r, float g, float b);
3748NK_API struct nk_color nk_rgb_fv(const float *rgb);
3749NK_API struct nk_color nk_rgb_cf(struct nk_colorf c);
3750NK_API struct nk_color nk_rgb_hex(const char *rgb);
3751NK_API struct nk_color nk_rgb_factor(struct nk_color col, float factor);
3752
3753NK_API struct nk_color nk_rgba(int r, int g, int b, int a);
3754NK_API struct nk_color nk_rgba_u32(nk_uint);
3755NK_API struct nk_color nk_rgba_iv(const int *rgba);
3756NK_API struct nk_color nk_rgba_bv(const nk_byte *rgba);
3757NK_API struct nk_color nk_rgba_f(float r, float g, float b, float a);
3758NK_API struct nk_color nk_rgba_fv(const float *rgba);
3759NK_API struct nk_color nk_rgba_cf(struct nk_colorf c);
3760NK_API struct nk_color nk_rgba_hex(const char *rgb);
3761
3762NK_API struct nk_colorf nk_hsva_colorf(float h, float s, float v, float a);
3763NK_API struct nk_colorf nk_hsva_colorfv(const float *c);
3764NK_API void nk_colorf_hsva_f(float *out_h, float *out_s, float *out_v, float *out_a, struct nk_colorf in);
3765NK_API void nk_colorf_hsva_fv(float *hsva, struct nk_colorf in);
3766
3767NK_API struct nk_color nk_hsv(int h, int s, int v);
3768NK_API struct nk_color nk_hsv_iv(const int *hsv);
3769NK_API struct nk_color nk_hsv_bv(const nk_byte *hsv);
3770NK_API struct nk_color nk_hsv_f(float h, float s, float v);
3771NK_API struct nk_color nk_hsv_fv(const float *hsv);
3772
3773NK_API struct nk_color nk_hsva(int h, int s, int v, int a);
3774NK_API struct nk_color nk_hsva_iv(const int *hsva);
3775NK_API struct nk_color nk_hsva_bv(const nk_byte *hsva);
3776NK_API struct nk_color nk_hsva_f(float h, float s, float v, float a);
3777NK_API struct nk_color nk_hsva_fv(const float *hsva);
3778
3779/* color (conversion nuklear --> user) */
3780NK_API void nk_color_f(float *r, float *g, float *b, float *a, struct nk_color);
3781NK_API void nk_color_fv(float *rgba_out, struct nk_color);
3782NK_API struct nk_colorf nk_color_cf(struct nk_color);
3783NK_API void nk_color_d(double *r, double *g, double *b, double *a, struct nk_color);
3784NK_API void nk_color_dv(double *rgba_out, struct nk_color);
3785
3786NK_API nk_uint nk_color_u32(struct nk_color);
3787NK_API void nk_color_hex_rgba(char *output, struct nk_color);
3788NK_API void nk_color_hex_rgb(char *output, struct nk_color);
3789
3790NK_API void nk_color_hsv_i(int *out_h, int *out_s, int *out_v, struct nk_color);
3791NK_API void nk_color_hsv_b(nk_byte *out_h, nk_byte *out_s, nk_byte *out_v, struct nk_color);
3792NK_API void nk_color_hsv_iv(int *hsv_out, struct nk_color);
3793NK_API void nk_color_hsv_bv(nk_byte *hsv_out, struct nk_color);
3794NK_API void nk_color_hsv_f(float *out_h, float *out_s, float *out_v, struct nk_color);
3795NK_API void nk_color_hsv_fv(float *hsv_out, struct nk_color);
3796
3797NK_API void nk_color_hsva_i(int *h, int *s, int *v, int *a, struct nk_color);
3798NK_API void nk_color_hsva_b(nk_byte *h, nk_byte *s, nk_byte *v, nk_byte *a, struct nk_color);
3799NK_API void nk_color_hsva_iv(int *hsva_out, struct nk_color);
3800NK_API void nk_color_hsva_bv(nk_byte *hsva_out, struct nk_color);
3801NK_API void nk_color_hsva_f(float *out_h, float *out_s, float *out_v, float *out_a, struct nk_color);
3802NK_API void nk_color_hsva_fv(float *hsva_out, struct nk_color);
3803/* =============================================================================
3804 *
3805 * IMAGE
3806 *
3807 * ============================================================================= */
3808NK_API nk_handle nk_handle_ptr(void*);
3809NK_API nk_handle nk_handle_id(int);
3810NK_API struct nk_image nk_image_handle(nk_handle);
3811NK_API struct nk_image nk_image_ptr(void*);
3812NK_API struct nk_image nk_image_id(int);
3813NK_API nk_bool nk_image_is_subimage(const struct nk_image* img);
3814NK_API struct nk_image nk_subimage_ptr(void*, nk_ushort w, nk_ushort h, struct nk_rect sub_region);
3815NK_API struct nk_image nk_subimage_id(int, nk_ushort w, nk_ushort h, struct nk_rect sub_region);
3816NK_API struct nk_image nk_subimage_handle(nk_handle, nk_ushort w, nk_ushort h, struct nk_rect sub_region);
3817/* =============================================================================
3818 *
3819 * 9-SLICE
3820 *
3821 * ============================================================================= */
3822NK_API struct nk_nine_slice nk_nine_slice_handle(nk_handle, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b);
3823NK_API struct nk_nine_slice nk_nine_slice_ptr(void*, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b);
3824NK_API struct nk_nine_slice nk_nine_slice_id(int, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b);
3825NK_API int nk_nine_slice_is_sub9slice(const struct nk_nine_slice* img);
3826NK_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);
3827NK_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);
3828NK_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);
3829/* =============================================================================
3830 *
3831 * MATH
3832 *
3833 * ============================================================================= */
3834NK_API nk_hash nk_murmur_hash(const void *key, int len, nk_hash seed);
3835NK_API void nk_triangle_from_direction(struct nk_vec2 *result, struct nk_rect r, float pad_x, float pad_y, enum nk_heading);
3836
3837NK_API struct nk_vec2 nk_vec2(float x, float y);
3838NK_API struct nk_vec2 nk_vec2i(int x, int y);
3839NK_API struct nk_vec2 nk_vec2v(const float *xy);
3840NK_API struct nk_vec2 nk_vec2iv(const int *xy);
3841
3842NK_API struct nk_rect nk_get_null_rect(void);
3843NK_API struct nk_rect nk_rect(float x, float y, float w, float h);
3844NK_API struct nk_rect nk_recti(int x, int y, int w, int h);
3845NK_API struct nk_rect nk_recta(struct nk_vec2 pos, struct nk_vec2 size);
3846NK_API struct nk_rect nk_rectv(const float *xywh);
3847NK_API struct nk_rect nk_rectiv(const int *xywh);
3848NK_API struct nk_vec2 nk_rect_pos(struct nk_rect);
3849NK_API struct nk_vec2 nk_rect_size(struct nk_rect);
3850/* =============================================================================
3851 *
3852 * STRING
3853 *
3854 * ============================================================================= */
3855NK_API int nk_strlen(const char *str);
3856NK_API int nk_stricmp(const char *s1, const char *s2);
3857NK_API int nk_stricmpn(const char *s1, const char *s2, int n);
3858NK_API int nk_strtoi(const char *str, char **endptr);
3859NK_API float nk_strtof(const char *str, char **endptr);
3860#ifndef NK_STRTOD
3861#define NK_STRTOD nk_strtod
3862#define NK_STRTOD_NEEDED
3863NK_API double nk_strtod(const char *str, char **endptr);
3864#endif
3865NK_API int nk_strfilter(const char *text, const char *regexp);
3866NK_API int nk_strmatch_fuzzy_string(char const *str, char const *pattern, int *out_score);
3867NK_API int nk_strmatch_fuzzy_text(const char *txt, int txt_len, const char *pattern, int *out_score);
3868/* =============================================================================
3869 *
3870 * UTF-8
3871 *
3872 * ============================================================================= */
3873NK_API int nk_utf_decode(const char*, nk_rune*, int);
3874NK_API int nk_utf_encode(nk_rune, char*, int);
3875NK_API int nk_utf_len(const char*, int byte_len);
3876NK_API const char* nk_utf_at(const char *buffer, int length, int index, nk_rune *unicode, int *len);
3877/* ===============================================================
3878 *
3879 * FONT
3880 *
3881 * ===============================================================*/
4034struct nk_user_font_glyph;
4035typedef float(*nk_text_width_f)(nk_handle, float h, const char*, int len);
4036typedef void(*nk_query_font_glyph_f)(nk_handle handle, float font_height,
4037 struct nk_user_font_glyph *glyph,
4038 nk_rune codepoint, nk_rune next_codepoint);
4039
4040#if defined(NK_INCLUDE_VERTEX_BUFFER_OUTPUT) || defined(NK_INCLUDE_SOFTWARE_FONT)
4041struct nk_user_font_glyph {
4042 struct nk_vec2 uv[2];
4043 struct nk_vec2 offset;
4044 float width, height;
4045 float xadvance;
4046};
4047#endif
4048
4050 nk_handle userdata;
4051 float height;
4052 nk_text_width_f width;
4053#ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
4054 nk_query_font_glyph_f query;
4055 nk_handle texture;
4056#endif
4057};
4058
4059#ifdef NK_INCLUDE_FONT_BAKING
4060enum nk_font_coord_type {
4061 NK_COORD_UV,
4062 NK_COORD_PIXEL
4063};
4064
4065struct nk_font;
4066struct nk_baked_font {
4067 float height;
4068 float ascent;
4069 float descent;
4070 nk_rune glyph_offset;
4071 nk_rune glyph_count;
4072 const nk_rune *ranges;
4073};
4074
4075struct nk_font_config {
4076 struct nk_font_config *next;
4077 void *ttf_blob;
4078 nk_size ttf_size;
4080 unsigned char ttf_data_owned_by_atlas;
4081 unsigned char merge_mode;
4082 unsigned char pixel_snap;
4083 unsigned char oversample_v, oversample_h;
4084 unsigned char padding[3];
4085
4086 float size;
4087 enum nk_font_coord_type coord_type;
4088 struct nk_vec2 spacing;
4089 const nk_rune *range;
4090 struct nk_baked_font *font;
4091 nk_rune fallback_glyph;
4092 struct nk_font_config *n;
4093 struct nk_font_config *p;
4094};
4095
4096struct nk_font_glyph {
4097 nk_rune codepoint;
4098 float xadvance;
4099 float x0, y0, x1, y1, w, h;
4100 float u0, v0, u1, v1;
4101};
4102
4103struct nk_font {
4104 struct nk_font *next;
4105 struct nk_user_font handle;
4106 struct nk_baked_font info;
4107 float scale;
4108 struct nk_font_glyph *glyphs;
4109 const struct nk_font_glyph *fallback;
4110 nk_rune fallback_codepoint;
4111 nk_handle texture;
4112 struct nk_font_config *config;
4113};
4114
4115enum nk_font_atlas_format {
4116 NK_FONT_ATLAS_ALPHA8,
4117 NK_FONT_ATLAS_RGBA32
4118};
4119
4120struct nk_font_atlas {
4121 void *pixel;
4122 int tex_width;
4123 int tex_height;
4124
4125 struct nk_allocator permanent;
4126 struct nk_allocator temporary;
4127
4128 struct nk_recti custom;
4129 struct nk_cursor cursors[NK_CURSOR_COUNT];
4130
4131 int glyph_count;
4132 struct nk_font_glyph *glyphs;
4133 struct nk_font *default_font;
4134 struct nk_font *fonts;
4135 struct nk_font_config *config;
4136 int font_num;
4137};
4138
4140NK_API const nk_rune *nk_font_default_glyph_ranges(void);
4141NK_API const nk_rune *nk_font_chinese_glyph_ranges(void);
4142NK_API const nk_rune *nk_font_cyrillic_glyph_ranges(void);
4143NK_API const nk_rune *nk_font_korean_glyph_ranges(void);
4144
4145#ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
4146NK_API void nk_font_atlas_init_default(struct nk_font_atlas*);
4147#endif
4148NK_API void nk_font_atlas_init(struct nk_font_atlas*, const struct nk_allocator*);
4149NK_API void nk_font_atlas_init_custom(struct nk_font_atlas*, const struct nk_allocator *persistent, const struct nk_allocator *transient);
4150NK_API void nk_font_atlas_begin(struct nk_font_atlas*);
4151NK_API struct nk_font_config nk_font_config(float pixel_height);
4152NK_API struct nk_font *nk_font_atlas_add(struct nk_font_atlas*, const struct nk_font_config*);
4153#ifdef NK_INCLUDE_DEFAULT_FONT
4154NK_API struct nk_font* nk_font_atlas_add_default(struct nk_font_atlas*, float height, const struct nk_font_config*);
4155#endif
4156NK_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);
4157#ifdef NK_INCLUDE_STANDARD_IO
4158NK_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*);
4159#endif
4160NK_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*);
4161NK_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);
4162NK_API const void* nk_font_atlas_bake(struct nk_font_atlas*, int *width, int *height, enum nk_font_atlas_format);
4163NK_API void nk_font_atlas_end(struct nk_font_atlas*, nk_handle tex, struct nk_draw_null_texture*);
4164NK_API const struct nk_font_glyph* nk_font_find_glyph(const struct nk_font*, nk_rune unicode);
4165NK_API void nk_font_atlas_cleanup(struct nk_font_atlas *atlas);
4166NK_API void nk_font_atlas_clear(struct nk_font_atlas*);
4167
4168#endif
4169
4170/* ==============================================================
4171 *
4172 * MEMORY BUFFER
4173 *
4174 * ===============================================================*/
4207 void *memory;
4208 unsigned int type;
4209 nk_size size;
4210 nk_size allocated;
4211 nk_size needed;
4212 nk_size calls;
4213};
4214
4215enum nk_allocation_type {
4216 NK_BUFFER_FIXED,
4217 NK_BUFFER_DYNAMIC
4218};
4219
4220enum nk_buffer_allocation_type {
4221 NK_BUFFER_FRONT,
4222 NK_BUFFER_BACK,
4223 NK_BUFFER_MAX
4224};
4225
4227 nk_bool active;
4228 nk_size offset;
4229};
4230
4231struct nk_memory {void *ptr;nk_size size;};
4233 struct nk_buffer_marker marker[NK_BUFFER_MAX];
4235 enum nk_allocation_type type;
4238 nk_size allocated;
4239 nk_size needed;
4240 nk_size calls;
4241 nk_size size;
4242};
4243
4244#ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
4245NK_API void nk_buffer_init_default(struct nk_buffer*);
4246#endif
4247NK_API void nk_buffer_init(struct nk_buffer*, const struct nk_allocator*, nk_size size);
4248NK_API void nk_buffer_init_fixed(struct nk_buffer*, void *memory, nk_size size);
4249NK_API void nk_buffer_info(struct nk_memory_status*, const struct nk_buffer*);
4250NK_API void nk_buffer_push(struct nk_buffer*, enum nk_buffer_allocation_type type, const void *memory, nk_size size, nk_size align);
4251NK_API void nk_buffer_mark(struct nk_buffer*, enum nk_buffer_allocation_type type);
4252NK_API void nk_buffer_reset(struct nk_buffer*, enum nk_buffer_allocation_type type);
4253NK_API void nk_buffer_clear(struct nk_buffer*);
4254NK_API void nk_buffer_free(struct nk_buffer*);
4255NK_API void *nk_buffer_memory(struct nk_buffer*);
4256NK_API const void *nk_buffer_memory_const(const struct nk_buffer*);
4257NK_API nk_size nk_buffer_total(const struct nk_buffer*);
4258
4259/* ==============================================================
4260 *
4261 * STRING
4262 *
4263 * ===============================================================*/
4269struct nk_str {
4270 struct nk_buffer buffer;
4271 int len;
4272};
4273
4274#ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
4275NK_API void nk_str_init_default(struct nk_str*);
4276#endif
4277NK_API void nk_str_init(struct nk_str*, const struct nk_allocator*, nk_size size);
4278NK_API void nk_str_init_fixed(struct nk_str*, void *memory, nk_size size);
4279NK_API void nk_str_clear(struct nk_str*);
4280NK_API void nk_str_free(struct nk_str*);
4281
4282NK_API int nk_str_append_text_char(struct nk_str*, const char*, int);
4283NK_API int nk_str_append_str_char(struct nk_str*, const char*);
4284NK_API int nk_str_append_text_utf8(struct nk_str*, const char*, int);
4285NK_API int nk_str_append_str_utf8(struct nk_str*, const char*);
4286NK_API int nk_str_append_text_runes(struct nk_str*, const nk_rune*, int);
4287NK_API int nk_str_append_str_runes(struct nk_str*, const nk_rune*);
4288
4289NK_API int nk_str_insert_at_char(struct nk_str*, int pos, const char*, int);
4290NK_API int nk_str_insert_at_rune(struct nk_str*, int pos, const char*, int);
4291
4292NK_API int nk_str_insert_text_char(struct nk_str*, int pos, const char*, int);
4293NK_API int nk_str_insert_str_char(struct nk_str*, int pos, const char*);
4294NK_API int nk_str_insert_text_utf8(struct nk_str*, int pos, const char*, int);
4295NK_API int nk_str_insert_str_utf8(struct nk_str*, int pos, const char*);
4296NK_API int nk_str_insert_text_runes(struct nk_str*, int pos, const nk_rune*, int);
4297NK_API int nk_str_insert_str_runes(struct nk_str*, int pos, const nk_rune*);
4298
4299NK_API void nk_str_remove_chars(struct nk_str*, int len);
4300NK_API void nk_str_remove_runes(struct nk_str *str, int len);
4301NK_API void nk_str_delete_chars(struct nk_str*, int pos, int len);
4302NK_API void nk_str_delete_runes(struct nk_str*, int pos, int len);
4303
4304NK_API char *nk_str_at_char(struct nk_str*, int pos);
4305NK_API char *nk_str_at_rune(struct nk_str*, int pos, nk_rune *unicode, int *len);
4306NK_API nk_rune nk_str_rune_at(const struct nk_str*, int pos);
4307NK_API const char *nk_str_at_char_const(const struct nk_str*, int pos);
4308NK_API const char *nk_str_at_const(const struct nk_str*, int pos, nk_rune *unicode, int *len);
4309
4310NK_API char *nk_str_get(struct nk_str*);
4311NK_API const char *nk_str_get_const(const struct nk_str*);
4312NK_API int nk_str_len(const struct nk_str*);
4313NK_API int nk_str_len_char(const struct nk_str*);
4314
4315/* ===============================================================
4316 *
4317 * TEXT EDITOR
4318 *
4319 * ===============================================================*/
4346#ifndef NK_TEXTEDIT_UNDOSTATECOUNT
4347#define NK_TEXTEDIT_UNDOSTATECOUNT 99
4348#endif
4349
4350#ifndef NK_TEXTEDIT_UNDOCHARCOUNT
4351#define NK_TEXTEDIT_UNDOCHARCOUNT 999
4352#endif
4353
4354struct nk_text_edit;
4356 nk_handle userdata;
4357 nk_plugin_paste paste;
4358 nk_plugin_copy copy;
4359};
4360
4362 int where;
4363 short insert_length;
4364 short delete_length;
4365 short char_storage;
4366};
4367
4369 struct nk_text_undo_record undo_rec[NK_TEXTEDIT_UNDOSTATECOUNT];
4370 nk_rune undo_char[NK_TEXTEDIT_UNDOCHARCOUNT];
4371 short undo_point;
4372 short redo_point;
4373 short undo_char_point;
4374 short redo_char_point;
4375};
4376
4377enum nk_text_edit_type {
4378 NK_TEXT_EDIT_SINGLE_LINE,
4379 NK_TEXT_EDIT_MULTI_LINE
4380};
4381
4382enum nk_text_edit_mode {
4383 NK_TEXT_EDIT_MODE_VIEW,
4384 NK_TEXT_EDIT_MODE_INSERT,
4385 NK_TEXT_EDIT_MODE_REPLACE
4386};
4387
4389 struct nk_clipboard clip;
4390 struct nk_str string;
4391 nk_plugin_filter filter;
4392 struct nk_vec2 scrollbar;
4393
4394 int cursor;
4395 int select_start;
4396 int select_end;
4397 unsigned char mode;
4398 unsigned char cursor_at_end_of_line;
4399 unsigned char initialized;
4400 unsigned char has_preferred_x;
4401 unsigned char single_line;
4402 unsigned char active;
4403 unsigned char padding1;
4404 float preferred_x;
4405 struct nk_text_undo_state undo;
4406};
4407
4409NK_API nk_bool nk_filter_default(const struct nk_text_edit*, nk_rune unicode);
4410NK_API nk_bool nk_filter_ascii(const struct nk_text_edit*, nk_rune unicode);
4411NK_API nk_bool nk_filter_float(const struct nk_text_edit*, nk_rune unicode);
4412NK_API nk_bool nk_filter_decimal(const struct nk_text_edit*, nk_rune unicode);
4413NK_API nk_bool nk_filter_hex(const struct nk_text_edit*, nk_rune unicode);
4414NK_API nk_bool nk_filter_oct(const struct nk_text_edit*, nk_rune unicode);
4415NK_API nk_bool nk_filter_binary(const struct nk_text_edit*, nk_rune unicode);
4416
4418#ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
4419NK_API void nk_textedit_init_default(struct nk_text_edit*);
4420#endif
4421NK_API void nk_textedit_init(struct nk_text_edit*, const struct nk_allocator*, nk_size size);
4422NK_API void nk_textedit_init_fixed(struct nk_text_edit*, void *memory, nk_size size);
4423NK_API void nk_textedit_free(struct nk_text_edit*);
4424NK_API void nk_textedit_text(struct nk_text_edit*, const char*, int total_len);
4425NK_API void nk_textedit_delete(struct nk_text_edit*, int where, int len);
4426NK_API void nk_textedit_delete_selection(struct nk_text_edit*);
4427NK_API void nk_textedit_select_all(struct nk_text_edit*);
4428NK_API nk_bool nk_textedit_cut(struct nk_text_edit*);
4429NK_API nk_bool nk_textedit_paste(struct nk_text_edit*, char const*, int len);
4430NK_API void nk_textedit_undo(struct nk_text_edit*);
4431NK_API void nk_textedit_redo(struct nk_text_edit*);
4432
4433/* ===============================================================
4434 *
4435 * DRAWING
4436 *
4437 * ===============================================================*/
4487enum nk_command_type {
4488 NK_COMMAND_NOP,
4489 NK_COMMAND_SCISSOR,
4490 NK_COMMAND_LINE,
4491 NK_COMMAND_CURVE,
4492 NK_COMMAND_RECT,
4493 NK_COMMAND_RECT_FILLED,
4494 NK_COMMAND_RECT_MULTI_COLOR,
4495 NK_COMMAND_CIRCLE,
4496 NK_COMMAND_CIRCLE_FILLED,
4497 NK_COMMAND_ARC,
4498 NK_COMMAND_ARC_FILLED,
4499 NK_COMMAND_TRIANGLE,
4500 NK_COMMAND_TRIANGLE_FILLED,
4501 NK_COMMAND_POLYGON,
4502 NK_COMMAND_POLYGON_FILLED,
4503 NK_COMMAND_POLYLINE,
4504 NK_COMMAND_TEXT,
4505 NK_COMMAND_IMAGE,
4506 NK_COMMAND_CUSTOM
4507};
4508
4511 enum nk_command_type type;
4512 nk_size next;
4513#ifdef NK_INCLUDE_COMMAND_USERDATA
4514 nk_handle userdata;
4515#endif
4516};
4517
4519 struct nk_command header;
4520 short x, y;
4521 unsigned short w, h;
4522};
4523
4525 struct nk_command header;
4526 unsigned short line_thickness;
4527 struct nk_vec2i begin;
4528 struct nk_vec2i end;
4529 struct nk_color color;
4530};
4531
4533 struct nk_command header;
4534 unsigned short line_thickness;
4535 struct nk_vec2i begin;
4536 struct nk_vec2i end;
4537 struct nk_vec2i ctrl[2];
4538 struct nk_color color;
4539};
4540
4542 struct nk_command header;
4543 unsigned short rounding;
4544 unsigned short line_thickness;
4545 short x, y;
4546 unsigned short w, h;
4547 struct nk_color color;
4548};
4549
4551 struct nk_command header;
4552 unsigned short rounding;
4553 short x, y;
4554 unsigned short w, h;
4555 struct nk_color color;
4556};
4557
4559 struct nk_command header;
4560 short x, y;
4561 unsigned short w, h;
4562 struct nk_color left;
4563 struct nk_color top;
4564 struct nk_color bottom;
4565 struct nk_color right;
4566};
4567
4569 struct nk_command header;
4570 unsigned short line_thickness;
4571 struct nk_vec2i a;
4572 struct nk_vec2i b;
4573 struct nk_vec2i c;
4574 struct nk_color color;
4575};
4576
4578 struct nk_command header;
4579 struct nk_vec2i a;
4580 struct nk_vec2i b;
4581 struct nk_vec2i c;
4582 struct nk_color color;
4583};
4584
4586 struct nk_command header;
4587 short x, y;
4588 unsigned short line_thickness;
4589 unsigned short w, h;
4590 struct nk_color color;
4591};
4592
4594 struct nk_command header;
4595 short x, y;
4596 unsigned short w, h;
4597 struct nk_color color;
4598};
4599
4601 struct nk_command header;
4602 short cx, cy;
4603 unsigned short r;
4604 unsigned short line_thickness;
4605 float a[2];
4606 struct nk_color color;
4607};
4608
4610 struct nk_command header;
4611 short cx, cy;
4612 unsigned short r;
4613 float a[2];
4614 struct nk_color color;
4615};
4616
4618 struct nk_command header;
4619 struct nk_color color;
4620 unsigned short line_thickness;
4621 unsigned short point_count;
4622 struct nk_vec2i points[1];
4623};
4624
4626 struct nk_command header;
4627 struct nk_color color;
4628 unsigned short point_count;
4629 struct nk_vec2i points[1];
4630};
4631
4633 struct nk_command header;
4634 struct nk_color color;
4635 unsigned short line_thickness;
4636 unsigned short point_count;
4637 struct nk_vec2i points[1];
4638};
4639
4641 struct nk_command header;
4642 short x, y;
4643 unsigned short w, h;
4644 struct nk_image img;
4645 struct nk_color col;
4646};
4647
4648typedef void (*nk_command_custom_callback)(void *canvas, short x,short y,
4649 unsigned short w, unsigned short h, nk_handle callback_data);
4651 struct nk_command header;
4652 short x, y;
4653 unsigned short w, h;
4654 nk_handle callback_data;
4655 nk_command_custom_callback callback;
4656};
4657
4659 struct nk_command header;
4660 const struct nk_user_font *font;
4661 struct nk_color background;
4662 struct nk_color foreground;
4663 short x, y;
4664 unsigned short w, h;
4665 float height;
4666 int length;
4667 char string[2];
4668};
4669
4670enum nk_command_clipping {
4671 NK_CLIPPING_OFF = nk_false,
4672 NK_CLIPPING_ON = nk_true
4673};
4674
4676 struct nk_buffer *base;
4677 struct nk_rect clip;
4678 int use_clipping;
4679 nk_handle userdata;
4680 nk_size begin, end, last;
4681};
4682
4684NK_API void nk_stroke_line(struct nk_command_buffer *b, float x0, float y0, float x1, float y1, float line_thickness, struct nk_color);
4685NK_API void nk_stroke_curve(struct nk_command_buffer*, float, float, float, float, float, float, float, float, float line_thickness, struct nk_color);
4686NK_API void nk_stroke_rect(struct nk_command_buffer*, struct nk_rect, float rounding, float line_thickness, struct nk_color);
4687NK_API void nk_stroke_circle(struct nk_command_buffer*, struct nk_rect, float line_thickness, struct nk_color);
4688NK_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);
4689NK_API void nk_stroke_triangle(struct nk_command_buffer*, float, float, float, float, float, float, float line_thichness, struct nk_color);
4690NK_API void nk_stroke_polyline(struct nk_command_buffer*, const float *points, int point_count, float line_thickness, struct nk_color col);
4691NK_API void nk_stroke_polygon(struct nk_command_buffer*, const float *points, int point_count, float line_thickness, struct nk_color);
4692
4694NK_API void nk_fill_rect(struct nk_command_buffer*, struct nk_rect, float rounding, struct nk_color);
4695NK_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);
4696NK_API void nk_fill_circle(struct nk_command_buffer*, struct nk_rect, struct nk_color);
4697NK_API void nk_fill_arc(struct nk_command_buffer*, float cx, float cy, float radius, float a_min, float a_max, struct nk_color);
4698NK_API void nk_fill_triangle(struct nk_command_buffer*, float x0, float y0, float x1, float y1, float x2, float y2, struct nk_color);
4699NK_API void nk_fill_polygon(struct nk_command_buffer*, const float *points, int point_count, struct nk_color);
4700
4702NK_API void nk_draw_image(struct nk_command_buffer*, struct nk_rect, const struct nk_image*, struct nk_color);
4703NK_API void nk_draw_nine_slice(struct nk_command_buffer*, struct nk_rect, const struct nk_nine_slice*, struct nk_color);
4704NK_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);
4705NK_API void nk_push_scissor(struct nk_command_buffer*, struct nk_rect);
4706NK_API void nk_push_custom(struct nk_command_buffer*, struct nk_rect, nk_command_custom_callback, nk_handle usr);
4707
4708/* ===============================================================
4709 *
4710 * INPUT
4711 *
4712 * ===============================================================*/
4714 nk_bool down;
4715 unsigned int clicked;
4716 struct nk_vec2 clicked_pos;
4717};
4718struct nk_mouse {
4719 struct nk_mouse_button buttons[NK_BUTTON_MAX];
4720 struct nk_vec2 pos;
4721#ifdef NK_BUTTON_TRIGGER_ON_RELEASE
4722 struct nk_vec2 down_pos;
4723#endif
4724 struct nk_vec2 prev;
4725 struct nk_vec2 delta;
4726 struct nk_vec2 scroll_delta;
4727 unsigned char grab;
4728 unsigned char grabbed;
4729 unsigned char ungrab;
4730};
4731
4732struct nk_key {
4733 nk_bool down;
4734 unsigned int clicked;
4735};
4737 struct nk_key keys[NK_KEY_MAX];
4738 char text[NK_INPUT_MAX];
4739 int text_len;
4740};
4741
4742struct nk_input {
4743 struct nk_keyboard keyboard;
4744 struct nk_mouse mouse;
4745};
4746
4747NK_API nk_bool nk_input_has_mouse_click(const struct nk_input*, enum nk_buttons);
4748NK_API nk_bool nk_input_has_mouse_click_in_rect(const struct nk_input*, enum nk_buttons, struct nk_rect);
4749NK_API nk_bool nk_input_has_mouse_click_in_button_rect(const struct nk_input*, enum nk_buttons, struct nk_rect);
4750NK_API nk_bool nk_input_has_mouse_click_down_in_rect(const struct nk_input*, enum nk_buttons, struct nk_rect, nk_bool down);
4751NK_API nk_bool nk_input_is_mouse_click_in_rect(const struct nk_input*, enum nk_buttons, struct nk_rect);
4752NK_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);
4753NK_API nk_bool nk_input_any_mouse_click_in_rect(const struct nk_input*, struct nk_rect);
4754NK_API nk_bool nk_input_is_mouse_prev_hovering_rect(const struct nk_input*, struct nk_rect);
4755NK_API nk_bool nk_input_is_mouse_hovering_rect(const struct nk_input*, struct nk_rect);
4756NK_API nk_bool nk_input_is_mouse_hovering_still_rect(const struct nk_input*, struct nk_rect);
4757NK_API nk_bool nk_input_is_mouse_hovering_delay_rect(const struct nk_context*, struct nk_rect, float*, float);
4758NK_API nk_bool nk_input_is_mouse_hovering_still_delay_rect(const struct nk_context*, struct nk_rect, float*, float);
4759NK_API nk_bool nk_input_is_mouse_hovering_still_delay_clicked_rect(const struct nk_context*, struct nk_rect, float*, float, nk_bool*);
4760NK_API nk_bool nk_input_is_mouse_moved(const struct nk_input*);
4761NK_API nk_bool nk_input_mouse_clicked(const struct nk_input*, enum nk_buttons, struct nk_rect);
4762NK_API nk_bool nk_input_is_mouse_down(const struct nk_input*, enum nk_buttons);
4763NK_API nk_bool nk_input_is_mouse_pressed(const struct nk_input*, enum nk_buttons);
4764NK_API nk_bool nk_input_is_mouse_released(const struct nk_input*, enum nk_buttons);
4765NK_API nk_bool nk_input_is_key_pressed(const struct nk_input*, enum nk_keys);
4766NK_API nk_bool nk_input_is_key_released(const struct nk_input*, enum nk_keys);
4767NK_API nk_bool nk_input_is_key_down(const struct nk_input*, enum nk_keys);
4768
4769/* ===============================================================
4770 *
4771 * DRAW LIST
4772 *
4773 * ===============================================================*/
4774#ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
4791#ifdef NK_UINT_DRAW_INDEX
4792typedef nk_uint nk_draw_index;
4793#else
4794typedef nk_ushort nk_draw_index;
4795#endif
4796enum nk_draw_list_stroke {
4797 NK_STROKE_OPEN = nk_false, /***< build up path has no connection back to the beginning */
4798 NK_STROKE_CLOSED = nk_true /***< build up path has a connection back to the beginning */
4799};
4800
4801enum nk_draw_vertex_layout_attribute {
4802 NK_VERTEX_POSITION,
4803 NK_VERTEX_COLOR,
4804 NK_VERTEX_TEXCOORD,
4805 NK_VERTEX_ATTRIBUTE_COUNT
4806};
4807
4808enum nk_draw_vertex_layout_format {
4809 NK_FORMAT_SCHAR,
4810 NK_FORMAT_SSHORT,
4811 NK_FORMAT_SINT,
4812 NK_FORMAT_UCHAR,
4813 NK_FORMAT_USHORT,
4814 NK_FORMAT_UINT,
4815 NK_FORMAT_FLOAT,
4816 NK_FORMAT_DOUBLE,
4817
4818NK_FORMAT_COLOR_BEGIN,
4819 NK_FORMAT_R8G8B8 = NK_FORMAT_COLOR_BEGIN,
4820 NK_FORMAT_R16G15B16,
4821 NK_FORMAT_R32G32B32,
4822
4823 NK_FORMAT_R8G8B8A8,
4824 NK_FORMAT_B8G8R8A8,
4825 NK_FORMAT_R16G15B16A16,
4826 NK_FORMAT_R32G32B32A32,
4827 NK_FORMAT_R32G32B32A32_FLOAT,
4828 NK_FORMAT_R32G32B32A32_DOUBLE,
4829
4830 NK_FORMAT_RGB32,
4831 NK_FORMAT_RGBA32,
4832NK_FORMAT_COLOR_END = NK_FORMAT_RGBA32,
4833 NK_FORMAT_COUNT
4834};
4835
4836#define NK_VERTEX_LAYOUT_END NK_VERTEX_ATTRIBUTE_COUNT,NK_FORMAT_COUNT,0
4837struct nk_draw_vertex_layout_element {
4838 enum nk_draw_vertex_layout_attribute attribute;
4839 enum nk_draw_vertex_layout_format format;
4840 nk_size offset;
4841};
4842
4843struct nk_draw_command {
4844 unsigned int elem_count;
4845 struct nk_rect clip_rect;
4846 nk_handle texture;
4847#ifdef NK_INCLUDE_COMMAND_USERDATA
4848 nk_handle userdata;
4849#endif
4850};
4851
4852struct nk_draw_list {
4853 struct nk_rect clip_rect;
4854 struct nk_vec2 circle_vtx[12];
4855 struct nk_convert_config config;
4856
4857 struct nk_buffer *buffer;
4858 struct nk_buffer *vertices;
4859 struct nk_buffer *elements;
4860
4861 unsigned int element_count;
4862 unsigned int vertex_count;
4863 unsigned int cmd_count;
4864 nk_size cmd_offset;
4865
4866 unsigned int path_count;
4867 unsigned int path_offset;
4868
4869 enum nk_anti_aliasing line_AA;
4870 enum nk_anti_aliasing shape_AA;
4871
4872#ifdef NK_INCLUDE_COMMAND_USERDATA
4873 nk_handle userdata;
4874#endif
4875};
4876
4877/* draw list */
4878NK_API void nk_draw_list_init(struct nk_draw_list*);
4879NK_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);
4880
4881/* drawing */
4882#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))
4883NK_API const struct nk_draw_command* nk__draw_list_begin(const struct nk_draw_list*, const struct nk_buffer*);
4884NK_API const struct nk_draw_command* nk__draw_list_next(const struct nk_draw_command*, const struct nk_buffer*, const struct nk_draw_list*);
4885NK_API const struct nk_draw_command* nk__draw_list_end(const struct nk_draw_list*, const struct nk_buffer*);
4886
4887/* path */
4888NK_API void nk_draw_list_path_clear(struct nk_draw_list*);
4889NK_API void nk_draw_list_path_line_to(struct nk_draw_list*, struct nk_vec2 pos);
4890NK_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);
4891NK_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);
4892NK_API void nk_draw_list_path_rect_to(struct nk_draw_list*, struct nk_vec2 a, struct nk_vec2 b, float rounding);
4893NK_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);
4894NK_API void nk_draw_list_path_fill(struct nk_draw_list*, struct nk_color);
4895NK_API void nk_draw_list_path_stroke(struct nk_draw_list*, struct nk_color, enum nk_draw_list_stroke closed, float thickness);
4896
4897/* stroke */
4898NK_API void nk_draw_list_stroke_line(struct nk_draw_list*, struct nk_vec2 a, struct nk_vec2 b, struct nk_color, float thickness);
4899NK_API void nk_draw_list_stroke_rect(struct nk_draw_list*, struct nk_rect rect, struct nk_color, float rounding, float thickness);
4900NK_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);
4901NK_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);
4902NK_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);
4903NK_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);
4904
4905/* fill */
4906NK_API void nk_draw_list_fill_rect(struct nk_draw_list*, struct nk_rect rect, struct nk_color, float rounding);
4907NK_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);
4908NK_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);
4909NK_API void nk_draw_list_fill_circle(struct nk_draw_list*, struct nk_vec2 center, float radius, struct nk_color col, unsigned int segs);
4910NK_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);
4911
4912/* misc */
4913NK_API void nk_draw_list_add_image(struct nk_draw_list*, struct nk_image texture, struct nk_rect rect, struct nk_color);
4914NK_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);
4915#ifdef NK_INCLUDE_COMMAND_USERDATA
4916NK_API void nk_draw_list_push_userdata(struct nk_draw_list*, nk_handle userdata);
4917#endif
4918
4919#endif
4920
4921/* ===============================================================
4922 *
4923 * GUI
4924 *
4925 * ===============================================================*/
4926enum nk_style_item_type {
4927 NK_STYLE_ITEM_COLOR,
4928 NK_STYLE_ITEM_IMAGE,
4929 NK_STYLE_ITEM_NINE_SLICE
4930};
4931
4933 struct nk_color color;
4934 struct nk_image image;
4935 struct nk_nine_slice slice;
4936};
4937
4939 enum nk_style_item_type type;
4940 union nk_style_item_data data;
4941};
4942
4944 struct nk_color color;
4945 struct nk_vec2 padding;
4946 float color_factor;
4947 float disabled_factor;
4948};
4949
4951 /* background */
4952 struct nk_style_item normal;
4953 struct nk_style_item hover;
4954 struct nk_style_item active;
4955 struct nk_color border_color;
4956 float color_factor_background;
4957
4958 /* text */
4959 struct nk_color text_background;
4960 struct nk_color text_normal;
4961 struct nk_color text_hover;
4962 struct nk_color text_active;
4963 nk_flags text_alignment;
4964 float color_factor_text;
4965
4966 /* properties */
4967 float border;
4968 float rounding;
4969 struct nk_vec2 padding;
4970 struct nk_vec2 image_padding;
4971 struct nk_vec2 touch_padding;
4972 float disabled_factor;
4973
4974 /* optional user callbacks */
4975 nk_handle userdata;
4976 void(*draw_begin)(struct nk_command_buffer*, nk_handle userdata);
4977 void(*draw_end)(struct nk_command_buffer*, nk_handle userdata);
4978};
4979
4981 /* background */
4982 struct nk_style_item normal;
4983 struct nk_style_item hover;
4984 struct nk_style_item active;
4985 struct nk_color border_color;
4986
4987 /* cursor */
4988 struct nk_style_item cursor_normal;
4989 struct nk_style_item cursor_hover;
4990
4991 /* text */
4992 struct nk_color text_normal;
4993 struct nk_color text_hover;
4994 struct nk_color text_active;
4995 struct nk_color text_background;
4996 nk_flags text_alignment;
4997
4998 /* properties */
4999 struct nk_vec2 padding;
5000 struct nk_vec2 touch_padding;
5001 float spacing;
5002 float border;
5003 float color_factor;
5004 float disabled_factor;
5005
5006 /* optional user callbacks */
5007 nk_handle userdata;
5008 void(*draw_begin)(struct nk_command_buffer*, nk_handle);
5009 void(*draw_end)(struct nk_command_buffer*, nk_handle);
5010};
5011
5013 /* background (inactive) */
5014 struct nk_style_item normal;
5015 struct nk_style_item hover;
5016 struct nk_style_item pressed;
5017
5018 /* background (active) */
5019 struct nk_style_item normal_active;
5020 struct nk_style_item hover_active;
5021 struct nk_style_item pressed_active;
5022
5023 /* text color (inactive) */
5024 struct nk_color text_normal;
5025 struct nk_color text_hover;
5026 struct nk_color text_pressed;
5027
5028 /* text color (active) */
5029 struct nk_color text_normal_active;
5030 struct nk_color text_hover_active;
5031 struct nk_color text_pressed_active;
5032 struct nk_color text_background;
5033 nk_flags text_alignment;
5034
5035 /* properties */
5036 float rounding;
5037 struct nk_vec2 padding;
5038 struct nk_vec2 touch_padding;
5039 struct nk_vec2 image_padding;
5040 float color_factor;
5041 float disabled_factor;
5042
5043 /* optional user callbacks */
5044 nk_handle userdata;
5045 void(*draw_begin)(struct nk_command_buffer*, nk_handle);
5046 void(*draw_end)(struct nk_command_buffer*, nk_handle);
5047};
5048
5050 /* background */
5051 struct nk_style_item normal;
5052 struct nk_style_item hover;
5053 struct nk_style_item active;
5054 struct nk_color border_color;
5055
5056 /* background bar */
5057 struct nk_color bar_normal;
5058 struct nk_color bar_hover;
5059 struct nk_color bar_active;
5060 struct nk_color bar_filled;
5061
5062 /* cursor */
5063 struct nk_style_item cursor_normal;
5064 struct nk_style_item cursor_hover;
5065 struct nk_style_item cursor_active;
5066
5067 /* properties */
5068 float border;
5069 float rounding;
5070 float bar_height;
5071 struct nk_vec2 padding;
5072 struct nk_vec2 spacing;
5073 struct nk_vec2 cursor_size; /* NOTE y has no effect on vertex buffer backends */
5074 float color_factor;
5075 float disabled_factor;
5076
5077 /* optional buttons */
5078 int show_buttons;
5079 struct nk_style_button inc_button;
5080 struct nk_style_button dec_button;
5081 enum nk_symbol_type inc_symbol;
5082 enum nk_symbol_type dec_symbol;
5083
5084 /* optional user callbacks */
5085 nk_handle userdata;
5086 void(*draw_begin)(struct nk_command_buffer*, nk_handle);
5087 void(*draw_end)(struct nk_command_buffer*, nk_handle);
5088};
5089
5091 /* background */
5092 struct nk_style_item normal;
5093 struct nk_style_item hover;
5094 struct nk_style_item active;
5095 struct nk_color border_color;
5096
5097 /* knob */
5098 struct nk_color knob_normal;
5099 struct nk_color knob_hover;
5100 struct nk_color knob_active;
5101 struct nk_color knob_border_color;
5102
5103 /* cursor */
5104 struct nk_color cursor_normal;
5105 struct nk_color cursor_hover;
5106 struct nk_color cursor_active;
5107
5108 /* properties */
5109 float border;
5110 float knob_border;
5111 struct nk_vec2 padding;
5112 struct nk_vec2 spacing;
5113 float cursor_width;
5114 float color_factor;
5115 float disabled_factor;
5116
5117 /* optional user callbacks */
5118 nk_handle userdata;
5119 void(*draw_begin)(struct nk_command_buffer*, nk_handle);
5120 void(*draw_end)(struct nk_command_buffer*, nk_handle);
5121};
5122
5124 /* background */
5125 struct nk_style_item normal;
5126 struct nk_style_item hover;
5127 struct nk_style_item active;
5128 struct nk_color border_color;
5129
5130 /* cursor */
5131 struct nk_style_item cursor_normal;
5132 struct nk_style_item cursor_hover;
5133 struct nk_style_item cursor_active;
5134 struct nk_color cursor_border_color;
5135
5136 /* properties */
5137 float rounding;
5138 float border;
5139 float cursor_border;
5140 float cursor_rounding;
5141 struct nk_vec2 padding;
5142 float color_factor;
5143 float disabled_factor;
5144
5145 /* optional user callbacks */
5146 nk_handle userdata;
5147 void(*draw_begin)(struct nk_command_buffer*, nk_handle);
5148 void(*draw_end)(struct nk_command_buffer*, nk_handle);
5149};
5150
5152 /* background */
5153 struct nk_style_item normal;
5154 struct nk_style_item hover;
5155 struct nk_style_item active;
5156 struct nk_color border_color;
5157
5158 /* cursor */
5159 struct nk_style_item cursor_normal;
5160 struct nk_style_item cursor_hover;
5161 struct nk_style_item cursor_active;
5162 struct nk_color cursor_border_color;
5163
5164 /* properties */
5165 float border;
5166 float rounding;
5167 float border_cursor;
5168 float rounding_cursor;
5169 struct nk_vec2 padding;
5170 float color_factor;
5171 float disabled_factor;
5172
5173 /* optional buttons */
5174 int show_buttons;
5175 struct nk_style_button inc_button;
5176 struct nk_style_button dec_button;
5177 enum nk_symbol_type inc_symbol;
5178 enum nk_symbol_type dec_symbol;
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 struct nk_style_scrollbar scrollbar;
5193
5194 /* cursor */
5195 struct nk_color cursor_normal;
5196 struct nk_color cursor_hover;
5197 struct nk_color cursor_text_normal;
5198 struct nk_color cursor_text_hover;
5199
5200 /* text (unselected) */
5201 struct nk_color text_normal;
5202 struct nk_color text_hover;
5203 struct nk_color text_active;
5204
5205 /* text (selected) */
5206 struct nk_color selected_normal;
5207 struct nk_color selected_hover;
5208 struct nk_color selected_text_normal;
5209 struct nk_color selected_text_hover;
5210
5211 /* properties */
5212 float border;
5213 float rounding;
5214 float cursor_size;
5215 struct nk_vec2 scrollbar_size;
5216 struct nk_vec2 padding;
5217 float row_padding;
5218 float color_factor;
5219 float disabled_factor;
5220};
5221
5223 /* background */
5224 struct nk_style_item normal;
5225 struct nk_style_item hover;
5226 struct nk_style_item active;
5227 struct nk_color border_color;
5228
5229 /* text */
5230 struct nk_color label_normal;
5231 struct nk_color label_hover;
5232 struct nk_color label_active;
5233
5234 /* symbols */
5235 enum nk_symbol_type sym_left;
5236 enum nk_symbol_type sym_right;
5237
5238 /* properties */
5239 float border;
5240 float rounding;
5241 struct nk_vec2 padding;
5242 float color_factor;
5243 float disabled_factor;
5244
5245 struct nk_style_edit edit;
5246 struct nk_style_button inc_button;
5247 struct nk_style_button dec_button;
5248
5249 /* optional user callbacks */
5250 nk_handle userdata;
5251 void(*draw_begin)(struct nk_command_buffer*, nk_handle);
5252 void(*draw_end)(struct nk_command_buffer*, nk_handle);
5253};
5254
5256 /* colors */
5257 struct nk_style_item background;
5258 struct nk_color border_color;
5259 struct nk_color selected_color;
5260 struct nk_color color;
5261
5262 /* properties */
5263 float border;
5264 float rounding;
5265 struct nk_vec2 padding;
5266 float color_factor;
5267 float disabled_factor;
5268 nk_bool show_markers;
5269};
5270
5272 /* background */
5273 struct nk_style_item normal;
5274 struct nk_style_item hover;
5275 struct nk_style_item active;
5276 struct nk_color border_color;
5277
5278 /* label */
5279 struct nk_color label_normal;
5280 struct nk_color label_hover;
5281 struct nk_color label_active;
5282
5283 /* symbol */
5284 struct nk_color symbol_normal;
5285 struct nk_color symbol_hover;
5286 struct nk_color symbol_active;
5287
5288 /* button */
5289 struct nk_style_button button;
5290 enum nk_symbol_type sym_normal;
5291 enum nk_symbol_type sym_hover;
5292 enum nk_symbol_type sym_active;
5293
5294 /* properties */
5295 float border;
5296 float rounding;
5297 struct nk_vec2 content_padding;
5298 struct nk_vec2 button_padding;
5299 struct nk_vec2 spacing;
5300 float color_factor;
5301 float disabled_factor;
5302};
5303
5305 /* background */
5306 struct nk_style_item background;
5307 struct nk_color border_color;
5308 struct nk_color text;
5309
5310 /* button */
5311 struct nk_style_button tab_maximize_button;
5312 struct nk_style_button tab_minimize_button;
5313 struct nk_style_button node_maximize_button;
5314 struct nk_style_button node_minimize_button;
5315 enum nk_symbol_type sym_minimize;
5316 enum nk_symbol_type sym_maximize;
5317
5318 /* properties */
5319 float border;
5320 float rounding;
5321 float indent;
5322 struct nk_vec2 padding;
5323 struct nk_vec2 spacing;
5324 float color_factor;
5325 float disabled_factor;
5326};
5327
5328enum nk_style_header_align {
5329 NK_HEADER_LEFT,
5330 NK_HEADER_RIGHT
5331};
5333 /* background */
5334 struct nk_style_item normal;
5335 struct nk_style_item hover;
5336 struct nk_style_item active;
5337
5338 /* button */
5339 struct nk_style_button close_button;
5340 struct nk_style_button minimize_button;
5341 enum nk_symbol_type close_symbol;
5342 enum nk_symbol_type minimize_symbol;
5343 enum nk_symbol_type maximize_symbol;
5344
5345 /* title */
5346 struct nk_color label_normal;
5347 struct nk_color label_hover;
5348 struct nk_color label_active;
5349
5350 /* properties */
5351 enum nk_style_header_align align;
5352 struct nk_vec2 padding;
5353 struct nk_vec2 label_padding;
5354 struct nk_vec2 spacing;
5355};
5356
5358 struct nk_style_window_header header;
5359 struct nk_style_item fixed_background;
5360 struct nk_color background;
5361
5362 struct nk_color border_color;
5363 struct nk_color popup_border_color;
5364 struct nk_color combo_border_color;
5365 struct nk_color contextual_border_color;
5366 struct nk_color menu_border_color;
5367 struct nk_color group_border_color;
5368 struct nk_color tooltip_border_color;
5369 struct nk_style_item scaler;
5370
5371 float border;
5372 float combo_border;
5373 float contextual_border;
5374 float menu_border;
5375 float group_border;
5376 float tooltip_border;
5377 float popup_border;
5378 float min_row_height_padding;
5379
5380 float rounding;
5381 struct nk_vec2 spacing;
5382 struct nk_vec2 scrollbar_size;
5383 struct nk_vec2 min_size;
5384
5385 struct nk_vec2 padding;
5386 struct nk_vec2 group_padding;
5387 struct nk_vec2 popup_padding;
5388 struct nk_vec2 combo_padding;
5389 struct nk_vec2 contextual_padding;
5390 struct nk_vec2 menu_padding;
5391 struct nk_vec2 tooltip_padding;
5392
5393 enum nk_tooltip_pos tooltip_origin;
5394 struct nk_vec2 tooltip_offset;
5395 float tooltip_delay;
5396};
5397
5398struct nk_style {
5399 const struct nk_user_font *font;
5400 const struct nk_cursor *cursors[NK_CURSOR_COUNT];
5401 const struct nk_cursor *cursor_active;
5402 struct nk_cursor *cursor_last;
5403 int cursor_visible;
5404
5405 struct nk_style_text text;
5406 struct nk_style_button button;
5407 struct nk_style_button contextual_button;
5408 struct nk_style_button menu_button;
5409 struct nk_style_toggle option;
5410 struct nk_style_toggle checkbox;
5411 struct nk_style_selectable selectable;
5412 struct nk_style_slider slider;
5413 struct nk_style_knob knob;
5414 struct nk_style_progress progress;
5415 struct nk_style_property property;
5416 struct nk_style_edit edit;
5417 struct nk_style_chart chart;
5418 struct nk_style_scrollbar scrollh;
5419 struct nk_style_scrollbar scrollv;
5420 struct nk_style_tab tab;
5421 struct nk_style_combo combo;
5422 struct nk_style_window window;
5423};
5424
5425NK_API struct nk_style_item nk_style_item_color(struct nk_color);
5426NK_API struct nk_style_item nk_style_item_image(struct nk_image img);
5427NK_API struct nk_style_item nk_style_item_nine_slice(struct nk_nine_slice slice);
5428NK_API struct nk_style_item nk_style_item_hide(void);
5429
5430/*==============================================================
5431 * PANEL
5432 * =============================================================*/
5433#ifndef NK_MAX_LAYOUT_ROW_TEMPLATE_COLUMNS
5434#define NK_MAX_LAYOUT_ROW_TEMPLATE_COLUMNS 16
5435#endif
5436#ifndef NK_CHART_MAX_SLOT
5437#define NK_CHART_MAX_SLOT 4
5438#endif
5439
5440enum nk_panel_type {
5441 NK_PANEL_NONE = 0,
5442 NK_PANEL_WINDOW = NK_FLAG(0),
5443 NK_PANEL_GROUP = NK_FLAG(1),
5444 NK_PANEL_POPUP = NK_FLAG(2),
5445 NK_PANEL_CONTEXTUAL = NK_FLAG(4),
5446 NK_PANEL_COMBO = NK_FLAG(5),
5447 NK_PANEL_MENU = NK_FLAG(6),
5448 NK_PANEL_TOOLTIP = NK_FLAG(7)
5449};
5450enum nk_panel_set {
5451 NK_PANEL_SET_NONBLOCK = NK_PANEL_CONTEXTUAL|NK_PANEL_COMBO|NK_PANEL_MENU|NK_PANEL_TOOLTIP,
5452 NK_PANEL_SET_POPUP = NK_PANEL_SET_NONBLOCK|NK_PANEL_POPUP,
5453 NK_PANEL_SET_SUB = NK_PANEL_SET_POPUP|NK_PANEL_GROUP
5454};
5455
5457 enum nk_chart_type type;
5458 struct nk_color color;
5459 struct nk_color highlight;
5460 float min, max, range;
5461 int count;
5462 struct nk_vec2 last;
5463 int index;
5464 nk_bool show_markers;
5465};
5466
5467struct nk_chart {
5468 int slot;
5469 float x, y, w, h;
5470 struct nk_chart_slot slots[NK_CHART_MAX_SLOT];
5471};
5472
5473enum nk_panel_row_layout_type {
5474 NK_LAYOUT_DYNAMIC_FIXED = 0,
5475 NK_LAYOUT_DYNAMIC_ROW,
5476 NK_LAYOUT_DYNAMIC_FREE,
5477 NK_LAYOUT_DYNAMIC,
5478 NK_LAYOUT_STATIC_FIXED,
5479 NK_LAYOUT_STATIC_ROW,
5480 NK_LAYOUT_STATIC_FREE,
5481 NK_LAYOUT_STATIC,
5482 NK_LAYOUT_TEMPLATE,
5483 NK_LAYOUT_COUNT
5484};
5486 enum nk_panel_row_layout_type type;
5487 int index;
5488 float height;
5489 float min_height;
5490 int columns;
5491 const float *ratio;
5492 float item_width;
5493 float item_height;
5494 float item_offset;
5495 float filled;
5496 struct nk_rect item;
5497 int tree_depth;
5498 float templates[NK_MAX_LAYOUT_ROW_TEMPLATE_COLUMNS];
5499};
5500
5502 nk_size begin;
5503 nk_size parent;
5504 nk_size last;
5505 nk_size end;
5506 nk_bool active;
5507};
5508
5510 float x, y, w, h;
5511 struct nk_scroll offset;
5512};
5513
5514struct nk_panel {
5515 enum nk_panel_type type;
5516 nk_flags flags;
5517 struct nk_rect bounds;
5518 nk_uint *offset_x;
5519 nk_uint *offset_y;
5520 float at_x, at_y, max_x;
5521 float footer_height;
5522 float header_height;
5523 float border;
5524 unsigned int has_scrolling;
5525 struct nk_rect clip;
5526 struct nk_menu_state menu;
5527 struct nk_row_layout row;
5528 struct nk_chart chart;
5529 struct nk_command_buffer *buffer;
5530 struct nk_panel *parent;
5531};
5532
5533/*==============================================================
5534 * WINDOW
5535 * =============================================================*/
5536#ifndef NK_WINDOW_MAX_NAME
5537#define NK_WINDOW_MAX_NAME 64
5538#endif
5539
5540struct nk_table;
5541enum nk_window_flags {
5542 NK_WINDOW_PRIVATE = NK_FLAG(11),
5543 NK_WINDOW_DYNAMIC = NK_WINDOW_PRIVATE,
5544 NK_WINDOW_ROM = NK_FLAG(12),
5545 NK_WINDOW_NOT_INTERACTIVE = NK_WINDOW_ROM|NK_WINDOW_NO_INPUT,
5546 NK_WINDOW_HIDDEN = NK_FLAG(13),
5547 NK_WINDOW_CLOSED = NK_FLAG(14),
5548 NK_WINDOW_MINIMIZED = NK_FLAG(15),
5549 NK_WINDOW_REMOVE_ROM = NK_FLAG(16)
5550};
5551
5553 struct nk_window *win;
5554 enum nk_panel_type type;
5555 struct nk_popup_buffer buf;
5556 nk_hash name;
5557 nk_bool active;
5558 unsigned combo_count;
5559 unsigned con_count, con_old;
5560 unsigned active_con;
5561 struct nk_rect header;
5562};
5563
5565 nk_hash name;
5566 unsigned int seq;
5567 unsigned int old;
5568 int active, prev;
5569 int cursor;
5570 int sel_start;
5571 int sel_end;
5572 struct nk_scroll scrollbar;
5573 unsigned char mode;
5574 unsigned char single_line;
5575};
5576
5578 int active, prev;
5579 char buffer[NK_MAX_NUMBER_BUFFER];
5580 int length;
5581 int cursor;
5582 int select_start;
5583 int select_end;
5584 nk_hash name;
5585 unsigned int seq;
5586 unsigned int old;
5587 int state;
5588 int prev_state;
5589 nk_hash prev_name;
5590 char prev_buffer[NK_MAX_NUMBER_BUFFER];
5591 int prev_length;
5592};
5593
5595 unsigned int seq;
5596 nk_hash name;
5597 char name_string[NK_WINDOW_MAX_NAME];
5598 nk_flags flags;
5599
5600 struct nk_rect bounds;
5601 struct nk_scroll scrollbar;
5602 struct nk_command_buffer buffer;
5603 struct nk_panel *layout;
5604 float scrollbar_hiding_timer;
5605
5606 /* persistent widget state */
5607 struct nk_property_state property;
5608 struct nk_popup_state popup;
5609 struct nk_edit_state edit;
5610 unsigned int scrolled;
5611 nk_bool widgets_disabled;
5612
5613 struct nk_table *tables;
5614 unsigned int table_count;
5615
5616 /* window list hooks */
5617 struct nk_window *next;
5618 struct nk_window *prev;
5619 struct nk_window *parent;
5620};
5621
5622/*==============================================================
5623 * STACK
5624 * =============================================================*/
5652#ifndef NK_BUTTON_BEHAVIOR_STACK_SIZE
5653#define NK_BUTTON_BEHAVIOR_STACK_SIZE 8
5654#endif
5655
5656#ifndef NK_FONT_STACK_SIZE
5657#define NK_FONT_STACK_SIZE 8
5658#endif
5659
5660#ifndef NK_STYLE_ITEM_STACK_SIZE
5661#define NK_STYLE_ITEM_STACK_SIZE 16
5662#endif
5663
5664#ifndef NK_FLOAT_STACK_SIZE
5665#define NK_FLOAT_STACK_SIZE 32
5666#endif
5667
5668#ifndef NK_VECTOR_STACK_SIZE
5669#define NK_VECTOR_STACK_SIZE 16
5670#endif
5671
5672#ifndef NK_FLAGS_STACK_SIZE
5673#define NK_FLAGS_STACK_SIZE 32
5674#endif
5675
5676#ifndef NK_COLOR_STACK_SIZE
5677#define NK_COLOR_STACK_SIZE 32
5678#endif
5679
5680#define NK_CONFIGURATION_STACK_TYPE(prefix, name, type)\
5681 struct nk_config_stack_##name##_element {\
5682 prefix##_##type *address;\
5683 prefix##_##type old_value;\
5684 }
5685#define NK_CONFIG_STACK(type,size)\
5686 struct nk_config_stack_##type {\
5687 int head;\
5688 struct nk_config_stack_##type##_element elements[size];\
5689 }
5690
5691#define nk_float float
5692NK_CONFIGURATION_STACK_TYPE(struct nk, style_item, style_item);
5693NK_CONFIGURATION_STACK_TYPE(nk ,float, float);
5694NK_CONFIGURATION_STACK_TYPE(struct nk, vec2, vec2);
5695NK_CONFIGURATION_STACK_TYPE(nk ,flags, flags);
5696NK_CONFIGURATION_STACK_TYPE(struct nk, color, color);
5697NK_CONFIGURATION_STACK_TYPE(const struct nk, user_font, user_font*);
5698NK_CONFIGURATION_STACK_TYPE(enum nk, button_behavior, button_behavior);
5699
5700NK_CONFIG_STACK(style_item, NK_STYLE_ITEM_STACK_SIZE);
5701NK_CONFIG_STACK(float, NK_FLOAT_STACK_SIZE);
5702NK_CONFIG_STACK(vec2, NK_VECTOR_STACK_SIZE);
5703NK_CONFIG_STACK(flags, NK_FLAGS_STACK_SIZE);
5704NK_CONFIG_STACK(color, NK_COLOR_STACK_SIZE);
5705NK_CONFIG_STACK(user_font, NK_FONT_STACK_SIZE);
5706NK_CONFIG_STACK(button_behavior, NK_BUTTON_BEHAVIOR_STACK_SIZE);
5707
5709 struct nk_config_stack_style_item style_items;
5710 struct nk_config_stack_float floats;
5711 struct nk_config_stack_vec2 vectors;
5712 struct nk_config_stack_flags flags;
5713 struct nk_config_stack_color colors;
5714 struct nk_config_stack_user_font fonts;
5715 struct nk_config_stack_button_behavior button_behaviors;
5716};
5717
5718/*==============================================================
5719 * CONTEXT
5720 * =============================================================*/
5721#define NK_VALUE_PAGE_CAPACITY \
5722 (((NK_MAX(sizeof(struct nk_window),sizeof(struct nk_panel)) / sizeof(nk_uint))) / 2)
5723
5724struct nk_table {
5725 unsigned int seq;
5726 unsigned int size;
5727 nk_hash keys[NK_VALUE_PAGE_CAPACITY];
5728 nk_uint values[NK_VALUE_PAGE_CAPACITY];
5729 struct nk_table *next, *prev;
5730};
5731
5733 struct nk_table tbl;
5734 struct nk_panel pan;
5735 struct nk_window win;
5736};
5737
5739 union nk_page_data data;
5740 struct nk_page_element *next;
5741 struct nk_page_element *prev;
5742};
5743
5744struct nk_page {
5745 unsigned int size;
5746 struct nk_page *next;
5747 struct nk_page_element win[1];
5748};
5749
5750struct nk_pool {
5751 struct nk_allocator alloc;
5752 enum nk_allocation_type type;
5753 unsigned int page_count;
5754 struct nk_page *pages;
5755 struct nk_page_element *freelist;
5756 unsigned capacity;
5757 nk_size size;
5758 nk_size cap;
5759};
5760
5762/* public: can be accessed freely */
5763 struct nk_input input;
5764 struct nk_style style;
5765 struct nk_buffer memory;
5766 struct nk_clipboard clip;
5767 nk_flags last_widget_state;
5768 enum nk_button_behavior button_behavior;
5769 struct nk_configuration_stacks stacks;
5770 float delta_time_seconds;
5771
5772/* private:
5773 should only be accessed if you
5774 know what you are doing */
5775#ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
5776 struct nk_draw_list draw_list;
5777#endif
5778#ifdef NK_INCLUDE_COMMAND_USERDATA
5779 nk_handle userdata;
5780#endif
5788
5791 int use_pool;
5792 struct nk_pool pool;
5793 struct nk_window *begin;
5794 struct nk_window *end;
5795 struct nk_window *active;
5796 struct nk_window *current;
5797 struct nk_page_element *freelist;
5798 unsigned int count;
5799 unsigned int seq;
5800};
5801
5802/* ==============================================================
5803 * MATH
5804 * =============================================================== */
5805#define NK_PI 3.141592654f
5806#define NK_PI_HALF 1.570796326f
5807#define NK_UTF_INVALID 0xFFFD
5808#define NK_MAX_FLOAT_PRECISION 2
5809
5810#define NK_UNUSED(x) ((void)(x))
5811#define NK_SATURATE(x) (NK_MAX(0, NK_MIN(1.0f, x)))
5812#define NK_LEN(a) (sizeof(a)/sizeof(a)[0])
5813#define NK_ABS(a) (((a) < 0) ? -(a) : (a))
5814#define NK_BETWEEN(x, a, b) ((a) <= (x) && (x) < (b))
5815#define NK_INBOX(px, py, x, y, w, h)\
5816 (NK_BETWEEN(px,x,x+w) && NK_BETWEEN(py,y,y+h))
5817#define NK_INTERSECT(x0, y0, w0, h0, x1, y1, w1, h1) \
5818 ((x1 < (x0 + w0)) && (x0 < (x1 + w1)) && \
5819 (y1 < (y0 + h0)) && (y0 < (y1 + h1)))
5820#define NK_CONTAINS(x, y, w, h, bx, by, bw, bh)\
5821 (NK_INBOX(x,y, bx, by, bw, bh) && NK_INBOX(x+w,y+h, bx, by, bw, bh))
5822
5823#define nk_vec2_sub(a, b) nk_vec2((a).x - (b).x, (a).y - (b).y)
5824#define nk_vec2_add(a, b) nk_vec2((a).x + (b).x, (a).y + (b).y)
5825#define nk_vec2_len_sqr(a) ((a).x*(a).x+(a).y*(a).y)
5826#define nk_vec2_muls(a, t) nk_vec2((a).x * (t), (a).y * (t))
5827
5828#define nk_ptr_add(t, p, i) ((t*)((void*)((nk_byte*)(p) + (i))))
5829#define nk_ptr_add_const(t, p, i) ((const t*)((const void*)((const nk_byte*)(p) + (i))))
5830#define nk_zero_struct(s) nk_zero(&s, sizeof(s))
5831
5832/* ==============================================================
5833 * ALIGNMENT
5834 * =============================================================== */
5835/* Pointer to Integer type conversion for pointer alignment */
5836#if defined(__PTRDIFF_TYPE__) /* This case should work for GCC*/
5837# define NK_UINT_TO_PTR(x) ((void*)(__PTRDIFF_TYPE__)(x))
5838# define NK_PTR_TO_UINT(x) ((nk_size)(__PTRDIFF_TYPE__)(x))
5839#elif !defined(__GNUC__) /* works for compilers other than LLVM */
5840# define NK_UINT_TO_PTR(x) ((void*)&((char*)0)[x])
5841# define NK_PTR_TO_UINT(x) ((nk_size)(((char*)x)-(char*)0))
5842#elif defined(NK_USE_FIXED_TYPES) /* used if we have <stdint.h> */
5843# define NK_UINT_TO_PTR(x) ((void*)(uintptr_t)(x))
5844# define NK_PTR_TO_UINT(x) ((uintptr_t)(x))
5845#else /* generates warning but works */
5846# define NK_UINT_TO_PTR(x) ((void*)(x))
5847# define NK_PTR_TO_UINT(x) ((nk_size)(x))
5848#endif
5849
5850#define NK_ALIGN_PTR(x, mask)\
5851 (NK_UINT_TO_PTR((NK_PTR_TO_UINT((nk_byte*)(x) + (mask-1)) & ~(mask-1))))
5852#define NK_ALIGN_PTR_BACK(x, mask)\
5853 (NK_UINT_TO_PTR((NK_PTR_TO_UINT((nk_byte*)(x)) & ~(mask-1))))
5854
5855#if ((defined(__GNUC__) && __GNUC__ >= 4) || defined(__clang__)) && !defined(__EMSCRIPTEN__)
5856#define NK_OFFSETOF(st,m) (__builtin_offsetof(st,m))
5857#else
5858#define NK_OFFSETOF(st,m) ((nk_ptr)&(((st*)0)->m))
5859#endif
5860
5861#ifdef __cplusplus
5862}
5863#endif
5864
5865#ifdef __cplusplus
5866template<typename T> struct nk_alignof;
5867template<typename T, int size_diff> struct nk_helper{enum {value = size_diff};};
5868template<typename T> struct nk_helper<T,0>{enum {value = nk_alignof<T>::value};};
5869template<typename T> struct nk_alignof{struct Big {T x; char c;}; enum {
5870 diff = sizeof(Big) - sizeof(T), value = nk_helper<Big, diff>::value};};
5871#define NK_ALIGNOF(t) (nk_alignof<t>::value)
5872#else
5873#define NK_ALIGNOF(t) NK_OFFSETOF(struct {char c; t _h;}, _h)
5874#endif
5875
5876#define NK_CONTAINER_OF(ptr,type,member)\
5877 (type*)((void*)((char*)(1 ? (ptr): &((type*)0)->member) - NK_OFFSETOF(type, member)))
5878
5879
5880
5881#endif /* NK_NUKLEAR_H_ */
struct nk_allocator pool
!< buffer marker to free a buffer to a certain offset
Definition nuklear.h:4234
struct nk_memory memory
!< memory management type
Definition nuklear.h:4236
enum nk_allocation_type type
!< allocator callback for dynamic buffers
Definition nuklear.h:4235
nk_size needed
!< total amount of memory allocated
Definition nuklear.h:4239
nk_size size
!< number of allocation calls
Definition nuklear.h:4241
nk_size allocated
!< growing factor for dynamic memory management
Definition nuklear.h:4238
float grow_factor
!< memory and size of the current memory block
Definition nuklear.h:4237
nk_size calls
!< totally consumed memory given that enough memory is present
Definition nuklear.h:4240
command base and header of every command inside the buffer
Definition nuklear.h:4510
int build
windows
Definition nuklear.h:5790
struct nk_text_edit text_edit
text editor objects are quite big because of an internal undo/redo stack.
Definition nuklear.h:5785
struct nk_command_buffer overlay
draw buffer used for overlay drawing operation like cursor
Definition nuklear.h:5787
enum nk_anti_aliasing shape_AA
!< line anti-aliasing flag can be turned off if you are tight on memory
Definition nuklear.h:1020
enum nk_anti_aliasing line_AA
!< global alpha value
Definition nuklear.h:1019
nk_size vertex_alignment
!< sizeof one vertex for vertex packing
Definition nuklear.h:1027
nk_size vertex_size
!< describes the vertex output format and packing
Definition nuklear.h:1026
const struct nk_draw_vertex_layout_element * vertex_layout
!< handle to texture with a white pixel for shape drawing
Definition nuklear.h:1025
unsigned arc_segment_count
!< number of segments used for circles: default to 22
Definition nuklear.h:1022
unsigned circle_segment_count
!< shape anti-aliasing flag can be turned off if you are tight on memory
Definition nuklear.h:1021
unsigned curve_segment_count
!< number of segments used for arcs: default to 22
Definition nuklear.h:1023
struct nk_draw_null_texture tex_null
!< number of segments used for curves: default to 22
Definition nuklear.h:1024
struct nk_vec2 uv
!< texture handle to a texture with a white pixel
Definition nuklear.h:1015
Basic string buffer which is only used in context with the text editor to manage and manipulate dynam...
Definition nuklear.h:4269
nk_text_width_f width
!< max height of the font
Definition nuklear.h:4052
float height
!< user provided font handle
Definition nuklear.h:4051