Nuklear
This is a minimal-state, immediate-mode graphical user interface toolkit written in ANSI C and licensed under public domain. It was designed as a simple embeddable user interface for application and does not have any dependencies, a default render backend or OS window/input handling but instead provides a highly modular, library-based approach, with simple input state for input and draw commands describing primitive shapes as output. So instead of providing a layered library that tries to abstract over a number of platform and render backends, it focuses only on the actual UI.
 
Loading...
Searching...
No Matches
nuklear.h
Go to the documentation of this file.
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_MAX
340};
341/* =============================================================================
342 *
343 * CONTEXT
344 *
345 * =============================================================================*/
381#ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
382
399NK_API nk_bool nk_init_default(struct nk_context*, const struct nk_user_font*);
400#endif
425NK_API nk_bool nk_init_fixed(struct nk_context*, void *memory, nk_size size, const struct nk_user_font*);
426
445NK_API nk_bool nk_init(struct nk_context*, const struct nk_allocator*, const struct nk_user_font*);
446
465NK_API nk_bool nk_init_custom(struct nk_context*, struct nk_buffer *cmds, struct nk_buffer *pool, const struct nk_user_font*);
466
480NK_API void nk_clear(struct nk_context*);
481
492NK_API void nk_free(struct nk_context*);
493
494#ifdef NK_INCLUDE_COMMAND_USERDATA
506NK_API void nk_set_user_data(struct nk_context*, nk_handle handle);
507#endif
508/* =============================================================================
509 *
510 * INPUT
511 *
512 * =============================================================================*/
577enum nk_keys {
578 NK_KEY_NONE,
579 NK_KEY_SHIFT,
580 NK_KEY_CTRL,
581 NK_KEY_DEL,
582 NK_KEY_ENTER,
583 NK_KEY_TAB,
584 NK_KEY_BACKSPACE,
585 NK_KEY_COPY,
586 NK_KEY_CUT,
587 NK_KEY_PASTE,
588 NK_KEY_UP,
589 NK_KEY_DOWN,
590 NK_KEY_LEFT,
591 NK_KEY_RIGHT,
592 /* Shortcuts: text field */
593 NK_KEY_TEXT_INSERT_MODE,
594 NK_KEY_TEXT_REPLACE_MODE,
595 NK_KEY_TEXT_RESET_MODE,
596 NK_KEY_TEXT_LINE_START,
597 NK_KEY_TEXT_LINE_END,
598 NK_KEY_TEXT_START,
599 NK_KEY_TEXT_END,
600 NK_KEY_TEXT_UNDO,
601 NK_KEY_TEXT_REDO,
602 NK_KEY_TEXT_SELECT_ALL,
603 NK_KEY_TEXT_WORD_LEFT,
604 NK_KEY_TEXT_WORD_RIGHT,
605 /* Shortcuts: scrollbar */
606 NK_KEY_SCROLL_START,
607 NK_KEY_SCROLL_END,
608 NK_KEY_SCROLL_DOWN,
609 NK_KEY_SCROLL_UP,
610 NK_KEY_MAX
611};
612enum nk_buttons {
613 NK_BUTTON_LEFT,
614 NK_BUTTON_MIDDLE,
615 NK_BUTTON_RIGHT,
616 NK_BUTTON_DOUBLE, /* Double click of the Left mouse button. */
617 NK_BUTTON_X1, /* Commonly used for "Back" in UI navigation. Mouse Button 4. */
618 NK_BUTTON_X2, /* Commonly used for "Forward" in UI navigation. Mouse Button 5. */
619 NK_BUTTON_MAX
620};
621
633NK_API void nk_input_begin(struct nk_context*);
634
647NK_API void nk_input_motion(struct nk_context*, int x, int y);
648
661NK_API void nk_input_key(struct nk_context*, enum nk_keys, nk_bool down);
662
677NK_API void nk_input_button(struct nk_context*, enum nk_buttons, int x, int y, nk_bool down);
678
693NK_API void nk_input_scroll(struct nk_context*, struct nk_vec2 val);
694
712NK_API void nk_input_char(struct nk_context*, char);
713
728NK_API void nk_input_glyph(struct nk_context*, const nk_glyph);
729
745NK_API void nk_input_unicode(struct nk_context*, nk_rune);
746
758NK_API void nk_input_end(struct nk_context*);
759
760/* =============================================================================
761 *
762 * DRAWING
763 *
764 * =============================================================================*/
991enum nk_anti_aliasing {NK_ANTI_ALIASING_OFF, NK_ANTI_ALIASING_ON};
992enum nk_convert_result {
993 NK_CONVERT_SUCCESS = 0,
994 NK_CONVERT_INVALID_PARAM = 1,
995 NK_CONVERT_COMMAND_BUFFER_FULL = NK_FLAG(1),
996 NK_CONVERT_VERTEX_BUFFER_FULL = NK_FLAG(2),
997 NK_CONVERT_ELEMENT_BUFFER_FULL = NK_FLAG(3)
998};
1000 nk_handle texture;
1001 struct nk_vec2 uv;
1002};
1004 float global_alpha;
1005 enum nk_anti_aliasing line_AA;
1006 enum nk_anti_aliasing shape_AA;
1011 const struct nk_draw_vertex_layout_element *vertex_layout;
1012 nk_size vertex_size;
1014};
1015
1029NK_API const struct nk_command* nk__begin(struct nk_context*);
1030
1044NK_API const struct nk_command* nk__next(struct nk_context*, const struct nk_command*);
1045
1056#define nk_foreach(c, ctx) for((c) = nk__begin(ctx); (c) != 0; (c) = nk__next(ctx,c))
1057
1058#ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
1059
1089NK_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*);
1090
1104NK_API const struct nk_draw_command* nk__draw_begin(const struct nk_context*, const struct nk_buffer*);
1105
1123NK_API const struct nk_draw_command* nk__draw_end(const struct nk_context*, const struct nk_buffer*);
1124
1142NK_API const struct nk_draw_command* nk__draw_next(const struct nk_draw_command*, const struct nk_buffer*, const struct nk_context*);
1143
1159#define nk_draw_foreach(cmd,ctx, b) for((cmd)=nk__draw_begin(ctx, b); (cmd)!=0; (cmd)=nk__draw_next(cmd, b, ctx))
1160#endif
1161
1162/* =============================================================================
1163 *
1164 * WINDOW
1165 *
1166 * =============================================================================*/
1315enum nk_panel_flags {
1316 NK_WINDOW_BORDER = NK_FLAG(0),
1317 NK_WINDOW_MOVABLE = NK_FLAG(1),
1318 NK_WINDOW_SCALABLE = NK_FLAG(2),
1319 NK_WINDOW_CLOSABLE = NK_FLAG(3),
1320 NK_WINDOW_MINIMIZABLE = NK_FLAG(4),
1321 NK_WINDOW_NO_SCROLLBAR = NK_FLAG(5),
1322 NK_WINDOW_TITLE = NK_FLAG(6),
1323 NK_WINDOW_SCROLL_AUTO_HIDE = NK_FLAG(7),
1324 NK_WINDOW_BACKGROUND = NK_FLAG(8),
1325 NK_WINDOW_SCALE_LEFT = NK_FLAG(9),
1326 NK_WINDOW_NO_INPUT = NK_FLAG(10)
1327};
1328
1349NK_API nk_bool nk_begin(struct nk_context *ctx, const char *title, struct nk_rect bounds, nk_flags flags);
1350
1372NK_API nk_bool nk_begin_titled(struct nk_context *ctx, const char *name, const char *title, struct nk_rect bounds, nk_flags flags);
1373
1388NK_API void nk_end(struct nk_context *ctx);
1389
1406NK_API struct nk_window *nk_window_find(const struct nk_context *ctx, const char *name);
1407
1425NK_API struct nk_rect nk_window_get_bounds(const struct nk_context *ctx);
1426
1444NK_API struct nk_vec2 nk_window_get_position(const struct nk_context *ctx);
1445
1463NK_API struct nk_vec2 nk_window_get_size(const struct nk_context *ctx);
1464
1481NK_API float nk_window_get_width(const struct nk_context *ctx);
1482
1500NK_API float nk_window_get_height(const struct nk_context* ctx);
1501
1521NK_API struct nk_panel* nk_window_get_panel(const struct nk_context* ctx);
1522
1543NK_API struct nk_rect nk_window_get_content_region(const struct nk_context* ctx);
1544
1565NK_API struct nk_vec2 nk_window_get_content_region_min(const struct nk_context *ctx);
1566
1587NK_API struct nk_vec2 nk_window_get_content_region_max(const struct nk_context *ctx);
1588
1608NK_API struct nk_vec2 nk_window_get_content_region_size(const struct nk_context *ctx);
1609
1629NK_API struct nk_command_buffer* nk_window_get_canvas(const struct nk_context* ctx);
1630
1648NK_API void nk_window_get_scroll(const struct nk_context *ctx, nk_uint *offset_x, nk_uint *offset_y);
1649
1666NK_API nk_bool nk_window_has_focus(const struct nk_context *ctx);
1667
1684NK_API nk_bool nk_window_is_hovered(const struct nk_context *ctx);
1685
1702NK_API nk_bool nk_window_is_collapsed(const struct nk_context *ctx, const char *name);
1703
1719NK_API nk_bool nk_window_is_closed(const struct nk_context *ctx, const char* name);
1720
1736NK_API nk_bool nk_window_is_hidden(const struct nk_context *ctx, const char* name);
1737
1752NK_API nk_bool nk_window_is_active(const struct nk_context *ctx, const char* name);
1753
1767NK_API nk_bool nk_window_is_any_hovered(const struct nk_context *ctx);
1768
1785NK_API nk_bool nk_item_is_any_active(const struct nk_context *ctx);
1786
1801NK_API void nk_window_set_bounds(struct nk_context *ctx, const char *name, struct nk_rect bounds);
1802
1817NK_API void nk_window_set_position(struct nk_context *ctx, const char *name, struct nk_vec2 pos);
1818
1833NK_API void nk_window_set_size(struct nk_context *ctx, const char *name, struct nk_vec2 size);
1834
1848NK_API void nk_window_set_focus(struct nk_context *ctx, const char *name);
1849
1867NK_API void nk_window_set_scroll(struct nk_context *ctx, nk_uint offset_x, nk_uint offset_y);
1868
1882NK_API void nk_window_close(struct nk_context *ctx, const char *name);
1883
1898NK_API void nk_window_collapse(struct nk_context *ctx, const char *name, enum nk_collapse_states state);
1899
1915NK_API void nk_window_collapse_if(struct nk_context *ctx, const char *name, enum nk_collapse_states state, int cond);
1916
1930NK_API void nk_window_show(struct nk_context *ctx, const char *name, enum nk_show_states state);
1931
1947NK_API void nk_window_show_if(struct nk_context *ctx, const char *name, enum nk_show_states state, int cond);
1948
1962NK_API void nk_rule_horizontal(struct nk_context *ctx, struct nk_color color, nk_bool rounding);
1963
1964/* =============================================================================
1965 *
1966 * LAYOUT
1967 *
1968 * =============================================================================*/
2236enum nk_widget_align {
2237 NK_WIDGET_ALIGN_LEFT = 0x01,
2238 NK_WIDGET_ALIGN_CENTERED = 0x02,
2239 NK_WIDGET_ALIGN_RIGHT = 0x04,
2240 NK_WIDGET_ALIGN_TOP = 0x08,
2241 NK_WIDGET_ALIGN_MIDDLE = 0x10,
2242 NK_WIDGET_ALIGN_BOTTOM = 0x20
2243};
2244enum nk_widget_alignment {
2245 NK_WIDGET_LEFT = NK_WIDGET_ALIGN_MIDDLE|NK_WIDGET_ALIGN_LEFT,
2246 NK_WIDGET_CENTERED = NK_WIDGET_ALIGN_MIDDLE|NK_WIDGET_ALIGN_CENTERED,
2247 NK_WIDGET_RIGHT = NK_WIDGET_ALIGN_MIDDLE|NK_WIDGET_ALIGN_RIGHT
2248};
2249
2263NK_API void nk_layout_set_min_row_height(struct nk_context*, float height);
2264
2273NK_API void nk_layout_reset_min_row_height(struct nk_context*);
2274
2287NK_API struct nk_rect nk_layout_widget_bounds(const struct nk_context *ctx);
2288
2302NK_API float nk_layout_ratio_from_pixel(const struct nk_context *ctx, float pixel_width);
2303
2318NK_API void nk_layout_row_dynamic(struct nk_context *ctx, float height, int cols);
2319
2335NK_API void nk_layout_row_static(struct nk_context *ctx, float height, int item_width, int cols);
2336
2350NK_API void nk_layout_row_begin(struct nk_context *ctx, enum nk_layout_format fmt, float row_height, int cols);
2351
2363NK_API void nk_layout_row_push(struct nk_context*, float value);
2364
2375NK_API void nk_layout_row_end(struct nk_context*);
2376
2390NK_API void nk_layout_row(struct nk_context*, enum nk_layout_format, float height, int cols, const float *ratio);
2391
2404NK_API void nk_layout_row_template_begin(struct nk_context*, float row_height);
2405
2419
2432NK_API void nk_layout_row_template_push_variable(struct nk_context*, float min_width);
2433
2446NK_API void nk_layout_row_template_push_static(struct nk_context*, float width);
2447
2459NK_API void nk_layout_row_template_end(struct nk_context*);
2460
2475NK_API void nk_layout_space_begin(struct nk_context*, enum nk_layout_format, float height, int widget_count);
2476
2489NK_API void nk_layout_space_push(struct nk_context*, struct nk_rect bounds);
2490
2502NK_API void nk_layout_space_end(struct nk_context*);
2503
2517NK_API struct nk_rect nk_layout_space_bounds(const struct nk_context *ctx);
2518
2533NK_API struct nk_vec2 nk_layout_space_to_screen(const struct nk_context* ctx, struct nk_vec2 vec);
2534
2549NK_API struct nk_vec2 nk_layout_space_to_local(const struct nk_context *ctx, struct nk_vec2 vec);
2550
2565NK_API struct nk_rect nk_layout_space_rect_to_screen(const struct nk_context *ctx, struct nk_rect bounds);
2566
2581NK_API struct nk_rect nk_layout_space_rect_to_local(const struct nk_context *ctx, struct nk_rect bounds);
2582
2595NK_API void nk_spacer(struct nk_context *ctx);
2596
2597
2598/* =============================================================================
2599 *
2600 * GROUP
2601 *
2602 * =============================================================================*/
2702NK_API nk_bool nk_group_begin(struct nk_context*, const char *title, nk_flags);
2703
2717NK_API nk_bool nk_group_begin_titled(struct nk_context*, const char *name, const char *title, nk_flags);
2718
2730NK_API void nk_group_end(struct nk_context*);
2731
2750NK_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);
2751
2769NK_API nk_bool nk_group_scrolled_begin(struct nk_context*, struct nk_scroll *off, const char *title, nk_flags);
2770
2782NK_API void nk_group_scrolled_end(struct nk_context*);
2783
2798NK_API void nk_group_get_scroll(struct nk_context*, const char *id, nk_uint *x_offset, nk_uint *y_offset);
2799
2814NK_API void nk_group_set_scroll(struct nk_context*, const char *id, nk_uint x_offset, nk_uint y_offset);
2815
2816/* =============================================================================
2817 *
2818 * TREE
2819 *
2820 * =============================================================================*/
2909#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__)
2910
2928#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)
2929
2950NK_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);
2951
2974#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__)
2975
2996#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)
2997
3019NK_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);
3020
3032NK_API void nk_tree_pop(struct nk_context*);
3033
3050NK_API nk_bool nk_tree_state_push(struct nk_context*, enum nk_tree_type, const char *title, enum nk_collapse_states *state);
3051
3069NK_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);
3070
3082NK_API void nk_tree_state_pop(struct nk_context*);
3083
3084#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__)
3085#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)
3086NK_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);
3087NK_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);
3088NK_API void nk_tree_element_pop(struct nk_context*);
3089
3090/* =============================================================================
3091 *
3092 * LIST VIEW
3093 *
3094 * ============================================================================= */
3096/* public: */
3097 int begin, end, count;
3098/* private: */
3099 int total_height;
3100 struct nk_context *ctx;
3101 nk_uint *scroll_pointer;
3102 nk_uint scroll_value;
3103};
3104NK_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);
3105NK_API void nk_list_view_end(struct nk_list_view*);
3106/* =============================================================================
3107 *
3108 * WIDGET
3109 *
3110 * ============================================================================= */
3118 NK_WIDGET_STATE_MODIFIED = NK_FLAG(1),
3119 NK_WIDGET_STATE_INACTIVE = NK_FLAG(2),
3125 NK_WIDGET_STATE_ACTIVE = NK_WIDGET_STATE_ACTIVED|NK_WIDGET_STATE_MODIFIED
3127NK_API enum nk_widget_layout_states nk_widget(struct nk_rect*, const struct nk_context*);
3128NK_API enum nk_widget_layout_states nk_widget_fitting(struct nk_rect*, const struct nk_context*, struct nk_vec2);
3129NK_API struct nk_rect nk_widget_bounds(const struct nk_context*);
3130NK_API struct nk_vec2 nk_widget_position(const struct nk_context*);
3131NK_API struct nk_vec2 nk_widget_size(const struct nk_context*);
3132NK_API float nk_widget_width(const struct nk_context*);
3133NK_API float nk_widget_height(const struct nk_context*);
3134NK_API nk_bool nk_widget_is_hovered(const struct nk_context*);
3135NK_API nk_bool nk_widget_is_mouse_clicked(const struct nk_context*, enum nk_buttons);
3136NK_API nk_bool nk_widget_has_mouse_click_down(const struct nk_context*, enum nk_buttons, nk_bool down);
3137NK_API void nk_spacing(struct nk_context*, int cols);
3138NK_API void nk_widget_disable_begin(struct nk_context* ctx);
3139NK_API void nk_widget_disable_end(struct nk_context* ctx);
3140/* =============================================================================
3141 *
3142 * TEXT
3143 *
3144 * ============================================================================= */
3145enum nk_text_align {
3146 NK_TEXT_ALIGN_LEFT = 0x01,
3147 NK_TEXT_ALIGN_CENTERED = 0x02,
3148 NK_TEXT_ALIGN_RIGHT = 0x04,
3149 NK_TEXT_ALIGN_TOP = 0x08,
3150 NK_TEXT_ALIGN_MIDDLE = 0x10,
3151 NK_TEXT_ALIGN_BOTTOM = 0x20
3152};
3153enum nk_text_alignment {
3154 NK_TEXT_LEFT = NK_TEXT_ALIGN_MIDDLE|NK_TEXT_ALIGN_LEFT,
3155 NK_TEXT_CENTERED = NK_TEXT_ALIGN_MIDDLE|NK_TEXT_ALIGN_CENTERED,
3156 NK_TEXT_RIGHT = NK_TEXT_ALIGN_MIDDLE|NK_TEXT_ALIGN_RIGHT
3157};
3158NK_API void nk_text(struct nk_context*, const char*, int, nk_flags);
3159NK_API void nk_text_colored(struct nk_context*, const char*, int, nk_flags, struct nk_color);
3160NK_API void nk_text_wrap(struct nk_context*, const char*, int);
3161NK_API void nk_text_wrap_colored(struct nk_context*, const char*, int, struct nk_color);
3162NK_API void nk_label(struct nk_context*, const char*, nk_flags align);
3163NK_API void nk_label_colored(struct nk_context*, const char*, nk_flags align, struct nk_color);
3164NK_API void nk_label_wrap(struct nk_context*, const char*);
3165NK_API void nk_label_colored_wrap(struct nk_context*, const char*, struct nk_color);
3166NK_API void nk_image(struct nk_context*, struct nk_image);
3167NK_API void nk_image_color(struct nk_context*, struct nk_image, struct nk_color);
3168#ifdef NK_INCLUDE_STANDARD_VARARGS
3169NK_API void nk_labelf(struct nk_context*, nk_flags, NK_PRINTF_FORMAT_STRING const char*, ...) NK_PRINTF_VARARG_FUNC(3);
3170NK_API void nk_labelf_colored(struct nk_context*, nk_flags, struct nk_color, NK_PRINTF_FORMAT_STRING const char*,...) NK_PRINTF_VARARG_FUNC(4);
3171NK_API void nk_labelf_wrap(struct nk_context*, NK_PRINTF_FORMAT_STRING const char*,...) NK_PRINTF_VARARG_FUNC(2);
3172NK_API void nk_labelf_colored_wrap(struct nk_context*, struct nk_color, NK_PRINTF_FORMAT_STRING const char*,...) NK_PRINTF_VARARG_FUNC(3);
3173NK_API void nk_labelfv(struct nk_context*, nk_flags, NK_PRINTF_FORMAT_STRING const char*, va_list) NK_PRINTF_VALIST_FUNC(3);
3174NK_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);
3175NK_API void nk_labelfv_wrap(struct nk_context*, NK_PRINTF_FORMAT_STRING const char*, va_list) NK_PRINTF_VALIST_FUNC(2);
3176NK_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);
3177NK_API void nk_value_bool(struct nk_context*, const char *prefix, int);
3178NK_API void nk_value_int(struct nk_context*, const char *prefix, int);
3179NK_API void nk_value_uint(struct nk_context*, const char *prefix, unsigned int);
3180NK_API void nk_value_float(struct nk_context*, const char *prefix, float);
3181NK_API void nk_value_color_byte(struct nk_context*, const char *prefix, struct nk_color);
3182NK_API void nk_value_color_float(struct nk_context*, const char *prefix, struct nk_color);
3183NK_API void nk_value_color_hex(struct nk_context*, const char *prefix, struct nk_color);
3184#endif
3185/* =============================================================================
3186 *
3187 * BUTTON
3188 *
3189 * ============================================================================= */
3190NK_API nk_bool nk_button_text(struct nk_context*, const char *title, int len);
3191NK_API nk_bool nk_button_label(struct nk_context*, const char *title);
3192NK_API nk_bool nk_button_color(struct nk_context*, struct nk_color);
3193NK_API nk_bool nk_button_symbol(struct nk_context*, enum nk_symbol_type);
3194NK_API nk_bool nk_button_image(struct nk_context*, struct nk_image img);
3195NK_API nk_bool nk_button_symbol_label(struct nk_context*, enum nk_symbol_type, const char*, nk_flags text_alignment);
3196NK_API nk_bool nk_button_symbol_text(struct nk_context*, enum nk_symbol_type, const char*, int, nk_flags alignment);
3197NK_API nk_bool nk_button_image_label(struct nk_context*, struct nk_image img, const char*, nk_flags text_alignment);
3198NK_API nk_bool nk_button_image_text(struct nk_context*, struct nk_image img, const char*, int, nk_flags alignment);
3199NK_API nk_bool nk_button_text_styled(struct nk_context*, const struct nk_style_button*, const char *title, int len);
3200NK_API nk_bool nk_button_label_styled(struct nk_context*, const struct nk_style_button*, const char *title);
3201NK_API nk_bool nk_button_symbol_styled(struct nk_context*, const struct nk_style_button*, enum nk_symbol_type);
3202NK_API nk_bool nk_button_image_styled(struct nk_context*, const struct nk_style_button*, struct nk_image img);
3203NK_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);
3204NK_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);
3205NK_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);
3206NK_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);
3207NK_API void nk_button_set_behavior(struct nk_context*, enum nk_button_behavior);
3208NK_API nk_bool nk_button_push_behavior(struct nk_context*, enum nk_button_behavior);
3209NK_API nk_bool nk_button_pop_behavior(struct nk_context*);
3210/* =============================================================================
3211 *
3212 * CHECKBOX
3213 *
3214 * ============================================================================= */
3215NK_API nk_bool nk_check_label(struct nk_context*, const char*, nk_bool active);
3216NK_API nk_bool nk_check_text(struct nk_context*, const char*, int, nk_bool active);
3217NK_API nk_bool nk_check_text_align(struct nk_context*, const char*, int, nk_bool active, nk_flags widget_alignment, nk_flags text_alignment);
3218NK_API unsigned nk_check_flags_label(struct nk_context*, const char*, unsigned int flags, unsigned int value);
3219NK_API unsigned nk_check_flags_text(struct nk_context*, const char*, int, unsigned int flags, unsigned int value);
3220NK_API nk_bool nk_checkbox_label(struct nk_context*, const char*, nk_bool *active);
3221NK_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);
3222NK_API nk_bool nk_checkbox_text(struct nk_context*, const char*, int, nk_bool *active);
3223NK_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);
3224NK_API nk_bool nk_checkbox_flags_label(struct nk_context*, const char*, unsigned int *flags, unsigned int value);
3225NK_API nk_bool nk_checkbox_flags_text(struct nk_context*, const char*, int, unsigned int *flags, unsigned int value);
3226/* =============================================================================
3227 *
3228 * RADIO BUTTON
3229 *
3230 * ============================================================================= */
3231NK_API nk_bool nk_radio_label(struct nk_context*, const char*, nk_bool *active);
3232NK_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);
3233NK_API nk_bool nk_radio_text(struct nk_context*, const char*, int, nk_bool *active);
3234NK_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);
3235NK_API nk_bool nk_option_label(struct nk_context*, const char*, nk_bool active);
3236NK_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);
3237NK_API nk_bool nk_option_text(struct nk_context*, const char*, int, nk_bool active);
3238NK_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);
3239/* =============================================================================
3240 *
3241 * SELECTABLE
3242 *
3243 * ============================================================================= */
3244NK_API nk_bool nk_selectable_label(struct nk_context*, const char*, nk_flags align, nk_bool *value);
3245NK_API nk_bool nk_selectable_text(struct nk_context*, const char*, int, nk_flags align, nk_bool *value);
3246NK_API nk_bool nk_selectable_image_label(struct nk_context*,struct nk_image, const char*, nk_flags align, nk_bool *value);
3247NK_API nk_bool nk_selectable_image_text(struct nk_context*,struct nk_image, const char*, int, nk_flags align, nk_bool *value);
3248NK_API nk_bool nk_selectable_symbol_label(struct nk_context*,enum nk_symbol_type, const char*, nk_flags align, nk_bool *value);
3249NK_API nk_bool nk_selectable_symbol_text(struct nk_context*,enum nk_symbol_type, const char*, int, nk_flags align, nk_bool *value);
3250
3251NK_API nk_bool nk_select_label(struct nk_context*, const char*, nk_flags align, nk_bool value);
3252NK_API nk_bool nk_select_text(struct nk_context*, const char*, int, nk_flags align, nk_bool value);
3253NK_API nk_bool nk_select_image_label(struct nk_context*, struct nk_image,const char*, nk_flags align, nk_bool value);
3254NK_API nk_bool nk_select_image_text(struct nk_context*, struct nk_image,const char*, int, nk_flags align, nk_bool value);
3255NK_API nk_bool nk_select_symbol_label(struct nk_context*,enum nk_symbol_type, const char*, nk_flags align, nk_bool value);
3256NK_API nk_bool nk_select_symbol_text(struct nk_context*,enum nk_symbol_type, const char*, int, nk_flags align, nk_bool value);
3257
3258/* =============================================================================
3259 *
3260 * SLIDER
3261 *
3262 * ============================================================================= */
3263NK_API float nk_slide_float(struct nk_context*, float min, float val, float max, float step);
3264NK_API int nk_slide_int(struct nk_context*, int min, int val, int max, int step);
3265NK_API nk_bool nk_slider_float(struct nk_context*, float min, float *val, float max, float step);
3266NK_API nk_bool nk_slider_int(struct nk_context*, int min, int *val, int max, int step);
3267
3268/* =============================================================================
3269 *
3270 * KNOB
3271 *
3272 * ============================================================================= */
3273NK_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);
3274NK_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);
3275
3276/* =============================================================================
3277 *
3278 * PROGRESSBAR
3279 *
3280 * ============================================================================= */
3281NK_API nk_bool nk_progress(struct nk_context*, nk_size *cur, nk_size max, nk_bool modifyable);
3282NK_API nk_size nk_prog(struct nk_context*, nk_size cur, nk_size max, nk_bool modifyable);
3283
3284/* =============================================================================
3285 *
3286 * COLOR PICKER
3287 *
3288 * ============================================================================= */
3289NK_API struct nk_colorf nk_color_picker(struct nk_context*, struct nk_colorf, enum nk_color_format);
3290NK_API nk_bool nk_color_pick(struct nk_context*, struct nk_colorf*, enum nk_color_format);
3291/* =============================================================================
3292 *
3293 * PROPERTIES
3294 *
3295 * =============================================================================*/
3390NK_API nk_bool nk_property_int(struct nk_context*, const char *name, int min, int *val, int max, int step, float inc_per_pixel);
3391
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
3440NK_API nk_bool nk_property_double(struct nk_context*, const char *name, double min, double *val, double max, double step, float inc_per_pixel);
3441
3463NK_API int nk_propertyi(struct nk_context*, const char *name, int min, int val, int max, int step, float inc_per_pixel);
3464
3486NK_API float nk_propertyf(struct nk_context*, const char *name, float min, float val, float max, float step, float inc_per_pixel);
3487
3509NK_API double nk_propertyd(struct nk_context*, const char *name, double min, double val, double max, double step, float inc_per_pixel);
3510
3511/* =============================================================================
3512 *
3513 * TEXT EDIT
3514 *
3515 * ============================================================================= */
3516enum nk_edit_flags {
3517 NK_EDIT_DEFAULT = 0,
3518 NK_EDIT_READ_ONLY = NK_FLAG(0),
3519 NK_EDIT_AUTO_SELECT = NK_FLAG(1),
3520 NK_EDIT_SIG_ENTER = NK_FLAG(2),
3521 NK_EDIT_ALLOW_TAB = NK_FLAG(3),
3522 NK_EDIT_NO_CURSOR = NK_FLAG(4),
3523 NK_EDIT_SELECTABLE = NK_FLAG(5),
3524 NK_EDIT_CLIPBOARD = NK_FLAG(6),
3525 NK_EDIT_CTRL_ENTER_NEWLINE = NK_FLAG(7),
3526 NK_EDIT_NO_HORIZONTAL_SCROLL = NK_FLAG(8),
3527 NK_EDIT_ALWAYS_INSERT_MODE = NK_FLAG(9),
3528 NK_EDIT_MULTILINE = NK_FLAG(10),
3529 NK_EDIT_GOTO_END_ON_ACTIVATE = NK_FLAG(11)
3530};
3531enum nk_edit_types {
3532 NK_EDIT_SIMPLE = NK_EDIT_ALWAYS_INSERT_MODE,
3533 NK_EDIT_FIELD = NK_EDIT_SIMPLE|NK_EDIT_SELECTABLE|NK_EDIT_CLIPBOARD,
3534 NK_EDIT_BOX = NK_EDIT_ALWAYS_INSERT_MODE| NK_EDIT_SELECTABLE| NK_EDIT_MULTILINE|NK_EDIT_ALLOW_TAB|NK_EDIT_CLIPBOARD,
3535 NK_EDIT_EDITOR = NK_EDIT_SELECTABLE|NK_EDIT_MULTILINE|NK_EDIT_ALLOW_TAB| NK_EDIT_CLIPBOARD
3536};
3538 NK_EDIT_ACTIVE = NK_FLAG(0),
3539 NK_EDIT_INACTIVE = NK_FLAG(1),
3540 NK_EDIT_ACTIVATED = NK_FLAG(2),
3541 NK_EDIT_DEACTIVATED = NK_FLAG(3),
3542 NK_EDIT_COMMITED = NK_FLAG(4)
3544NK_API nk_flags nk_edit_string(struct nk_context*, nk_flags, char *buffer, int *len, int max, nk_plugin_filter);
3545NK_API nk_flags nk_edit_string_zero_terminated(struct nk_context*, nk_flags, char *buffer, int max, nk_plugin_filter);
3546NK_API nk_flags nk_edit_buffer(struct nk_context*, nk_flags, struct nk_text_edit*, nk_plugin_filter);
3547NK_API void nk_edit_focus(struct nk_context*, nk_flags flags);
3548NK_API void nk_edit_unfocus(struct nk_context*);
3549/* =============================================================================
3550 *
3551 * CHART
3552 *
3553 * ============================================================================= */
3554NK_API nk_bool nk_chart_begin(struct nk_context*, enum nk_chart_type, int num, float min, float max);
3555NK_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);
3556NK_API void nk_chart_add_slot(struct nk_context *ctx, const enum nk_chart_type, int count, float min_value, float max_value);
3557NK_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);
3558NK_API nk_flags nk_chart_push(struct nk_context*, float);
3559NK_API nk_flags nk_chart_push_slot(struct nk_context*, float, int);
3560NK_API void nk_chart_end(struct nk_context*);
3561NK_API void nk_plot(struct nk_context*, enum nk_chart_type, const float *values, int count, int offset);
3562NK_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);
3563/* =============================================================================
3564 *
3565 * POPUP
3566 *
3567 * ============================================================================= */
3568NK_API nk_bool nk_popup_begin(struct nk_context*, enum nk_popup_type, const char*, nk_flags, struct nk_rect bounds);
3569NK_API void nk_popup_close(struct nk_context*);
3570NK_API void nk_popup_end(struct nk_context*);
3571NK_API void nk_popup_get_scroll(const struct nk_context*, nk_uint *offset_x, nk_uint *offset_y);
3572NK_API void nk_popup_set_scroll(struct nk_context*, nk_uint offset_x, nk_uint offset_y);
3573/* =============================================================================
3574 *
3575 * COMBOBOX
3576 *
3577 * ============================================================================= */
3578NK_API int nk_combo(struct nk_context*, const char *const *items, int count, int selected, int item_height, struct nk_vec2 size);
3579NK_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);
3580NK_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);
3581NK_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);
3582NK_API nk_bool nk_combobox(struct nk_context*, const char *const *items, int count, int *selected, int item_height, struct nk_vec2 size);
3583NK_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);
3584NK_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);
3585NK_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);
3586/* =============================================================================
3587 *
3588 * ABSTRACT COMBOBOX
3589 *
3590 * ============================================================================= */
3591NK_API nk_bool nk_combo_begin_text(struct nk_context*, const char *selected, int, struct nk_vec2 size);
3592NK_API nk_bool nk_combo_begin_label(struct nk_context*, const char *selected, struct nk_vec2 size);
3593NK_API nk_bool nk_combo_begin_color(struct nk_context*, struct nk_color color, struct nk_vec2 size);
3594NK_API nk_bool nk_combo_begin_symbol(struct nk_context*, enum nk_symbol_type, struct nk_vec2 size);
3595NK_API nk_bool nk_combo_begin_symbol_label(struct nk_context*, const char *selected, enum nk_symbol_type, struct nk_vec2 size);
3596NK_API nk_bool nk_combo_begin_symbol_text(struct nk_context*, const char *selected, int, enum nk_symbol_type, struct nk_vec2 size);
3597NK_API nk_bool nk_combo_begin_image(struct nk_context*, struct nk_image img, struct nk_vec2 size);
3598NK_API nk_bool nk_combo_begin_image_label(struct nk_context*, const char *selected, struct nk_image, struct nk_vec2 size);
3599NK_API nk_bool nk_combo_begin_image_text(struct nk_context*, const char *selected, int, struct nk_image, struct nk_vec2 size);
3600NK_API nk_bool nk_combo_item_label(struct nk_context*, const char*, nk_flags alignment);
3601NK_API nk_bool nk_combo_item_text(struct nk_context*, const char*,int, nk_flags alignment);
3602NK_API nk_bool nk_combo_item_image_label(struct nk_context*, struct nk_image, const char*, nk_flags alignment);
3603NK_API nk_bool nk_combo_item_image_text(struct nk_context*, struct nk_image, const char*, int,nk_flags alignment);
3604NK_API nk_bool nk_combo_item_symbol_label(struct nk_context*, enum nk_symbol_type, const char*, nk_flags alignment);
3605NK_API nk_bool nk_combo_item_symbol_text(struct nk_context*, enum nk_symbol_type, const char*, int, nk_flags alignment);
3606NK_API void nk_combo_close(struct nk_context*);
3607NK_API void nk_combo_end(struct nk_context*);
3608/* =============================================================================
3609 *
3610 * CONTEXTUAL
3611 *
3612 * ============================================================================= */
3613NK_API nk_bool nk_contextual_begin(struct nk_context*, nk_flags, struct nk_vec2, struct nk_rect trigger_bounds);
3614NK_API nk_bool nk_contextual_item_text(struct nk_context*, const char*, int,nk_flags align);
3615NK_API nk_bool nk_contextual_item_label(struct nk_context*, const char*, nk_flags align);
3616NK_API nk_bool nk_contextual_item_image_label(struct nk_context*, struct nk_image, const char*, nk_flags alignment);
3617NK_API nk_bool nk_contextual_item_image_text(struct nk_context*, struct nk_image, const char*, int len, nk_flags alignment);
3618NK_API nk_bool nk_contextual_item_symbol_label(struct nk_context*, enum nk_symbol_type, const char*, nk_flags alignment);
3619NK_API nk_bool nk_contextual_item_symbol_text(struct nk_context*, enum nk_symbol_type, const char*, int, nk_flags alignment);
3620NK_API void nk_contextual_close(struct nk_context*);
3621NK_API void nk_contextual_end(struct nk_context*);
3622/* =============================================================================
3623 *
3624 * TOOLTIP
3625 *
3626 * ============================================================================= */
3627NK_API void nk_tooltip(struct nk_context*, const char*);
3628NK_API void nk_tooltip_offset(struct nk_context *ctx, const char *text, enum nk_tooltip_pos position, struct nk_vec2 offset);
3629#ifdef NK_INCLUDE_STANDARD_VARARGS
3630NK_API void nk_tooltipf(struct nk_context*, NK_PRINTF_FORMAT_STRING const char*, ...) NK_PRINTF_VARARG_FUNC(2);
3631NK_API void nk_tooltipfv(struct nk_context*, NK_PRINTF_FORMAT_STRING const char*, va_list) NK_PRINTF_VALIST_FUNC(2);
3632NK_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);
3633NK_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);
3634#endif
3635NK_API nk_bool nk_tooltip_begin(struct nk_context*, float width);
3636NK_API nk_bool nk_tooltip_begin_offset(struct nk_context*, float, enum nk_tooltip_pos, struct nk_vec2);
3637NK_API void nk_tooltip_end(struct nk_context*);
3638/* =============================================================================
3639 *
3640 * MENU
3641 *
3642 * ============================================================================= */
3643NK_API void nk_menubar_begin(struct nk_context*);
3644NK_API void nk_menubar_end(struct nk_context*);
3645NK_API nk_bool nk_menu_begin_text(struct nk_context*, const char* title, int title_len, nk_flags align, struct nk_vec2 size);
3646NK_API nk_bool nk_menu_begin_label(struct nk_context*, const char*, nk_flags align, struct nk_vec2 size);
3647NK_API nk_bool nk_menu_begin_image(struct nk_context*, const char*, struct nk_image, struct nk_vec2 size);
3648NK_API nk_bool nk_menu_begin_image_text(struct nk_context*, const char*, int,nk_flags align,struct nk_image, struct nk_vec2 size);
3649NK_API nk_bool nk_menu_begin_image_label(struct nk_context*, const char*, nk_flags align,struct nk_image, struct nk_vec2 size);
3650NK_API nk_bool nk_menu_begin_symbol(struct nk_context*, const char*, enum nk_symbol_type, struct nk_vec2 size);
3651NK_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);
3652NK_API nk_bool nk_menu_begin_symbol_label(struct nk_context*, const char*, nk_flags align,enum nk_symbol_type, struct nk_vec2 size);
3653NK_API nk_bool nk_menu_item_text(struct nk_context*, const char*, int,nk_flags align);
3654NK_API nk_bool nk_menu_item_label(struct nk_context*, const char*, nk_flags alignment);
3655NK_API nk_bool nk_menu_item_image_label(struct nk_context*, struct nk_image, const char*, nk_flags alignment);
3656NK_API nk_bool nk_menu_item_image_text(struct nk_context*, struct nk_image, const char*, int len, nk_flags alignment);
3657NK_API nk_bool nk_menu_item_symbol_text(struct nk_context*, enum nk_symbol_type, const char*, int, nk_flags alignment);
3658NK_API nk_bool nk_menu_item_symbol_label(struct nk_context*, enum nk_symbol_type, const char*, nk_flags alignment);
3659NK_API void nk_menu_close(struct nk_context*);
3660NK_API void nk_menu_end(struct nk_context*);
3661/* =============================================================================
3662 *
3663 * STYLE
3664 *
3665 * ============================================================================= */
3666
3667#define NK_WIDGET_DISABLED_FACTOR 0.5f
3668
3669enum nk_style_colors {
3670 NK_COLOR_TEXT,
3671 NK_COLOR_WINDOW,
3672 NK_COLOR_HEADER,
3673 NK_COLOR_BORDER,
3674 NK_COLOR_BUTTON,
3675 NK_COLOR_BUTTON_HOVER,
3676 NK_COLOR_BUTTON_ACTIVE,
3677 NK_COLOR_TOGGLE,
3678 NK_COLOR_TOGGLE_HOVER,
3679 NK_COLOR_TOGGLE_CURSOR,
3680 NK_COLOR_SELECT,
3681 NK_COLOR_SELECT_ACTIVE,
3682 NK_COLOR_SLIDER,
3683 NK_COLOR_SLIDER_CURSOR,
3684 NK_COLOR_SLIDER_CURSOR_HOVER,
3685 NK_COLOR_SLIDER_CURSOR_ACTIVE,
3686 NK_COLOR_PROPERTY,
3687 NK_COLOR_EDIT,
3688 NK_COLOR_EDIT_CURSOR,
3689 NK_COLOR_COMBO,
3690 NK_COLOR_CHART,
3691 NK_COLOR_CHART_COLOR,
3692 NK_COLOR_CHART_COLOR_HIGHLIGHT,
3693 NK_COLOR_SCROLLBAR,
3694 NK_COLOR_SCROLLBAR_CURSOR,
3695 NK_COLOR_SCROLLBAR_CURSOR_HOVER,
3696 NK_COLOR_SCROLLBAR_CURSOR_ACTIVE,
3697 NK_COLOR_TAB_HEADER,
3698 NK_COLOR_KNOB,
3699 NK_COLOR_KNOB_CURSOR,
3700 NK_COLOR_KNOB_CURSOR_HOVER,
3701 NK_COLOR_KNOB_CURSOR_ACTIVE,
3702 NK_COLOR_COUNT
3703};
3704enum nk_style_cursor {
3705 NK_CURSOR_ARROW,
3706 NK_CURSOR_TEXT,
3707 NK_CURSOR_MOVE,
3708 NK_CURSOR_RESIZE_VERTICAL,
3709 NK_CURSOR_RESIZE_HORIZONTAL,
3710 NK_CURSOR_RESIZE_TOP_LEFT_DOWN_RIGHT,
3711 NK_CURSOR_RESIZE_TOP_RIGHT_DOWN_LEFT,
3712 NK_CURSOR_COUNT
3713};
3714NK_API void nk_style_default(struct nk_context*);
3715NK_API void nk_style_from_table(struct nk_context*, const struct nk_color*);
3716NK_API void nk_style_load_cursor(struct nk_context*, enum nk_style_cursor, const struct nk_cursor*);
3717NK_API void nk_style_load_all_cursors(struct nk_context*, const struct nk_cursor*);
3718NK_API const char* nk_style_get_color_by_name(enum nk_style_colors);
3719NK_API void nk_style_set_font(struct nk_context*, const struct nk_user_font*);
3720NK_API nk_bool nk_style_set_cursor(struct nk_context*, enum nk_style_cursor);
3721NK_API void nk_style_show_cursor(struct nk_context*);
3722NK_API void nk_style_hide_cursor(struct nk_context*);
3723
3724NK_API nk_bool nk_style_push_font(struct nk_context*, const struct nk_user_font*);
3725NK_API nk_bool nk_style_push_float(struct nk_context*, float*, float);
3726NK_API nk_bool nk_style_push_vec2(struct nk_context*, struct nk_vec2*, struct nk_vec2);
3727NK_API nk_bool nk_style_push_style_item(struct nk_context*, struct nk_style_item*, struct nk_style_item);
3728NK_API nk_bool nk_style_push_flags(struct nk_context*, nk_flags*, nk_flags);
3729NK_API nk_bool nk_style_push_color(struct nk_context*, struct nk_color*, struct nk_color);
3730
3731NK_API nk_bool nk_style_pop_font(struct nk_context*);
3732NK_API nk_bool nk_style_pop_float(struct nk_context*);
3733NK_API nk_bool nk_style_pop_vec2(struct nk_context*);
3734NK_API nk_bool nk_style_pop_style_item(struct nk_context*);
3735NK_API nk_bool nk_style_pop_flags(struct nk_context*);
3736NK_API nk_bool nk_style_pop_color(struct nk_context*);
3737/* =============================================================================
3738 *
3739 * COLOR
3740 *
3741 * ============================================================================= */
3742NK_API struct nk_color nk_rgb(int r, int g, int b);
3743NK_API struct nk_color nk_rgb_iv(const int *rgb);
3744NK_API struct nk_color nk_rgb_bv(const nk_byte* rgb);
3745NK_API struct nk_color nk_rgb_f(float r, float g, float b);
3746NK_API struct nk_color nk_rgb_fv(const float *rgb);
3747NK_API struct nk_color nk_rgb_cf(struct nk_colorf c);
3748NK_API struct nk_color nk_rgb_hex(const char *rgb);
3749NK_API struct nk_color nk_rgb_factor(struct nk_color col, float factor);
3750
3751NK_API struct nk_color nk_rgba(int r, int g, int b, int a);
3752NK_API struct nk_color nk_rgba_u32(nk_uint);
3753NK_API struct nk_color nk_rgba_iv(const int *rgba);
3754NK_API struct nk_color nk_rgba_bv(const nk_byte *rgba);
3755NK_API struct nk_color nk_rgba_f(float r, float g, float b, float a);
3756NK_API struct nk_color nk_rgba_fv(const float *rgba);
3757NK_API struct nk_color nk_rgba_cf(struct nk_colorf c);
3758NK_API struct nk_color nk_rgba_hex(const char *rgb);
3759
3760NK_API struct nk_colorf nk_hsva_colorf(float h, float s, float v, float a);
3761NK_API struct nk_colorf nk_hsva_colorfv(const float *c);
3762NK_API void nk_colorf_hsva_f(float *out_h, float *out_s, float *out_v, float *out_a, struct nk_colorf in);
3763NK_API void nk_colorf_hsva_fv(float *hsva, struct nk_colorf in);
3764
3765NK_API struct nk_color nk_hsv(int h, int s, int v);
3766NK_API struct nk_color nk_hsv_iv(const int *hsv);
3767NK_API struct nk_color nk_hsv_bv(const nk_byte *hsv);
3768NK_API struct nk_color nk_hsv_f(float h, float s, float v);
3769NK_API struct nk_color nk_hsv_fv(const float *hsv);
3770
3771NK_API struct nk_color nk_hsva(int h, int s, int v, int a);
3772NK_API struct nk_color nk_hsva_iv(const int *hsva);
3773NK_API struct nk_color nk_hsva_bv(const nk_byte *hsva);
3774NK_API struct nk_color nk_hsva_f(float h, float s, float v, float a);
3775NK_API struct nk_color nk_hsva_fv(const float *hsva);
3776
3777/* color (conversion nuklear --> user) */
3778NK_API void nk_color_f(float *r, float *g, float *b, float *a, struct nk_color);
3779NK_API void nk_color_fv(float *rgba_out, struct nk_color);
3780NK_API struct nk_colorf nk_color_cf(struct nk_color);
3781NK_API void nk_color_d(double *r, double *g, double *b, double *a, struct nk_color);
3782NK_API void nk_color_dv(double *rgba_out, struct nk_color);
3783
3784NK_API nk_uint nk_color_u32(struct nk_color);
3785NK_API void nk_color_hex_rgba(char *output, struct nk_color);
3786NK_API void nk_color_hex_rgb(char *output, struct nk_color);
3787
3788NK_API void nk_color_hsv_i(int *out_h, int *out_s, int *out_v, struct nk_color);
3789NK_API void nk_color_hsv_b(nk_byte *out_h, nk_byte *out_s, nk_byte *out_v, struct nk_color);
3790NK_API void nk_color_hsv_iv(int *hsv_out, struct nk_color);
3791NK_API void nk_color_hsv_bv(nk_byte *hsv_out, struct nk_color);
3792NK_API void nk_color_hsv_f(float *out_h, float *out_s, float *out_v, struct nk_color);
3793NK_API void nk_color_hsv_fv(float *hsv_out, struct nk_color);
3794
3795NK_API void nk_color_hsva_i(int *h, int *s, int *v, int *a, struct nk_color);
3796NK_API void nk_color_hsva_b(nk_byte *h, nk_byte *s, nk_byte *v, nk_byte *a, struct nk_color);
3797NK_API void nk_color_hsva_iv(int *hsva_out, struct nk_color);
3798NK_API void nk_color_hsva_bv(nk_byte *hsva_out, struct nk_color);
3799NK_API void nk_color_hsva_f(float *out_h, float *out_s, float *out_v, float *out_a, struct nk_color);
3800NK_API void nk_color_hsva_fv(float *hsva_out, struct nk_color);
3801/* =============================================================================
3802 *
3803 * IMAGE
3804 *
3805 * ============================================================================= */
3806NK_API nk_handle nk_handle_ptr(void*);
3807NK_API nk_handle nk_handle_id(int);
3808NK_API struct nk_image nk_image_handle(nk_handle);
3809NK_API struct nk_image nk_image_ptr(void*);
3810NK_API struct nk_image nk_image_id(int);
3811NK_API nk_bool nk_image_is_subimage(const struct nk_image* img);
3812NK_API struct nk_image nk_subimage_ptr(void*, nk_ushort w, nk_ushort h, struct nk_rect sub_region);
3813NK_API struct nk_image nk_subimage_id(int, nk_ushort w, nk_ushort h, struct nk_rect sub_region);
3814NK_API struct nk_image nk_subimage_handle(nk_handle, nk_ushort w, nk_ushort h, struct nk_rect sub_region);
3815/* =============================================================================
3816 *
3817 * 9-SLICE
3818 *
3819 * ============================================================================= */
3820NK_API struct nk_nine_slice nk_nine_slice_handle(nk_handle, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b);
3821NK_API struct nk_nine_slice nk_nine_slice_ptr(void*, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b);
3822NK_API struct nk_nine_slice nk_nine_slice_id(int, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b);
3823NK_API int nk_nine_slice_is_sub9slice(const struct nk_nine_slice* img);
3824NK_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);
3825NK_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);
3826NK_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);
3827/* =============================================================================
3828 *
3829 * MATH
3830 *
3831 * ============================================================================= */
3832NK_API nk_hash nk_murmur_hash(const void *key, int len, nk_hash seed);
3833NK_API void nk_triangle_from_direction(struct nk_vec2 *result, struct nk_rect r, float pad_x, float pad_y, enum nk_heading);
3834
3835NK_API struct nk_vec2 nk_vec2(float x, float y);
3836NK_API struct nk_vec2 nk_vec2i(int x, int y);
3837NK_API struct nk_vec2 nk_vec2v(const float *xy);
3838NK_API struct nk_vec2 nk_vec2iv(const int *xy);
3839
3840NK_API struct nk_rect nk_get_null_rect(void);
3841NK_API struct nk_rect nk_rect(float x, float y, float w, float h);
3842NK_API struct nk_rect nk_recti(int x, int y, int w, int h);
3843NK_API struct nk_rect nk_recta(struct nk_vec2 pos, struct nk_vec2 size);
3844NK_API struct nk_rect nk_rectv(const float *xywh);
3845NK_API struct nk_rect nk_rectiv(const int *xywh);
3846NK_API struct nk_vec2 nk_rect_pos(struct nk_rect);
3847NK_API struct nk_vec2 nk_rect_size(struct nk_rect);
3848/* =============================================================================
3849 *
3850 * STRING
3851 *
3852 * ============================================================================= */
3853NK_API int nk_strlen(const char *str);
3854NK_API int nk_stricmp(const char *s1, const char *s2);
3855NK_API int nk_stricmpn(const char *s1, const char *s2, int n);
3856NK_API int nk_strtoi(const char *str, char **endptr);
3857NK_API float nk_strtof(const char *str, char **endptr);
3858#ifndef NK_STRTOD
3859#define NK_STRTOD nk_strtod
3860#define NK_STRTOD_NEEDED
3861NK_API double nk_strtod(const char *str, char **endptr);
3862#endif
3863NK_API int nk_strfilter(const char *text, const char *regexp);
3864NK_API int nk_strmatch_fuzzy_string(char const *str, char const *pattern, int *out_score);
3865NK_API int nk_strmatch_fuzzy_text(const char *txt, int txt_len, const char *pattern, int *out_score);
3866/* =============================================================================
3867 *
3868 * UTF-8
3869 *
3870 * ============================================================================= */
3871NK_API int nk_utf_decode(const char*, nk_rune*, int);
3872NK_API int nk_utf_encode(nk_rune, char*, int);
3873NK_API int nk_utf_len(const char*, int byte_len);
3874NK_API const char* nk_utf_at(const char *buffer, int length, int index, nk_rune *unicode, int *len);
3875/* ===============================================================
3876 *
3877 * FONT
3878 *
3879 * ===============================================================*/
4032struct nk_user_font_glyph;
4033typedef float(*nk_text_width_f)(nk_handle, float h, const char*, int len);
4034typedef void(*nk_query_font_glyph_f)(nk_handle handle, float font_height,
4035 struct nk_user_font_glyph *glyph,
4036 nk_rune codepoint, nk_rune next_codepoint);
4037
4038#if defined(NK_INCLUDE_VERTEX_BUFFER_OUTPUT) || defined(NK_INCLUDE_SOFTWARE_FONT)
4039struct nk_user_font_glyph {
4040 struct nk_vec2 uv[2];
4041 struct nk_vec2 offset;
4042 float width, height;
4043 float xadvance;
4044};
4045#endif
4046
4048 nk_handle userdata;
4049 float height;
4050 nk_text_width_f width;
4051#ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
4052 nk_query_font_glyph_f query;
4053 nk_handle texture;
4054#endif
4055};
4056
4057#ifdef NK_INCLUDE_FONT_BAKING
4058enum nk_font_coord_type {
4059 NK_COORD_UV,
4060 NK_COORD_PIXEL
4061};
4062
4063struct nk_font;
4064struct nk_baked_font {
4065 float height;
4066 float ascent;
4067 float descent;
4068 nk_rune glyph_offset;
4069 nk_rune glyph_count;
4070 const nk_rune *ranges;
4071};
4072
4073struct nk_font_config {
4074 struct nk_font_config *next;
4075 void *ttf_blob;
4076 nk_size ttf_size;
4078 unsigned char ttf_data_owned_by_atlas;
4079 unsigned char merge_mode;
4080 unsigned char pixel_snap;
4081 unsigned char oversample_v, oversample_h;
4082 unsigned char padding[3];
4083
4084 float size;
4085 enum nk_font_coord_type coord_type;
4086 struct nk_vec2 spacing;
4087 const nk_rune *range;
4088 struct nk_baked_font *font;
4089 nk_rune fallback_glyph;
4090 struct nk_font_config *n;
4091 struct nk_font_config *p;
4092};
4093
4094struct nk_font_glyph {
4095 nk_rune codepoint;
4096 float xadvance;
4097 float x0, y0, x1, y1, w, h;
4098 float u0, v0, u1, v1;
4099};
4100
4101struct nk_font {
4102 struct nk_font *next;
4103 struct nk_user_font handle;
4104 struct nk_baked_font info;
4105 float scale;
4106 struct nk_font_glyph *glyphs;
4107 const struct nk_font_glyph *fallback;
4108 nk_rune fallback_codepoint;
4109 nk_handle texture;
4110 struct nk_font_config *config;
4111};
4112
4113enum nk_font_atlas_format {
4114 NK_FONT_ATLAS_ALPHA8,
4115 NK_FONT_ATLAS_RGBA32
4116};
4117
4118struct nk_font_atlas {
4119 void *pixel;
4120 int tex_width;
4121 int tex_height;
4122
4123 struct nk_allocator permanent;
4124 struct nk_allocator temporary;
4125
4126 struct nk_recti custom;
4127 struct nk_cursor cursors[NK_CURSOR_COUNT];
4128
4129 int glyph_count;
4130 struct nk_font_glyph *glyphs;
4131 struct nk_font *default_font;
4132 struct nk_font *fonts;
4133 struct nk_font_config *config;
4134 int font_num;
4135};
4136
4138NK_API const nk_rune *nk_font_default_glyph_ranges(void);
4139NK_API const nk_rune *nk_font_chinese_glyph_ranges(void);
4140NK_API const nk_rune *nk_font_cyrillic_glyph_ranges(void);
4141NK_API const nk_rune *nk_font_korean_glyph_ranges(void);
4142
4143#ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
4144NK_API void nk_font_atlas_init_default(struct nk_font_atlas*);
4145#endif
4146NK_API void nk_font_atlas_init(struct nk_font_atlas*, const struct nk_allocator*);
4147NK_API void nk_font_atlas_init_custom(struct nk_font_atlas*, const struct nk_allocator *persistent, const struct nk_allocator *transient);
4148NK_API void nk_font_atlas_begin(struct nk_font_atlas*);
4149NK_API struct nk_font_config nk_font_config(float pixel_height);
4150NK_API struct nk_font *nk_font_atlas_add(struct nk_font_atlas*, const struct nk_font_config*);
4151#ifdef NK_INCLUDE_DEFAULT_FONT
4152NK_API struct nk_font* nk_font_atlas_add_default(struct nk_font_atlas*, float height, const struct nk_font_config*);
4153#endif
4154NK_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);
4155#ifdef NK_INCLUDE_STANDARD_IO
4156NK_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*);
4157#endif
4158NK_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*);
4159NK_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);
4160NK_API const void* nk_font_atlas_bake(struct nk_font_atlas*, int *width, int *height, enum nk_font_atlas_format);
4161NK_API void nk_font_atlas_end(struct nk_font_atlas*, nk_handle tex, struct nk_draw_null_texture*);
4162NK_API const struct nk_font_glyph* nk_font_find_glyph(const struct nk_font*, nk_rune unicode);
4163NK_API void nk_font_atlas_cleanup(struct nk_font_atlas *atlas);
4164NK_API void nk_font_atlas_clear(struct nk_font_atlas*);
4165
4166#endif
4167
4168/* ==============================================================
4169 *
4170 * MEMORY BUFFER
4171 *
4172 * ===============================================================*/
4205 void *memory;
4206 unsigned int type;
4207 nk_size size;
4208 nk_size allocated;
4209 nk_size needed;
4210 nk_size calls;
4211};
4212
4213enum nk_allocation_type {
4214 NK_BUFFER_FIXED,
4215 NK_BUFFER_DYNAMIC
4216};
4217
4218enum nk_buffer_allocation_type {
4219 NK_BUFFER_FRONT,
4220 NK_BUFFER_BACK,
4221 NK_BUFFER_MAX
4222};
4223
4225 nk_bool active;
4226 nk_size offset;
4227};
4228
4229struct nk_memory {void *ptr;nk_size size;};
4231 struct nk_buffer_marker marker[NK_BUFFER_MAX];
4233 enum nk_allocation_type type;
4236 nk_size allocated;
4237 nk_size needed;
4238 nk_size calls;
4239 nk_size size;
4240};
4241
4242#ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
4243NK_API void nk_buffer_init_default(struct nk_buffer*);
4244#endif
4245NK_API void nk_buffer_init(struct nk_buffer*, const struct nk_allocator*, nk_size size);
4246NK_API void nk_buffer_init_fixed(struct nk_buffer*, void *memory, nk_size size);
4247NK_API void nk_buffer_info(struct nk_memory_status*, const struct nk_buffer*);
4248NK_API void nk_buffer_push(struct nk_buffer*, enum nk_buffer_allocation_type type, const void *memory, nk_size size, nk_size align);
4249NK_API void nk_buffer_mark(struct nk_buffer*, enum nk_buffer_allocation_type type);
4250NK_API void nk_buffer_reset(struct nk_buffer*, enum nk_buffer_allocation_type type);
4251NK_API void nk_buffer_clear(struct nk_buffer*);
4252NK_API void nk_buffer_free(struct nk_buffer*);
4253NK_API void *nk_buffer_memory(struct nk_buffer*);
4254NK_API const void *nk_buffer_memory_const(const struct nk_buffer*);
4255NK_API nk_size nk_buffer_total(const struct nk_buffer*);
4256
4257/* ==============================================================
4258 *
4259 * STRING
4260 *
4261 * ===============================================================*/
4267struct nk_str {
4268 struct nk_buffer buffer;
4269 int len;
4270};
4271
4272#ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
4273NK_API void nk_str_init_default(struct nk_str*);
4274#endif
4275NK_API void nk_str_init(struct nk_str*, const struct nk_allocator*, nk_size size);
4276NK_API void nk_str_init_fixed(struct nk_str*, void *memory, nk_size size);
4277NK_API void nk_str_clear(struct nk_str*);
4278NK_API void nk_str_free(struct nk_str*);
4279
4280NK_API int nk_str_append_text_char(struct nk_str*, const char*, int);
4281NK_API int nk_str_append_str_char(struct nk_str*, const char*);
4282NK_API int nk_str_append_text_utf8(struct nk_str*, const char*, int);
4283NK_API int nk_str_append_str_utf8(struct nk_str*, const char*);
4284NK_API int nk_str_append_text_runes(struct nk_str*, const nk_rune*, int);
4285NK_API int nk_str_append_str_runes(struct nk_str*, const nk_rune*);
4286
4287NK_API int nk_str_insert_at_char(struct nk_str*, int pos, const char*, int);
4288NK_API int nk_str_insert_at_rune(struct nk_str*, int pos, const char*, int);
4289
4290NK_API int nk_str_insert_text_char(struct nk_str*, int pos, const char*, int);
4291NK_API int nk_str_insert_str_char(struct nk_str*, int pos, const char*);
4292NK_API int nk_str_insert_text_utf8(struct nk_str*, int pos, const char*, int);
4293NK_API int nk_str_insert_str_utf8(struct nk_str*, int pos, const char*);
4294NK_API int nk_str_insert_text_runes(struct nk_str*, int pos, const nk_rune*, int);
4295NK_API int nk_str_insert_str_runes(struct nk_str*, int pos, const nk_rune*);
4296
4297NK_API void nk_str_remove_chars(struct nk_str*, int len);
4298NK_API void nk_str_remove_runes(struct nk_str *str, int len);
4299NK_API void nk_str_delete_chars(struct nk_str*, int pos, int len);
4300NK_API void nk_str_delete_runes(struct nk_str*, int pos, int len);
4301
4302NK_API char *nk_str_at_char(struct nk_str*, int pos);
4303NK_API char *nk_str_at_rune(struct nk_str*, int pos, nk_rune *unicode, int *len);
4304NK_API nk_rune nk_str_rune_at(const struct nk_str*, int pos);
4305NK_API const char *nk_str_at_char_const(const struct nk_str*, int pos);
4306NK_API const char *nk_str_at_const(const struct nk_str*, int pos, nk_rune *unicode, int *len);
4307
4308NK_API char *nk_str_get(struct nk_str*);
4309NK_API const char *nk_str_get_const(const struct nk_str*);
4310NK_API int nk_str_len(const struct nk_str*);
4311NK_API int nk_str_len_char(const struct nk_str*);
4312
4313/* ===============================================================
4314 *
4315 * TEXT EDITOR
4316 *
4317 * ===============================================================*/
4344#ifndef NK_TEXTEDIT_UNDOSTATECOUNT
4345#define NK_TEXTEDIT_UNDOSTATECOUNT 99
4346#endif
4347
4348#ifndef NK_TEXTEDIT_UNDOCHARCOUNT
4349#define NK_TEXTEDIT_UNDOCHARCOUNT 999
4350#endif
4351
4352struct nk_text_edit;
4354 nk_handle userdata;
4355 nk_plugin_paste paste;
4356 nk_plugin_copy copy;
4357};
4358
4360 int where;
4361 short insert_length;
4362 short delete_length;
4363 short char_storage;
4364};
4365
4367 struct nk_text_undo_record undo_rec[NK_TEXTEDIT_UNDOSTATECOUNT];
4368 nk_rune undo_char[NK_TEXTEDIT_UNDOCHARCOUNT];
4369 short undo_point;
4370 short redo_point;
4371 short undo_char_point;
4372 short redo_char_point;
4373};
4374
4375enum nk_text_edit_type {
4376 NK_TEXT_EDIT_SINGLE_LINE,
4377 NK_TEXT_EDIT_MULTI_LINE
4378};
4379
4380enum nk_text_edit_mode {
4381 NK_TEXT_EDIT_MODE_VIEW,
4382 NK_TEXT_EDIT_MODE_INSERT,
4383 NK_TEXT_EDIT_MODE_REPLACE
4384};
4385
4387 struct nk_clipboard clip;
4388 struct nk_str string;
4389 nk_plugin_filter filter;
4390 struct nk_vec2 scrollbar;
4391
4392 int cursor;
4393 int select_start;
4394 int select_end;
4395 unsigned char mode;
4396 unsigned char cursor_at_end_of_line;
4397 unsigned char initialized;
4398 unsigned char has_preferred_x;
4399 unsigned char single_line;
4400 unsigned char active;
4401 unsigned char padding1;
4402 float preferred_x;
4403 struct nk_text_undo_state undo;
4404};
4405
4407NK_API nk_bool nk_filter_default(const struct nk_text_edit*, nk_rune unicode);
4408NK_API nk_bool nk_filter_ascii(const struct nk_text_edit*, nk_rune unicode);
4409NK_API nk_bool nk_filter_float(const struct nk_text_edit*, nk_rune unicode);
4410NK_API nk_bool nk_filter_decimal(const struct nk_text_edit*, nk_rune unicode);
4411NK_API nk_bool nk_filter_hex(const struct nk_text_edit*, nk_rune unicode);
4412NK_API nk_bool nk_filter_oct(const struct nk_text_edit*, nk_rune unicode);
4413NK_API nk_bool nk_filter_binary(const struct nk_text_edit*, nk_rune unicode);
4414
4416#ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
4417NK_API void nk_textedit_init_default(struct nk_text_edit*);
4418#endif
4419NK_API void nk_textedit_init(struct nk_text_edit*, const struct nk_allocator*, nk_size size);
4420NK_API void nk_textedit_init_fixed(struct nk_text_edit*, void *memory, nk_size size);
4421NK_API void nk_textedit_free(struct nk_text_edit*);
4422NK_API void nk_textedit_text(struct nk_text_edit*, const char*, int total_len);
4423NK_API void nk_textedit_delete(struct nk_text_edit*, int where, int len);
4424NK_API void nk_textedit_delete_selection(struct nk_text_edit*);
4425NK_API void nk_textedit_select_all(struct nk_text_edit*);
4426NK_API nk_bool nk_textedit_cut(struct nk_text_edit*);
4427NK_API nk_bool nk_textedit_paste(struct nk_text_edit*, char const*, int len);
4428NK_API void nk_textedit_undo(struct nk_text_edit*);
4429NK_API void nk_textedit_redo(struct nk_text_edit*);
4430
4431/* ===============================================================
4432 *
4433 * DRAWING
4434 *
4435 * ===============================================================*/
4485enum nk_command_type {
4486 NK_COMMAND_NOP,
4487 NK_COMMAND_SCISSOR,
4488 NK_COMMAND_LINE,
4489 NK_COMMAND_CURVE,
4490 NK_COMMAND_RECT,
4491 NK_COMMAND_RECT_FILLED,
4492 NK_COMMAND_RECT_MULTI_COLOR,
4493 NK_COMMAND_CIRCLE,
4494 NK_COMMAND_CIRCLE_FILLED,
4495 NK_COMMAND_ARC,
4496 NK_COMMAND_ARC_FILLED,
4497 NK_COMMAND_TRIANGLE,
4498 NK_COMMAND_TRIANGLE_FILLED,
4499 NK_COMMAND_POLYGON,
4500 NK_COMMAND_POLYGON_FILLED,
4501 NK_COMMAND_POLYLINE,
4502 NK_COMMAND_TEXT,
4503 NK_COMMAND_IMAGE,
4504 NK_COMMAND_CUSTOM
4505};
4506
4509 enum nk_command_type type;
4510 nk_size next;
4511#ifdef NK_INCLUDE_COMMAND_USERDATA
4512 nk_handle userdata;
4513#endif
4514};
4515
4517 struct nk_command header;
4518 short x, y;
4519 unsigned short w, h;
4520};
4521
4523 struct nk_command header;
4524 unsigned short line_thickness;
4525 struct nk_vec2i begin;
4526 struct nk_vec2i end;
4527 struct nk_color color;
4528};
4529
4531 struct nk_command header;
4532 unsigned short line_thickness;
4533 struct nk_vec2i begin;
4534 struct nk_vec2i end;
4535 struct nk_vec2i ctrl[2];
4536 struct nk_color color;
4537};
4538
4540 struct nk_command header;
4541 unsigned short rounding;
4542 unsigned short line_thickness;
4543 short x, y;
4544 unsigned short w, h;
4545 struct nk_color color;
4546};
4547
4549 struct nk_command header;
4550 unsigned short rounding;
4551 short x, y;
4552 unsigned short w, h;
4553 struct nk_color color;
4554};
4555
4557 struct nk_command header;
4558 short x, y;
4559 unsigned short w, h;
4560 struct nk_color left;
4561 struct nk_color top;
4562 struct nk_color bottom;
4563 struct nk_color right;
4564};
4565
4567 struct nk_command header;
4568 unsigned short line_thickness;
4569 struct nk_vec2i a;
4570 struct nk_vec2i b;
4571 struct nk_vec2i c;
4572 struct nk_color color;
4573};
4574
4576 struct nk_command header;
4577 struct nk_vec2i a;
4578 struct nk_vec2i b;
4579 struct nk_vec2i c;
4580 struct nk_color color;
4581};
4582
4584 struct nk_command header;
4585 short x, y;
4586 unsigned short line_thickness;
4587 unsigned short w, h;
4588 struct nk_color color;
4589};
4590
4592 struct nk_command header;
4593 short x, y;
4594 unsigned short w, h;
4595 struct nk_color color;
4596};
4597
4599 struct nk_command header;
4600 short cx, cy;
4601 unsigned short r;
4602 unsigned short line_thickness;
4603 float a[2];
4604 struct nk_color color;
4605};
4606
4608 struct nk_command header;
4609 short cx, cy;
4610 unsigned short r;
4611 float a[2];
4612 struct nk_color color;
4613};
4614
4616 struct nk_command header;
4617 struct nk_color color;
4618 unsigned short line_thickness;
4619 unsigned short point_count;
4620 struct nk_vec2i points[1];
4621};
4622
4624 struct nk_command header;
4625 struct nk_color color;
4626 unsigned short point_count;
4627 struct nk_vec2i points[1];
4628};
4629
4631 struct nk_command header;
4632 struct nk_color color;
4633 unsigned short line_thickness;
4634 unsigned short point_count;
4635 struct nk_vec2i points[1];
4636};
4637
4639 struct nk_command header;
4640 short x, y;
4641 unsigned short w, h;
4642 struct nk_image img;
4643 struct nk_color col;
4644};
4645
4646typedef void (*nk_command_custom_callback)(void *canvas, short x,short y,
4647 unsigned short w, unsigned short h, nk_handle callback_data);
4649 struct nk_command header;
4650 short x, y;
4651 unsigned short w, h;
4652 nk_handle callback_data;
4653 nk_command_custom_callback callback;
4654};
4655
4657 struct nk_command header;
4658 const struct nk_user_font *font;
4659 struct nk_color background;
4660 struct nk_color foreground;
4661 short x, y;
4662 unsigned short w, h;
4663 float height;
4664 int length;
4665 char string[2];
4666};
4667
4668enum nk_command_clipping {
4669 NK_CLIPPING_OFF = nk_false,
4670 NK_CLIPPING_ON = nk_true
4671};
4672
4674 struct nk_buffer *base;
4675 struct nk_rect clip;
4676 int use_clipping;
4677 nk_handle userdata;
4678 nk_size begin, end, last;
4679};
4680
4682NK_API void nk_stroke_line(struct nk_command_buffer *b, float x0, float y0, float x1, float y1, float line_thickness, struct nk_color);
4683NK_API void nk_stroke_curve(struct nk_command_buffer*, float, float, float, float, float, float, float, float, float line_thickness, struct nk_color);
4684NK_API void nk_stroke_rect(struct nk_command_buffer*, struct nk_rect, float rounding, float line_thickness, struct nk_color);
4685NK_API void nk_stroke_circle(struct nk_command_buffer*, struct nk_rect, float line_thickness, struct nk_color);
4686NK_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);
4687NK_API void nk_stroke_triangle(struct nk_command_buffer*, float, float, float, float, float, float, float line_thichness, struct nk_color);
4688NK_API void nk_stroke_polyline(struct nk_command_buffer*, const float *points, int point_count, float line_thickness, struct nk_color col);
4689NK_API void nk_stroke_polygon(struct nk_command_buffer*, const float *points, int point_count, float line_thickness, struct nk_color);
4690
4692NK_API void nk_fill_rect(struct nk_command_buffer*, struct nk_rect, float rounding, struct nk_color);
4693NK_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);
4694NK_API void nk_fill_circle(struct nk_command_buffer*, struct nk_rect, struct nk_color);
4695NK_API void nk_fill_arc(struct nk_command_buffer*, float cx, float cy, float radius, float a_min, float a_max, struct nk_color);
4696NK_API void nk_fill_triangle(struct nk_command_buffer*, float x0, float y0, float x1, float y1, float x2, float y2, struct nk_color);
4697NK_API void nk_fill_polygon(struct nk_command_buffer*, const float *points, int point_count, struct nk_color);
4698
4700NK_API void nk_draw_image(struct nk_command_buffer*, struct nk_rect, const struct nk_image*, struct nk_color);
4701NK_API void nk_draw_nine_slice(struct nk_command_buffer*, struct nk_rect, const struct nk_nine_slice*, struct nk_color);
4702NK_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);
4703NK_API void nk_push_scissor(struct nk_command_buffer*, struct nk_rect);
4704NK_API void nk_push_custom(struct nk_command_buffer*, struct nk_rect, nk_command_custom_callback, nk_handle usr);
4705
4706/* ===============================================================
4707 *
4708 * INPUT
4709 *
4710 * ===============================================================*/
4712 nk_bool down;
4713 unsigned int clicked;
4714 struct nk_vec2 clicked_pos;
4715};
4716struct nk_mouse {
4717 struct nk_mouse_button buttons[NK_BUTTON_MAX];
4718 struct nk_vec2 pos;
4719#ifdef NK_BUTTON_TRIGGER_ON_RELEASE
4720 struct nk_vec2 down_pos;
4721#endif
4722 struct nk_vec2 prev;
4723 struct nk_vec2 delta;
4724 struct nk_vec2 scroll_delta;
4725 unsigned char grab;
4726 unsigned char grabbed;
4727 unsigned char ungrab;
4728};
4729
4730struct nk_key {
4731 nk_bool down;
4732 unsigned int clicked;
4733};
4735 struct nk_key keys[NK_KEY_MAX];
4736 char text[NK_INPUT_MAX];
4737 int text_len;
4738};
4739
4740struct nk_input {
4741 struct nk_keyboard keyboard;
4742 struct nk_mouse mouse;
4743};
4744
4745NK_API nk_bool nk_input_has_mouse_click(const struct nk_input*, enum nk_buttons);
4746NK_API nk_bool nk_input_has_mouse_click_in_rect(const struct nk_input*, enum nk_buttons, struct nk_rect);
4747NK_API nk_bool nk_input_has_mouse_click_in_button_rect(const struct nk_input*, enum nk_buttons, struct nk_rect);
4748NK_API nk_bool nk_input_has_mouse_click_down_in_rect(const struct nk_input*, enum nk_buttons, struct nk_rect, nk_bool down);
4749NK_API nk_bool nk_input_is_mouse_click_in_rect(const struct nk_input*, enum nk_buttons, struct nk_rect);
4750NK_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);
4751NK_API nk_bool nk_input_any_mouse_click_in_rect(const struct nk_input*, struct nk_rect);
4752NK_API nk_bool nk_input_is_mouse_prev_hovering_rect(const struct nk_input*, struct nk_rect);
4753NK_API nk_bool nk_input_is_mouse_hovering_rect(const struct nk_input*, struct nk_rect);
4754NK_API nk_bool nk_input_is_mouse_moved(const struct nk_input*);
4755NK_API nk_bool nk_input_mouse_clicked(const struct nk_input*, enum nk_buttons, struct nk_rect);
4756NK_API nk_bool nk_input_is_mouse_down(const struct nk_input*, enum nk_buttons);
4757NK_API nk_bool nk_input_is_mouse_pressed(const struct nk_input*, enum nk_buttons);
4758NK_API nk_bool nk_input_is_mouse_released(const struct nk_input*, enum nk_buttons);
4759NK_API nk_bool nk_input_is_key_pressed(const struct nk_input*, enum nk_keys);
4760NK_API nk_bool nk_input_is_key_released(const struct nk_input*, enum nk_keys);
4761NK_API nk_bool nk_input_is_key_down(const struct nk_input*, enum nk_keys);
4762
4763/* ===============================================================
4764 *
4765 * DRAW LIST
4766 *
4767 * ===============================================================*/
4768#ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
4785#ifdef NK_UINT_DRAW_INDEX
4786typedef nk_uint nk_draw_index;
4787#else
4788typedef nk_ushort nk_draw_index;
4789#endif
4790enum nk_draw_list_stroke {
4791 NK_STROKE_OPEN = nk_false, /***< build up path has no connection back to the beginning */
4792 NK_STROKE_CLOSED = nk_true /***< build up path has a connection back to the beginning */
4793};
4794
4795enum nk_draw_vertex_layout_attribute {
4796 NK_VERTEX_POSITION,
4797 NK_VERTEX_COLOR,
4798 NK_VERTEX_TEXCOORD,
4799 NK_VERTEX_ATTRIBUTE_COUNT
4800};
4801
4802enum nk_draw_vertex_layout_format {
4803 NK_FORMAT_SCHAR,
4804 NK_FORMAT_SSHORT,
4805 NK_FORMAT_SINT,
4806 NK_FORMAT_UCHAR,
4807 NK_FORMAT_USHORT,
4808 NK_FORMAT_UINT,
4809 NK_FORMAT_FLOAT,
4810 NK_FORMAT_DOUBLE,
4811
4812NK_FORMAT_COLOR_BEGIN,
4813 NK_FORMAT_R8G8B8 = NK_FORMAT_COLOR_BEGIN,
4814 NK_FORMAT_R16G15B16,
4815 NK_FORMAT_R32G32B32,
4816
4817 NK_FORMAT_R8G8B8A8,
4818 NK_FORMAT_B8G8R8A8,
4819 NK_FORMAT_R16G15B16A16,
4820 NK_FORMAT_R32G32B32A32,
4821 NK_FORMAT_R32G32B32A32_FLOAT,
4822 NK_FORMAT_R32G32B32A32_DOUBLE,
4823
4824 NK_FORMAT_RGB32,
4825 NK_FORMAT_RGBA32,
4826NK_FORMAT_COLOR_END = NK_FORMAT_RGBA32,
4827 NK_FORMAT_COUNT
4828};
4829
4830#define NK_VERTEX_LAYOUT_END NK_VERTEX_ATTRIBUTE_COUNT,NK_FORMAT_COUNT,0
4831struct nk_draw_vertex_layout_element {
4832 enum nk_draw_vertex_layout_attribute attribute;
4833 enum nk_draw_vertex_layout_format format;
4834 nk_size offset;
4835};
4836
4837struct nk_draw_command {
4838 unsigned int elem_count;
4839 struct nk_rect clip_rect;
4840 nk_handle texture;
4841#ifdef NK_INCLUDE_COMMAND_USERDATA
4842 nk_handle userdata;
4843#endif
4844};
4845
4846struct nk_draw_list {
4847 struct nk_rect clip_rect;
4848 struct nk_vec2 circle_vtx[12];
4849 struct nk_convert_config config;
4850
4851 struct nk_buffer *buffer;
4852 struct nk_buffer *vertices;
4853 struct nk_buffer *elements;
4854
4855 unsigned int element_count;
4856 unsigned int vertex_count;
4857 unsigned int cmd_count;
4858 nk_size cmd_offset;
4859
4860 unsigned int path_count;
4861 unsigned int path_offset;
4862
4863 enum nk_anti_aliasing line_AA;
4864 enum nk_anti_aliasing shape_AA;
4865
4866#ifdef NK_INCLUDE_COMMAND_USERDATA
4867 nk_handle userdata;
4868#endif
4869};
4870
4871/* draw list */
4872NK_API void nk_draw_list_init(struct nk_draw_list*);
4873NK_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);
4874
4875/* drawing */
4876#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))
4877NK_API const struct nk_draw_command* nk__draw_list_begin(const struct nk_draw_list*, const struct nk_buffer*);
4878NK_API const struct nk_draw_command* nk__draw_list_next(const struct nk_draw_command*, const struct nk_buffer*, const struct nk_draw_list*);
4879NK_API const struct nk_draw_command* nk__draw_list_end(const struct nk_draw_list*, const struct nk_buffer*);
4880
4881/* path */
4882NK_API void nk_draw_list_path_clear(struct nk_draw_list*);
4883NK_API void nk_draw_list_path_line_to(struct nk_draw_list*, struct nk_vec2 pos);
4884NK_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);
4885NK_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);
4886NK_API void nk_draw_list_path_rect_to(struct nk_draw_list*, struct nk_vec2 a, struct nk_vec2 b, float rounding);
4887NK_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);
4888NK_API void nk_draw_list_path_fill(struct nk_draw_list*, struct nk_color);
4889NK_API void nk_draw_list_path_stroke(struct nk_draw_list*, struct nk_color, enum nk_draw_list_stroke closed, float thickness);
4890
4891/* stroke */
4892NK_API void nk_draw_list_stroke_line(struct nk_draw_list*, struct nk_vec2 a, struct nk_vec2 b, struct nk_color, float thickness);
4893NK_API void nk_draw_list_stroke_rect(struct nk_draw_list*, struct nk_rect rect, struct nk_color, float rounding, float thickness);
4894NK_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);
4895NK_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);
4896NK_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);
4897NK_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);
4898
4899/* fill */
4900NK_API void nk_draw_list_fill_rect(struct nk_draw_list*, struct nk_rect rect, struct nk_color, float rounding);
4901NK_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);
4902NK_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);
4903NK_API void nk_draw_list_fill_circle(struct nk_draw_list*, struct nk_vec2 center, float radius, struct nk_color col, unsigned int segs);
4904NK_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);
4905
4906/* misc */
4907NK_API void nk_draw_list_add_image(struct nk_draw_list*, struct nk_image texture, struct nk_rect rect, struct nk_color);
4908NK_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);
4909#ifdef NK_INCLUDE_COMMAND_USERDATA
4910NK_API void nk_draw_list_push_userdata(struct nk_draw_list*, nk_handle userdata);
4911#endif
4912
4913#endif
4914
4915/* ===============================================================
4916 *
4917 * GUI
4918 *
4919 * ===============================================================*/
4920enum nk_style_item_type {
4921 NK_STYLE_ITEM_COLOR,
4922 NK_STYLE_ITEM_IMAGE,
4923 NK_STYLE_ITEM_NINE_SLICE
4924};
4925
4927 struct nk_color color;
4928 struct nk_image image;
4929 struct nk_nine_slice slice;
4930};
4931
4933 enum nk_style_item_type type;
4934 union nk_style_item_data data;
4935};
4936
4938 struct nk_color color;
4939 struct nk_vec2 padding;
4940 float color_factor;
4941 float disabled_factor;
4942};
4943
4945 /* background */
4946 struct nk_style_item normal;
4947 struct nk_style_item hover;
4948 struct nk_style_item active;
4949 struct nk_color border_color;
4950 float color_factor_background;
4951
4952 /* text */
4953 struct nk_color text_background;
4954 struct nk_color text_normal;
4955 struct nk_color text_hover;
4956 struct nk_color text_active;
4957 nk_flags text_alignment;
4958 float color_factor_text;
4959
4960 /* properties */
4961 float border;
4962 float rounding;
4963 struct nk_vec2 padding;
4964 struct nk_vec2 image_padding;
4965 struct nk_vec2 touch_padding;
4966 float disabled_factor;
4967
4968 /* optional user callbacks */
4969 nk_handle userdata;
4970 void(*draw_begin)(struct nk_command_buffer*, nk_handle userdata);
4971 void(*draw_end)(struct nk_command_buffer*, nk_handle userdata);
4972};
4973
4975 /* background */
4976 struct nk_style_item normal;
4977 struct nk_style_item hover;
4978 struct nk_style_item active;
4979 struct nk_color border_color;
4980
4981 /* cursor */
4982 struct nk_style_item cursor_normal;
4983 struct nk_style_item cursor_hover;
4984
4985 /* text */
4986 struct nk_color text_normal;
4987 struct nk_color text_hover;
4988 struct nk_color text_active;
4989 struct nk_color text_background;
4990 nk_flags text_alignment;
4991
4992 /* properties */
4993 struct nk_vec2 padding;
4994 struct nk_vec2 touch_padding;
4995 float spacing;
4996 float border;
4997 float color_factor;
4998 float disabled_factor;
4999
5000 /* optional user callbacks */
5001 nk_handle userdata;
5002 void(*draw_begin)(struct nk_command_buffer*, nk_handle);
5003 void(*draw_end)(struct nk_command_buffer*, nk_handle);
5004};
5005
5007 /* background (inactive) */
5008 struct nk_style_item normal;
5009 struct nk_style_item hover;
5010 struct nk_style_item pressed;
5011
5012 /* background (active) */
5013 struct nk_style_item normal_active;
5014 struct nk_style_item hover_active;
5015 struct nk_style_item pressed_active;
5016
5017 /* text color (inactive) */
5018 struct nk_color text_normal;
5019 struct nk_color text_hover;
5020 struct nk_color text_pressed;
5021
5022 /* text color (active) */
5023 struct nk_color text_normal_active;
5024 struct nk_color text_hover_active;
5025 struct nk_color text_pressed_active;
5026 struct nk_color text_background;
5027 nk_flags text_alignment;
5028
5029 /* properties */
5030 float rounding;
5031 struct nk_vec2 padding;
5032 struct nk_vec2 touch_padding;
5033 struct nk_vec2 image_padding;
5034 float color_factor;
5035 float disabled_factor;
5036
5037 /* optional user callbacks */
5038 nk_handle userdata;
5039 void(*draw_begin)(struct nk_command_buffer*, nk_handle);
5040 void(*draw_end)(struct nk_command_buffer*, nk_handle);
5041};
5042
5044 /* background */
5045 struct nk_style_item normal;
5046 struct nk_style_item hover;
5047 struct nk_style_item active;
5048 struct nk_color border_color;
5049
5050 /* background bar */
5051 struct nk_color bar_normal;
5052 struct nk_color bar_hover;
5053 struct nk_color bar_active;
5054 struct nk_color bar_filled;
5055
5056 /* cursor */
5057 struct nk_style_item cursor_normal;
5058 struct nk_style_item cursor_hover;
5059 struct nk_style_item cursor_active;
5060
5061 /* properties */
5062 float border;
5063 float rounding;
5064 float bar_height;
5065 struct nk_vec2 padding;
5066 struct nk_vec2 spacing;
5067 struct nk_vec2 cursor_size;
5068 float color_factor;
5069 float disabled_factor;
5070
5071 /* optional buttons */
5072 int show_buttons;
5073 struct nk_style_button inc_button;
5074 struct nk_style_button dec_button;
5075 enum nk_symbol_type inc_symbol;
5076 enum nk_symbol_type dec_symbol;
5077
5078 /* optional user callbacks */
5079 nk_handle userdata;
5080 void(*draw_begin)(struct nk_command_buffer*, nk_handle);
5081 void(*draw_end)(struct nk_command_buffer*, nk_handle);
5082};
5083
5085 /* background */
5086 struct nk_style_item normal;
5087 struct nk_style_item hover;
5088 struct nk_style_item active;
5089 struct nk_color border_color;
5090
5091 /* knob */
5092 struct nk_color knob_normal;
5093 struct nk_color knob_hover;
5094 struct nk_color knob_active;
5095 struct nk_color knob_border_color;
5096
5097 /* cursor */
5098 struct nk_color cursor_normal;
5099 struct nk_color cursor_hover;
5100 struct nk_color cursor_active;
5101
5102 /* properties */
5103 float border;
5104 float knob_border;
5105 struct nk_vec2 padding;
5106 struct nk_vec2 spacing;
5107 float cursor_width;
5108 float color_factor;
5109 float disabled_factor;
5110
5111 /* optional user callbacks */
5112 nk_handle userdata;
5113 void(*draw_begin)(struct nk_command_buffer*, nk_handle);
5114 void(*draw_end)(struct nk_command_buffer*, nk_handle);
5115};
5116
5118 /* background */
5119 struct nk_style_item normal;
5120 struct nk_style_item hover;
5121 struct nk_style_item active;
5122 struct nk_color border_color;
5123
5124 /* cursor */
5125 struct nk_style_item cursor_normal;
5126 struct nk_style_item cursor_hover;
5127 struct nk_style_item cursor_active;
5128 struct nk_color cursor_border_color;
5129
5130 /* properties */
5131 float rounding;
5132 float border;
5133 float cursor_border;
5134 float cursor_rounding;
5135 struct nk_vec2 padding;
5136 float color_factor;
5137 float disabled_factor;
5138
5139 /* optional user callbacks */
5140 nk_handle userdata;
5141 void(*draw_begin)(struct nk_command_buffer*, nk_handle);
5142 void(*draw_end)(struct nk_command_buffer*, nk_handle);
5143};
5144
5146 /* background */
5147 struct nk_style_item normal;
5148 struct nk_style_item hover;
5149 struct nk_style_item active;
5150 struct nk_color border_color;
5151
5152 /* cursor */
5153 struct nk_style_item cursor_normal;
5154 struct nk_style_item cursor_hover;
5155 struct nk_style_item cursor_active;
5156 struct nk_color cursor_border_color;
5157
5158 /* properties */
5159 float border;
5160 float rounding;
5161 float border_cursor;
5162 float rounding_cursor;
5163 struct nk_vec2 padding;
5164 float color_factor;
5165 float disabled_factor;
5166
5167 /* optional buttons */
5168 int show_buttons;
5169 struct nk_style_button inc_button;
5170 struct nk_style_button dec_button;
5171 enum nk_symbol_type inc_symbol;
5172 enum nk_symbol_type dec_symbol;
5173
5174 /* optional user callbacks */
5175 nk_handle userdata;
5176 void(*draw_begin)(struct nk_command_buffer*, nk_handle);
5177 void(*draw_end)(struct nk_command_buffer*, nk_handle);
5178};
5179
5181 /* background */
5182 struct nk_style_item normal;
5183 struct nk_style_item hover;
5184 struct nk_style_item active;
5185 struct nk_color border_color;
5186 struct nk_style_scrollbar scrollbar;
5187
5188 /* cursor */
5189 struct nk_color cursor_normal;
5190 struct nk_color cursor_hover;
5191 struct nk_color cursor_text_normal;
5192 struct nk_color cursor_text_hover;
5193
5194 /* text (unselected) */
5195 struct nk_color text_normal;
5196 struct nk_color text_hover;
5197 struct nk_color text_active;
5198
5199 /* text (selected) */
5200 struct nk_color selected_normal;
5201 struct nk_color selected_hover;
5202 struct nk_color selected_text_normal;
5203 struct nk_color selected_text_hover;
5204
5205 /* properties */
5206 float border;
5207 float rounding;
5208 float cursor_size;
5209 struct nk_vec2 scrollbar_size;
5210 struct nk_vec2 padding;
5211 float row_padding;
5212 float color_factor;
5213 float disabled_factor;
5214};
5215
5217 /* background */
5218 struct nk_style_item normal;
5219 struct nk_style_item hover;
5220 struct nk_style_item active;
5221 struct nk_color border_color;
5222
5223 /* text */
5224 struct nk_color label_normal;
5225 struct nk_color label_hover;
5226 struct nk_color label_active;
5227
5228 /* symbols */
5229 enum nk_symbol_type sym_left;
5230 enum nk_symbol_type sym_right;
5231
5232 /* properties */
5233 float border;
5234 float rounding;
5235 struct nk_vec2 padding;
5236 float color_factor;
5237 float disabled_factor;
5238
5239 struct nk_style_edit edit;
5240 struct nk_style_button inc_button;
5241 struct nk_style_button dec_button;
5242
5243 /* optional user callbacks */
5244 nk_handle userdata;
5245 void(*draw_begin)(struct nk_command_buffer*, nk_handle);
5246 void(*draw_end)(struct nk_command_buffer*, nk_handle);
5247};
5248
5250 /* colors */
5251 struct nk_style_item background;
5252 struct nk_color border_color;
5253 struct nk_color selected_color;
5254 struct nk_color color;
5255
5256 /* properties */
5257 float border;
5258 float rounding;
5259 struct nk_vec2 padding;
5260 float color_factor;
5261 float disabled_factor;
5262 nk_bool show_markers;
5263};
5264
5266 /* background */
5267 struct nk_style_item normal;
5268 struct nk_style_item hover;
5269 struct nk_style_item active;
5270 struct nk_color border_color;
5271
5272 /* label */
5273 struct nk_color label_normal;
5274 struct nk_color label_hover;
5275 struct nk_color label_active;
5276
5277 /* symbol */
5278 struct nk_color symbol_normal;
5279 struct nk_color symbol_hover;
5280 struct nk_color symbol_active;
5281
5282 /* button */
5283 struct nk_style_button button;
5284 enum nk_symbol_type sym_normal;
5285 enum nk_symbol_type sym_hover;
5286 enum nk_symbol_type sym_active;
5287
5288 /* properties */
5289 float border;
5290 float rounding;
5291 struct nk_vec2 content_padding;
5292 struct nk_vec2 button_padding;
5293 struct nk_vec2 spacing;
5294 float color_factor;
5295 float disabled_factor;
5296};
5297
5299 /* background */
5300 struct nk_style_item background;
5301 struct nk_color border_color;
5302 struct nk_color text;
5303
5304 /* button */
5305 struct nk_style_button tab_maximize_button;
5306 struct nk_style_button tab_minimize_button;
5307 struct nk_style_button node_maximize_button;
5308 struct nk_style_button node_minimize_button;
5309 enum nk_symbol_type sym_minimize;
5310 enum nk_symbol_type sym_maximize;
5311
5312 /* properties */
5313 float border;
5314 float rounding;
5315 float indent;
5316 struct nk_vec2 padding;
5317 struct nk_vec2 spacing;
5318 float color_factor;
5319 float disabled_factor;
5320};
5321
5322enum nk_style_header_align {
5323 NK_HEADER_LEFT,
5324 NK_HEADER_RIGHT
5325};
5327 /* background */
5328 struct nk_style_item normal;
5329 struct nk_style_item hover;
5330 struct nk_style_item active;
5331
5332 /* button */
5333 struct nk_style_button close_button;
5334 struct nk_style_button minimize_button;
5335 enum nk_symbol_type close_symbol;
5336 enum nk_symbol_type minimize_symbol;
5337 enum nk_symbol_type maximize_symbol;
5338
5339 /* title */
5340 struct nk_color label_normal;
5341 struct nk_color label_hover;
5342 struct nk_color label_active;
5343
5344 /* properties */
5345 enum nk_style_header_align align;
5346 struct nk_vec2 padding;
5347 struct nk_vec2 label_padding;
5348 struct nk_vec2 spacing;
5349};
5350
5352 struct nk_style_window_header header;
5353 struct nk_style_item fixed_background;
5354 struct nk_color background;
5355
5356 struct nk_color border_color;
5357 struct nk_color popup_border_color;
5358 struct nk_color combo_border_color;
5359 struct nk_color contextual_border_color;
5360 struct nk_color menu_border_color;
5361 struct nk_color group_border_color;
5362 struct nk_color tooltip_border_color;
5363 struct nk_style_item scaler;
5364
5365 float border;
5366 float combo_border;
5367 float contextual_border;
5368 float menu_border;
5369 float group_border;
5370 float tooltip_border;
5371 float popup_border;
5372 float min_row_height_padding;
5373
5374 float rounding;
5375 struct nk_vec2 spacing;
5376 struct nk_vec2 scrollbar_size;
5377 struct nk_vec2 min_size;
5378
5379 struct nk_vec2 padding;
5380 struct nk_vec2 group_padding;
5381 struct nk_vec2 popup_padding;
5382 struct nk_vec2 combo_padding;
5383 struct nk_vec2 contextual_padding;
5384 struct nk_vec2 menu_padding;
5385 struct nk_vec2 tooltip_padding;
5386
5387 enum nk_tooltip_pos tooltip_origin;
5388 struct nk_vec2 tooltip_offset;
5389};
5390
5391struct nk_style {
5392 const struct nk_user_font *font;
5393 const struct nk_cursor *cursors[NK_CURSOR_COUNT];
5394 const struct nk_cursor *cursor_active;
5395 struct nk_cursor *cursor_last;
5396 int cursor_visible;
5397
5398 struct nk_style_text text;
5399 struct nk_style_button button;
5400 struct nk_style_button contextual_button;
5401 struct nk_style_button menu_button;
5402 struct nk_style_toggle option;
5403 struct nk_style_toggle checkbox;
5404 struct nk_style_selectable selectable;
5405 struct nk_style_slider slider;
5406 struct nk_style_knob knob;
5407 struct nk_style_progress progress;
5408 struct nk_style_property property;
5409 struct nk_style_edit edit;
5410 struct nk_style_chart chart;
5411 struct nk_style_scrollbar scrollh;
5412 struct nk_style_scrollbar scrollv;
5413 struct nk_style_tab tab;
5414 struct nk_style_combo combo;
5415 struct nk_style_window window;
5416};
5417
5418NK_API struct nk_style_item nk_style_item_color(struct nk_color);
5419NK_API struct nk_style_item nk_style_item_image(struct nk_image img);
5420NK_API struct nk_style_item nk_style_item_nine_slice(struct nk_nine_slice slice);
5421NK_API struct nk_style_item nk_style_item_hide(void);
5422
5423/*==============================================================
5424 * PANEL
5425 * =============================================================*/
5426#ifndef NK_MAX_LAYOUT_ROW_TEMPLATE_COLUMNS
5427#define NK_MAX_LAYOUT_ROW_TEMPLATE_COLUMNS 16
5428#endif
5429#ifndef NK_CHART_MAX_SLOT
5430#define NK_CHART_MAX_SLOT 4
5431#endif
5432
5433enum nk_panel_type {
5434 NK_PANEL_NONE = 0,
5435 NK_PANEL_WINDOW = NK_FLAG(0),
5436 NK_PANEL_GROUP = NK_FLAG(1),
5437 NK_PANEL_POPUP = NK_FLAG(2),
5438 NK_PANEL_CONTEXTUAL = NK_FLAG(4),
5439 NK_PANEL_COMBO = NK_FLAG(5),
5440 NK_PANEL_MENU = NK_FLAG(6),
5441 NK_PANEL_TOOLTIP = NK_FLAG(7)
5442};
5443enum nk_panel_set {
5444 NK_PANEL_SET_NONBLOCK = NK_PANEL_CONTEXTUAL|NK_PANEL_COMBO|NK_PANEL_MENU|NK_PANEL_TOOLTIP,
5445 NK_PANEL_SET_POPUP = NK_PANEL_SET_NONBLOCK|NK_PANEL_POPUP,
5446 NK_PANEL_SET_SUB = NK_PANEL_SET_POPUP|NK_PANEL_GROUP
5447};
5448
5450 enum nk_chart_type type;
5451 struct nk_color color;
5452 struct nk_color highlight;
5453 float min, max, range;
5454 int count;
5455 struct nk_vec2 last;
5456 int index;
5457 nk_bool show_markers;
5458};
5459
5460struct nk_chart {
5461 int slot;
5462 float x, y, w, h;
5463 struct nk_chart_slot slots[NK_CHART_MAX_SLOT];
5464};
5465
5466enum nk_panel_row_layout_type {
5467 NK_LAYOUT_DYNAMIC_FIXED = 0,
5468 NK_LAYOUT_DYNAMIC_ROW,
5469 NK_LAYOUT_DYNAMIC_FREE,
5470 NK_LAYOUT_DYNAMIC,
5471 NK_LAYOUT_STATIC_FIXED,
5472 NK_LAYOUT_STATIC_ROW,
5473 NK_LAYOUT_STATIC_FREE,
5474 NK_LAYOUT_STATIC,
5475 NK_LAYOUT_TEMPLATE,
5476 NK_LAYOUT_COUNT
5477};
5479 enum nk_panel_row_layout_type type;
5480 int index;
5481 float height;
5482 float min_height;
5483 int columns;
5484 const float *ratio;
5485 float item_width;
5486 float item_height;
5487 float item_offset;
5488 float filled;
5489 struct nk_rect item;
5490 int tree_depth;
5491 float templates[NK_MAX_LAYOUT_ROW_TEMPLATE_COLUMNS];
5492};
5493
5495 nk_size begin;
5496 nk_size parent;
5497 nk_size last;
5498 nk_size end;
5499 nk_bool active;
5500};
5501
5503 float x, y, w, h;
5504 struct nk_scroll offset;
5505};
5506
5507struct nk_panel {
5508 enum nk_panel_type type;
5509 nk_flags flags;
5510 struct nk_rect bounds;
5511 nk_uint *offset_x;
5512 nk_uint *offset_y;
5513 float at_x, at_y, max_x;
5514 float footer_height;
5515 float header_height;
5516 float border;
5517 unsigned int has_scrolling;
5518 struct nk_rect clip;
5519 struct nk_menu_state menu;
5520 struct nk_row_layout row;
5521 struct nk_chart chart;
5522 struct nk_command_buffer *buffer;
5523 struct nk_panel *parent;
5524};
5525
5526/*==============================================================
5527 * WINDOW
5528 * =============================================================*/
5529#ifndef NK_WINDOW_MAX_NAME
5530#define NK_WINDOW_MAX_NAME 64
5531#endif
5532
5533struct nk_table;
5535 NK_WINDOW_PRIVATE = NK_FLAG(11),
5536 NK_WINDOW_DYNAMIC = NK_WINDOW_PRIVATE,
5537 NK_WINDOW_ROM = NK_FLAG(12),
5539 NK_WINDOW_HIDDEN = NK_FLAG(13),
5540 NK_WINDOW_CLOSED = NK_FLAG(14),
5541 NK_WINDOW_MINIMIZED = NK_FLAG(15),
5542 NK_WINDOW_REMOVE_ROM = NK_FLAG(16)
5544
5546 struct nk_window *win;
5547 enum nk_panel_type type;
5548 struct nk_popup_buffer buf;
5549 nk_hash name;
5550 nk_bool active;
5551 unsigned combo_count;
5552 unsigned con_count, con_old;
5553 unsigned active_con;
5554 struct nk_rect header;
5555};
5556
5558 nk_hash name;
5559 unsigned int seq;
5560 unsigned int old;
5561 int active, prev;
5562 int cursor;
5563 int sel_start;
5564 int sel_end;
5565 struct nk_scroll scrollbar;
5566 unsigned char mode;
5567 unsigned char single_line;
5568};
5569
5571 int active, prev;
5572 char buffer[NK_MAX_NUMBER_BUFFER];
5573 int length;
5574 int cursor;
5575 int select_start;
5576 int select_end;
5577 nk_hash name;
5578 unsigned int seq;
5579 unsigned int old;
5580 int state;
5581 int prev_state;
5582 nk_hash prev_name;
5583 char prev_buffer[NK_MAX_NUMBER_BUFFER];
5584 int prev_length;
5585};
5586
5588 unsigned int seq;
5589 nk_hash name;
5590 char name_string[NK_WINDOW_MAX_NAME];
5591 nk_flags flags;
5592
5593 struct nk_rect bounds;
5594 struct nk_scroll scrollbar;
5595 struct nk_command_buffer buffer;
5596 struct nk_panel *layout;
5597 float scrollbar_hiding_timer;
5598
5599 /* persistent widget state */
5600 struct nk_property_state property;
5601 struct nk_popup_state popup;
5602 struct nk_edit_state edit;
5603 unsigned int scrolled;
5604 nk_bool widgets_disabled;
5605
5606 struct nk_table *tables;
5607 unsigned int table_count;
5608
5609 /* window list hooks */
5610 struct nk_window *next;
5611 struct nk_window *prev;
5612 struct nk_window *parent;
5613};
5614
5615/*==============================================================
5616 * STACK
5617 * =============================================================*/
5643#ifndef NK_BUTTON_BEHAVIOR_STACK_SIZE
5644#define NK_BUTTON_BEHAVIOR_STACK_SIZE 8
5645#endif
5646
5647#ifndef NK_FONT_STACK_SIZE
5648#define NK_FONT_STACK_SIZE 8
5649#endif
5650
5651#ifndef NK_STYLE_ITEM_STACK_SIZE
5652#define NK_STYLE_ITEM_STACK_SIZE 16
5653#endif
5654
5655#ifndef NK_FLOAT_STACK_SIZE
5656#define NK_FLOAT_STACK_SIZE 32
5657#endif
5658
5659#ifndef NK_VECTOR_STACK_SIZE
5660#define NK_VECTOR_STACK_SIZE 16
5661#endif
5662
5663#ifndef NK_FLAGS_STACK_SIZE
5664#define NK_FLAGS_STACK_SIZE 32
5665#endif
5666
5667#ifndef NK_COLOR_STACK_SIZE
5668#define NK_COLOR_STACK_SIZE 32
5669#endif
5670
5671#define NK_CONFIGURATION_STACK_TYPE(prefix, name, type)\
5672 struct nk_config_stack_##name##_element {\
5673 prefix##_##type *address;\
5674 prefix##_##type old_value;\
5675 }
5676#define NK_CONFIG_STACK(type,size)\
5677 struct nk_config_stack_##type {\
5678 int head;\
5679 struct nk_config_stack_##type##_element elements[size];\
5680 }
5681
5682#define nk_float float
5683NK_CONFIGURATION_STACK_TYPE(struct nk, style_item, style_item);
5684NK_CONFIGURATION_STACK_TYPE(nk ,float, float);
5685NK_CONFIGURATION_STACK_TYPE(struct nk, vec2, vec2);
5686NK_CONFIGURATION_STACK_TYPE(nk ,flags, flags);
5687NK_CONFIGURATION_STACK_TYPE(struct nk, color, color);
5688NK_CONFIGURATION_STACK_TYPE(const struct nk, user_font, user_font*);
5689NK_CONFIGURATION_STACK_TYPE(enum nk, button_behavior, button_behavior);
5690
5691NK_CONFIG_STACK(style_item, NK_STYLE_ITEM_STACK_SIZE);
5692NK_CONFIG_STACK(float, NK_FLOAT_STACK_SIZE);
5693NK_CONFIG_STACK(vec2, NK_VECTOR_STACK_SIZE);
5694NK_CONFIG_STACK(flags, NK_FLAGS_STACK_SIZE);
5695NK_CONFIG_STACK(color, NK_COLOR_STACK_SIZE);
5696NK_CONFIG_STACK(user_font, NK_FONT_STACK_SIZE);
5697NK_CONFIG_STACK(button_behavior, NK_BUTTON_BEHAVIOR_STACK_SIZE);
5698
5700 struct nk_config_stack_style_item style_items;
5701 struct nk_config_stack_float floats;
5702 struct nk_config_stack_vec2 vectors;
5703 struct nk_config_stack_flags flags;
5704 struct nk_config_stack_color colors;
5705 struct nk_config_stack_user_font fonts;
5706 struct nk_config_stack_button_behavior button_behaviors;
5707};
5708
5709/*==============================================================
5710 * CONTEXT
5711 * =============================================================*/
5712#define NK_VALUE_PAGE_CAPACITY \
5713 (((NK_MAX(sizeof(struct nk_window),sizeof(struct nk_panel)) / sizeof(nk_uint))) / 2)
5714
5715struct nk_table {
5716 unsigned int seq;
5717 unsigned int size;
5718 nk_hash keys[NK_VALUE_PAGE_CAPACITY];
5719 nk_uint values[NK_VALUE_PAGE_CAPACITY];
5720 struct nk_table *next, *prev;
5721};
5722
5724 struct nk_table tbl;
5725 struct nk_panel pan;
5726 struct nk_window win;
5727};
5728
5730 union nk_page_data data;
5731 struct nk_page_element *next;
5732 struct nk_page_element *prev;
5733};
5734
5735struct nk_page {
5736 unsigned int size;
5737 struct nk_page *next;
5738 struct nk_page_element win[1];
5739};
5740
5741struct nk_pool {
5742 struct nk_allocator alloc;
5743 enum nk_allocation_type type;
5744 unsigned int page_count;
5745 struct nk_page *pages;
5746 struct nk_page_element *freelist;
5747 unsigned capacity;
5748 nk_size size;
5749 nk_size cap;
5750};
5751
5753/* public: can be accessed freely */
5754 struct nk_input input;
5755 struct nk_style style;
5756 struct nk_buffer memory;
5757 struct nk_clipboard clip;
5758 nk_flags last_widget_state;
5759 enum nk_button_behavior button_behavior;
5760 struct nk_configuration_stacks stacks;
5761 float delta_time_seconds;
5762
5763/* private:
5764 should only be accessed if you
5765 know what you are doing */
5766#ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
5767 struct nk_draw_list draw_list;
5768#endif
5769#ifdef NK_INCLUDE_COMMAND_USERDATA
5770 nk_handle userdata;
5771#endif
5779
5782 int use_pool;
5783 struct nk_pool pool;
5784 struct nk_window *begin;
5785 struct nk_window *end;
5786 struct nk_window *active;
5787 struct nk_window *current;
5788 struct nk_page_element *freelist;
5789 unsigned int count;
5790 unsigned int seq;
5791};
5792
5793/* ==============================================================
5794 * MATH
5795 * =============================================================== */
5796#define NK_PI 3.141592654f
5797#define NK_PI_HALF 1.570796326f
5798#define NK_UTF_INVALID 0xFFFD
5799#define NK_MAX_FLOAT_PRECISION 2
5800
5801#define NK_UNUSED(x) ((void)(x))
5802#define NK_SATURATE(x) (NK_MAX(0, NK_MIN(1.0f, x)))
5803#define NK_LEN(a) (sizeof(a)/sizeof(a)[0])
5804#define NK_ABS(a) (((a) < 0) ? -(a) : (a))
5805#define NK_BETWEEN(x, a, b) ((a) <= (x) && (x) < (b))
5806#define NK_INBOX(px, py, x, y, w, h)\
5807 (NK_BETWEEN(px,x,x+w) && NK_BETWEEN(py,y,y+h))
5808#define NK_INTERSECT(x0, y0, w0, h0, x1, y1, w1, h1) \
5809 ((x1 < (x0 + w0)) && (x0 < (x1 + w1)) && \
5810 (y1 < (y0 + h0)) && (y0 < (y1 + h1)))
5811#define NK_CONTAINS(x, y, w, h, bx, by, bw, bh)\
5812 (NK_INBOX(x,y, bx, by, bw, bh) && NK_INBOX(x+w,y+h, bx, by, bw, bh))
5813
5814#define nk_vec2_sub(a, b) nk_vec2((a).x - (b).x, (a).y - (b).y)
5815#define nk_vec2_add(a, b) nk_vec2((a).x + (b).x, (a).y + (b).y)
5816#define nk_vec2_len_sqr(a) ((a).x*(a).x+(a).y*(a).y)
5817#define nk_vec2_muls(a, t) nk_vec2((a).x * (t), (a).y * (t))
5818
5819#define nk_ptr_add(t, p, i) ((t*)((void*)((nk_byte*)(p) + (i))))
5820#define nk_ptr_add_const(t, p, i) ((const t*)((const void*)((const nk_byte*)(p) + (i))))
5821#define nk_zero_struct(s) nk_zero(&s, sizeof(s))
5822
5823/* ==============================================================
5824 * ALIGNMENT
5825 * =============================================================== */
5826/* Pointer to Integer type conversion for pointer alignment */
5827#if defined(__PTRDIFF_TYPE__) /* This case should work for GCC*/
5828# define NK_UINT_TO_PTR(x) ((void*)(__PTRDIFF_TYPE__)(x))
5829# define NK_PTR_TO_UINT(x) ((nk_size)(__PTRDIFF_TYPE__)(x))
5830#elif !defined(__GNUC__) /* works for compilers other than LLVM */
5831# define NK_UINT_TO_PTR(x) ((void*)&((char*)0)[x])
5832# define NK_PTR_TO_UINT(x) ((nk_size)(((char*)x)-(char*)0))
5833#elif defined(NK_USE_FIXED_TYPES) /* used if we have <stdint.h> */
5834# define NK_UINT_TO_PTR(x) ((void*)(uintptr_t)(x))
5835# define NK_PTR_TO_UINT(x) ((uintptr_t)(x))
5836#else /* generates warning but works */
5837# define NK_UINT_TO_PTR(x) ((void*)(x))
5838# define NK_PTR_TO_UINT(x) ((nk_size)(x))
5839#endif
5840
5841#define NK_ALIGN_PTR(x, mask)\
5842 (NK_UINT_TO_PTR((NK_PTR_TO_UINT((nk_byte*)(x) + (mask-1)) & ~(mask-1))))
5843#define NK_ALIGN_PTR_BACK(x, mask)\
5844 (NK_UINT_TO_PTR((NK_PTR_TO_UINT((nk_byte*)(x)) & ~(mask-1))))
5845
5846#if ((defined(__GNUC__) && __GNUC__ >= 4) || defined(__clang__)) && !defined(EMSCRIPTEN)
5847#define NK_OFFSETOF(st,m) (__builtin_offsetof(st,m))
5848#else
5849#define NK_OFFSETOF(st,m) ((nk_ptr)&(((st*)0)->m))
5850#endif
5851
5852#ifdef __cplusplus
5853}
5854#endif
5855
5856#ifdef __cplusplus
5857template<typename T> struct nk_alignof;
5858template<typename T, int size_diff> struct nk_helper{enum {value = size_diff};};
5859template<typename T> struct nk_helper<T,0>{enum {value = nk_alignof<T>::value};};
5860template<typename T> struct nk_alignof{struct Big {T x; char c;}; enum {
5861 diff = sizeof(Big) - sizeof(T), value = nk_helper<Big, diff>::value};};
5862#define NK_ALIGNOF(t) (nk_alignof<t>::value)
5863#else
5864#define NK_ALIGNOF(t) NK_OFFSETOF(struct {char c; t _h;}, _h)
5865#endif
5866
5867#define NK_CONTAINER_OF(ptr,type,member)\
5868 (type*)((void*)((char*)(1 ? (ptr): &((type*)0)->member) - NK_OFFSETOF(type, member)))
5869
5870
5871
5872#endif /* NK_NUKLEAR_H_ */
NK_API void nk_tree_pop(struct nk_context *)
NK_API void nk_free(struct nk_context *)
Frees all memory allocated by nuklear; Not needed if context was initialized with nk_init_fixed.
NK_API nk_bool nk_group_begin(struct nk_context *, const char *title, nk_flags)
Starts a new widget group.
NK_API struct nk_vec2 nk_window_get_content_region_max(const struct nk_context *ctx)
NK_API nk_bool nk_property_double(struct nk_context *, const char *name, double min, double *val, double max, double step, float inc_per_pixel)
NK_API void nk_layout_row_end(struct nk_context *)
Finished previously started row.
NK_API void nk_input_end(struct nk_context *)
End the input mirroring process by resetting mouse grabbing state to ensure the mouse cursor is not g...
NK_API void nk_window_close(struct nk_context *ctx, const char *name)
NK_API void nk_spacer(struct nk_context *ctx)
NK_API void nk_input_begin(struct nk_context *)
Begins the input mirroring process by resetting text, scroll mouse, previous mouse position and movem...
NK_API float nk_propertyf(struct nk_context *, const char *name, float min, float val, float max, float step, float inc_per_pixel)
NK_API void nk_rule_horizontal(struct nk_context *ctx, struct nk_color color, nk_bool rounding)
NK_API void nk_layout_space_end(struct nk_context *)
NK_API nk_bool nk_init_fixed(struct nk_context *, void *memory, nk_size size, const struct nk_user_font *)
nk_window_flags
Definition nuklear.h:5534
@ NK_WINDOW_CLOSED
Directly closes and frees the window at the end of the frame.
Definition nuklear.h:5540
@ NK_WINDOW_MINIMIZED
marks the window as minimized
Definition nuklear.h:5541
@ NK_WINDOW_HIDDEN
Hides window and stops any window interaction and drawing.
Definition nuklear.h:5539
@ NK_WINDOW_ROM
sets window widgets into a read only mode and does not allow input changes
Definition nuklear.h:5537
@ NK_WINDOW_NOT_INTERACTIVE
prevents all interaction caused by input to either window or widgets inside
Definition nuklear.h:5538
@ NK_WINDOW_DYNAMIC
special window type growing up in height while being filled to a certain maximum height
Definition nuklear.h:5536
@ NK_WINDOW_REMOVE_ROM
Removes read only mode at the end of the window.
Definition nuklear.h:5542
NK_API void nk_layout_row(struct nk_context *, enum nk_layout_format, float height, int cols, const float *ratio)
Specifies row columns in array as either window ratio or size.
NK_API void nk_draw_image(struct nk_command_buffer *, struct nk_rect, const struct nk_image *, struct nk_color)
misc
NK_API nk_bool nk_window_is_hovered(const struct nk_context *ctx)
NK_API void nk_window_collapse_if(struct nk_context *ctx, const char *name, enum nk_collapse_states state, int cond)
NK_API struct nk_vec2 nk_layout_space_to_screen(const struct nk_context *ctx, struct nk_vec2 vec)
NK_API struct nk_command_buffer * nk_window_get_canvas(const struct nk_context *ctx)
NK_API nk_bool nk_init_custom(struct nk_context *, struct nk_buffer *cmds, struct nk_buffer *pool, const struct nk_user_font *)
Initializes a nk_context struct from two different either fixed or growing buffers.
NK_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)
NK_API void nk_window_set_scroll(struct nk_context *ctx, nk_uint offset_x, nk_uint offset_y)
NK_API void nk_group_scrolled_end(struct nk_context *)
NK_API struct nk_vec2 nk_window_get_size(const struct nk_context *ctx)
NK_API void nk_layout_row_template_push_dynamic(struct nk_context *)
NK_API const struct nk_command * nk__begin(struct nk_context *)
Returns a draw command list iterator to iterate all draw commands accumulated over one frame.
NK_API nk_bool nk_window_is_active(const struct nk_context *ctx, const char *name)
NK_API void nk_group_get_scroll(struct nk_context *, const char *id, nk_uint *x_offset, nk_uint *y_offset)
NK_API struct nk_vec2 nk_layout_space_to_local(const struct nk_context *ctx, struct nk_vec2 vec)
#define NK_POINTER_TYPE
could be any type with semantic of standard bool, either equal or smaller than int
Definition nuklear.h:190
NK_API void nk_window_set_focus(struct nk_context *ctx, const char *name)
NK_API nk_bool nk_item_is_any_active(const struct nk_context *ctx)
#define NK_UTF_SIZE
describes the number of bytes a glyph consists of
Definition nuklear.h:22
NK_API void nk_input_unicode(struct nk_context *, nk_rune)
Converts a unicode rune into UTF-8 and copies the result into an internal text buffer.
NK_API nk_bool nk_window_is_any_hovered(const struct nk_context *ctx)
NK_API nk_bool nk_window_is_hidden(const struct nk_context *ctx, const char *name)
NK_API void nk_input_key(struct nk_context *, enum nk_keys, nk_bool down)
Mirrors the state of a specific key to nuklear.
NK_API void nk_stroke_line(struct nk_command_buffer *b, float x0, float y0, float x1, float y1, float line_thickness, struct nk_color)
shape outlines
NK_API void nk_fill_rect(struct nk_command_buffer *, struct nk_rect, float rounding, struct nk_color)
filled shades
NK_API void nk_layout_row_template_push_static(struct nk_context *, float width)
NK_API struct nk_vec2 nk_window_get_content_region_size(const struct nk_context *ctx)
NK_API struct nk_panel * nk_window_get_panel(const struct nk_context *ctx)
NK_API void nk_window_get_scroll(const struct nk_context *ctx, nk_uint *offset_x, nk_uint *offset_y)
NK_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)
NK_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)
NK_API void nk_window_set_position(struct nk_context *ctx, const char *name, struct nk_vec2 pos)
NK_API void nk_window_show(struct nk_context *ctx, const char *name, enum nk_show_states state)
NK_API nk_bool nk_window_is_collapsed(const struct nk_context *ctx, const char *name)
NK_API void nk_layout_row_dynamic(struct nk_context *ctx, float height, int cols)
Sets current row layout to share horizontal space between @cols number of widgets evenly.
NK_API const struct nk_command * nk__next(struct nk_context *, const struct nk_command *)
Returns draw command pointer pointing to the next command inside the draw command list.
NK_API void nk_window_collapse(struct nk_context *ctx, const char *name, enum nk_collapse_states state)
NK_API nk_bool nk_filter_default(const struct nk_text_edit *, nk_rune unicode)
filter function
NK_API void nk_layout_row_template_end(struct nk_context *)
NK_API nk_bool nk_window_has_focus(const struct nk_context *ctx)
NK_API void nk_layout_reset_min_row_height(struct nk_context *)
Reset the currently used minimum row height back to font_height + text_padding + padding
nk_widget_states
Definition nuklear.h:3117
@ NK_WIDGET_STATE_LEFT
!< widget is currently activated
Definition nuklear.h:3123
@ NK_WIDGET_STATE_ACTIVED
!< widget is being hovered
Definition nuklear.h:3122
@ NK_WIDGET_STATE_ENTERED
!< widget is neither active nor hovered
Definition nuklear.h:3120
@ NK_WIDGET_STATE_HOVER
!< widget has been hovered on the current frame
Definition nuklear.h:3121
@ NK_WIDGET_STATE_ACTIVE
!< widget is being hovered
Definition nuklear.h:3125
@ NK_WIDGET_STATE_HOVERED
!< widget is from this frame on not hovered anymore
Definition nuklear.h:3124
NK_API struct nk_window * nk_window_find(const struct nk_context *ctx, const char *name)
NK_API struct nk_rect nk_layout_space_rect_to_local(const struct nk_context *ctx, struct nk_rect bounds)
NK_API void nk_window_set_bounds(struct nk_context *ctx, const char *name, struct nk_rect bounds)
NK_API struct nk_rect nk_window_get_bounds(const struct nk_context *ctx)
NK_API nk_bool nk_tree_state_push(struct nk_context *, enum nk_tree_type, const char *title, enum nk_collapse_states *state)
NK_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)
NK_API void nk_layout_set_min_row_height(struct nk_context *, float height)
Sets the currently used minimum row height.
NK_API void nk_window_show_if(struct nk_context *ctx, const char *name, enum nk_show_states state, int cond)
NK_API float nk_window_get_height(const struct nk_context *ctx)
NK_API void nk_layout_row_begin(struct nk_context *ctx, enum nk_layout_format fmt, float row_height, int cols)
Starts a new dynamic or fixed row with given height and columns.
NK_API nk_bool nk_group_begin_titled(struct nk_context *, const char *name, const char *title, nk_flags)
Starts a new widget group.
NK_API nk_bool nk_begin_titled(struct nk_context *ctx, const char *name, const char *title, struct nk_rect bounds, nk_flags flags)
NK_API void nk_layout_space_push(struct nk_context *, struct nk_rect bounds)
NK_API nk_bool nk_begin(struct nk_context *ctx, const char *title, struct nk_rect bounds, nk_flags flags)
NK_API void nk_window_set_size(struct nk_context *ctx, const char *name, struct nk_vec2 size)
NK_API void nk_input_button(struct nk_context *, enum nk_buttons, int x, int y, nk_bool down)
Mirrors the state of a specific mouse button to nuklear.
NK_API void nk_group_set_scroll(struct nk_context *, const char *id, nk_uint x_offset, nk_uint y_offset)
NK_API void nk_layout_row_template_begin(struct nk_context *, float row_height)
NK_API nk_bool nk_init(struct nk_context *, const struct nk_allocator *, const struct nk_user_font *)
NK_API float nk_layout_ratio_from_pixel(const struct nk_context *ctx, float pixel_width)
Utility functions to calculate window ratio from pixel size.
NK_API void nk_tree_state_pop(struct nk_context *)
NK_API void nk_layout_row_push(struct nk_context *, float value)
\breif Specifies either window ratio or width of a single column
NK_API struct nk_rect nk_layout_widget_bounds(const struct nk_context *ctx)
Returns the width of the next row allocate by one of the layouting functions.
NK_API struct nk_rect nk_layout_space_rect_to_screen(const struct nk_context *ctx, struct nk_rect bounds)
NK_API struct nk_vec2 nk_window_get_content_region_min(const struct nk_context *ctx)
NK_API void nk_input_char(struct nk_context *, char)
Copies a single ASCII character into an internal text buffer.
NK_API float nk_window_get_width(const struct nk_context *ctx)
nk_window_get_width
NK_API void nk_input_scroll(struct nk_context *, struct nk_vec2 val)
Copies the last mouse scroll value to nuklear.
nk_widget_layout_states
Definition nuklear.h:3111
@ NK_WIDGET_DISABLED
The widget is manually disabled and acts like NK_WIDGET_ROM.
Definition nuklear.h:3115
@ NK_WIDGET_ROM
The widget is partially visible and cannot be updated.
Definition nuklear.h:3114
@ NK_WIDGET_VALID
The widget is completely inside the window and can be updated and drawn.
Definition nuklear.h:3113
@ NK_WIDGET_INVALID
The widget cannot be seen and is completely out of view.
Definition nuklear.h:3112
NK_API double nk_propertyd(struct nk_context *, const char *name, double min, double val, double max, double step, float inc_per_pixel)
NK_API void nk_input_motion(struct nk_context *, int x, int y)
Mirrors current mouse position to nuklear.
NK_API void nk_layout_space_begin(struct nk_context *, enum nk_layout_format, float height, int widget_count)
NK_API struct nk_rect nk_layout_space_bounds(const struct nk_context *ctx)
NK_API struct nk_rect nk_window_get_content_region(const struct nk_context *ctx)
NK_API nk_bool nk_window_is_closed(const struct nk_context *ctx, const char *name)
NK_API void nk_clear(struct nk_context *)
Resets the context state at the end of the frame.
NK_API void nk_end(struct nk_context *ctx)
NK_API void nk_group_end(struct nk_context *)
NK_API nk_bool nk_property_float(struct nk_context *, const char *name, float min, float *val, float max, float step, float inc_per_pixel)
NK_API void nk_layout_row_template_push_variable(struct nk_context *, float min_width)
NK_API struct nk_vec2 nk_window_get_position(const struct nk_context *ctx)
nk_edit_events
Definition nuklear.h:3537
@ NK_EDIT_INACTIVE
!< edit widget is currently being modified
Definition nuklear.h:3539
@ NK_EDIT_DEACTIVATED
!< edit widget went from state inactive to state active
Definition nuklear.h:3541
@ NK_EDIT_COMMITED
!< edit widget went from state active to state inactive
Definition nuklear.h:3542
@ NK_EDIT_ACTIVATED
!< edit widget is not active and is not being modified
Definition nuklear.h:3540
NK_API int nk_propertyi(struct nk_context *, const char *name, int min, int val, int max, int step, float inc_per_pixel)
NK_API nk_bool nk_group_scrolled_begin(struct nk_context *, struct nk_scroll *off, const char *title, nk_flags)
NK_API void nk_input_glyph(struct nk_context *, const nk_glyph)
Converts an encoded unicode rune into UTF-8 and copies the result into an internal text buffer.
NK_API void nk_layout_row_static(struct nk_context *ctx, float height, int item_width, int cols)
Sets current row layout to fill @cols number of widgets in row with same @item_width horizontal size.
NK_API void nk_textedit_init(struct nk_text_edit *, const struct nk_allocator *, nk_size size)
text editor
struct nk_allocator pool
!< buffer marker to free a buffer to a certain offset
Definition nuklear.h:4232
struct nk_memory memory
!< memory management type
Definition nuklear.h:4234
enum nk_allocation_type type
!< allocator callback for dynamic buffers
Definition nuklear.h:4233
nk_size needed
!< total amount of memory allocated
Definition nuklear.h:4237
nk_size size
!< number of allocation calls
Definition nuklear.h:4239
nk_size allocated
!< growing factor for dynamic memory management
Definition nuklear.h:4236
float grow_factor
!< memory and size of the current memory block
Definition nuklear.h:4235
nk_size calls
!< totally consumed memory given that enough memory is present
Definition nuklear.h:4238
command base and header of every command inside the buffer
Definition nuklear.h:4508
int build
windows
Definition nuklear.h:5781
struct nk_text_edit text_edit
text editor objects are quite big because of an internal undo/redo stack.
Definition nuklear.h:5776
struct nk_command_buffer overlay
draw buffer used for overlay drawing operation like cursor
Definition nuklear.h:5778
enum nk_anti_aliasing shape_AA
!< line anti-aliasing flag can be turned off if you are tight on memory
Definition nuklear.h:1006
enum nk_anti_aliasing line_AA
!< global alpha value
Definition nuklear.h:1005
nk_size vertex_alignment
!< sizeof one vertex for vertex packing
Definition nuklear.h:1013
nk_size vertex_size
!< describes the vertex output format and packing
Definition nuklear.h:1012
const struct nk_draw_vertex_layout_element * vertex_layout
!< handle to texture with a white pixel for shape drawing
Definition nuklear.h:1011
unsigned arc_segment_count
!< number of segments used for circles: default to 22
Definition nuklear.h:1008
unsigned circle_segment_count
!< shape anti-aliasing flag can be turned off if you are tight on memory
Definition nuklear.h:1007
unsigned curve_segment_count
!< number of segments used for arcs: default to 22
Definition nuklear.h:1009
struct nk_draw_null_texture tex_null
!< number of segments used for curves: default to 22
Definition nuklear.h:1010
struct nk_vec2 uv
!< texture handle to a texture with a white pixel
Definition nuklear.h:1001
Basic string buffer which is only used in context with the text editor to manage and manipulate dynam...
Definition nuklear.h:4267
nk_text_width_f width
!< max height of the font
Definition nuklear.h:4050
float height
!< user provided font handle
Definition nuklear.h:4049