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
296typedef void*(*nk_plugin_alloc)(nk_handle, void *old, nk_size);
297typedef void (*nk_plugin_free)(nk_handle, void *old);
298typedef nk_bool(*nk_plugin_filter)(const struct nk_text_edit*, nk_rune unicode);
299typedef void(*nk_plugin_paste)(nk_handle, struct nk_text_edit*);
300typedef void(*nk_plugin_copy)(nk_handle, const char*, int len);
301
303 nk_handle userdata;
304 nk_plugin_alloc alloc;
305 nk_plugin_free free;
306};
307enum nk_symbol_type {
308 NK_SYMBOL_NONE,
309 NK_SYMBOL_X,
310 NK_SYMBOL_UNDERSCORE,
311 NK_SYMBOL_CIRCLE_SOLID,
312 NK_SYMBOL_CIRCLE_OUTLINE,
313 NK_SYMBOL_RECT_SOLID,
314 NK_SYMBOL_RECT_OUTLINE,
315 NK_SYMBOL_TRIANGLE_UP,
316 NK_SYMBOL_TRIANGLE_DOWN,
317 NK_SYMBOL_TRIANGLE_LEFT,
318 NK_SYMBOL_TRIANGLE_RIGHT,
319 NK_SYMBOL_PLUS,
320 NK_SYMBOL_MINUS,
321 NK_SYMBOL_TRIANGLE_UP_OUTLINE,
322 NK_SYMBOL_TRIANGLE_DOWN_OUTLINE,
323 NK_SYMBOL_TRIANGLE_LEFT_OUTLINE,
324 NK_SYMBOL_TRIANGLE_RIGHT_OUTLINE,
325 NK_SYMBOL_MAX
326};
327/* =============================================================================
328 *
329 * CONTEXT
330 *
331 * =============================================================================*/
367#ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
368
385NK_API nk_bool nk_init_default(struct nk_context*, const struct nk_user_font*);
386#endif
411NK_API nk_bool nk_init_fixed(struct nk_context*, void *memory, nk_size size, const struct nk_user_font*);
412
431NK_API nk_bool nk_init(struct nk_context*, const struct nk_allocator*, const struct nk_user_font*);
432
451NK_API nk_bool nk_init_custom(struct nk_context*, struct nk_buffer *cmds, struct nk_buffer *pool, const struct nk_user_font*);
452
466NK_API void nk_clear(struct nk_context*);
467
478NK_API void nk_free(struct nk_context*);
479
480#ifdef NK_INCLUDE_COMMAND_USERDATA
492NK_API void nk_set_user_data(struct nk_context*, nk_handle handle);
493#endif
494/* =============================================================================
495 *
496 * INPUT
497 *
498 * =============================================================================*/
563enum nk_keys {
564 NK_KEY_NONE,
565 NK_KEY_SHIFT,
566 NK_KEY_CTRL,
567 NK_KEY_DEL,
568 NK_KEY_ENTER,
569 NK_KEY_TAB,
570 NK_KEY_BACKSPACE,
571 NK_KEY_COPY,
572 NK_KEY_CUT,
573 NK_KEY_PASTE,
574 NK_KEY_UP,
575 NK_KEY_DOWN,
576 NK_KEY_LEFT,
577 NK_KEY_RIGHT,
578 /* Shortcuts: text field */
579 NK_KEY_TEXT_INSERT_MODE,
580 NK_KEY_TEXT_REPLACE_MODE,
581 NK_KEY_TEXT_RESET_MODE,
582 NK_KEY_TEXT_LINE_START,
583 NK_KEY_TEXT_LINE_END,
584 NK_KEY_TEXT_START,
585 NK_KEY_TEXT_END,
586 NK_KEY_TEXT_UNDO,
587 NK_KEY_TEXT_REDO,
588 NK_KEY_TEXT_SELECT_ALL,
589 NK_KEY_TEXT_WORD_LEFT,
590 NK_KEY_TEXT_WORD_RIGHT,
591 /* Shortcuts: scrollbar */
592 NK_KEY_SCROLL_START,
593 NK_KEY_SCROLL_END,
594 NK_KEY_SCROLL_DOWN,
595 NK_KEY_SCROLL_UP,
596 NK_KEY_MAX
597};
598enum nk_buttons {
599 NK_BUTTON_LEFT,
600 NK_BUTTON_MIDDLE,
601 NK_BUTTON_RIGHT,
602 NK_BUTTON_DOUBLE,
603 NK_BUTTON_MAX
604};
605
617NK_API void nk_input_begin(struct nk_context*);
618
631NK_API void nk_input_motion(struct nk_context*, int x, int y);
632
645NK_API void nk_input_key(struct nk_context*, enum nk_keys, nk_bool down);
646
661NK_API void nk_input_button(struct nk_context*, enum nk_buttons, int x, int y, nk_bool down);
662
677NK_API void nk_input_scroll(struct nk_context*, struct nk_vec2 val);
678
696NK_API void nk_input_char(struct nk_context*, char);
697
712NK_API void nk_input_glyph(struct nk_context*, const nk_glyph);
713
729NK_API void nk_input_unicode(struct nk_context*, nk_rune);
730
742NK_API void nk_input_end(struct nk_context*);
743
744/* =============================================================================
745 *
746 * DRAWING
747 *
748 * =============================================================================*/
975enum nk_anti_aliasing {NK_ANTI_ALIASING_OFF, NK_ANTI_ALIASING_ON};
976enum nk_convert_result {
977 NK_CONVERT_SUCCESS = 0,
978 NK_CONVERT_INVALID_PARAM = 1,
979 NK_CONVERT_COMMAND_BUFFER_FULL = NK_FLAG(1),
980 NK_CONVERT_VERTEX_BUFFER_FULL = NK_FLAG(2),
981 NK_CONVERT_ELEMENT_BUFFER_FULL = NK_FLAG(3)
982};
984 nk_handle texture;
985 struct nk_vec2 uv;
986};
988 float global_alpha;
989 enum nk_anti_aliasing line_AA;
990 enum nk_anti_aliasing shape_AA;
995 const struct nk_draw_vertex_layout_element *vertex_layout;
996 nk_size vertex_size;
998};
999
1013NK_API const struct nk_command* nk__begin(struct nk_context*);
1014
1028NK_API const struct nk_command* nk__next(struct nk_context*, const struct nk_command*);
1029
1040#define nk_foreach(c, ctx) for((c) = nk__begin(ctx); (c) != 0; (c) = nk__next(ctx,c))
1041
1042#ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
1043
1073NK_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*);
1074
1088NK_API const struct nk_draw_command* nk__draw_begin(const struct nk_context*, const struct nk_buffer*);
1089
1107NK_API const struct nk_draw_command* nk__draw_end(const struct nk_context*, const struct nk_buffer*);
1108
1126NK_API const struct nk_draw_command* nk__draw_next(const struct nk_draw_command*, const struct nk_buffer*, const struct nk_context*);
1127
1143#define nk_draw_foreach(cmd,ctx, b) for((cmd)=nk__draw_begin(ctx, b); (cmd)!=0; (cmd)=nk__draw_next(cmd, b, ctx))
1144#endif
1145
1146/* =============================================================================
1147 *
1148 * WINDOW
1149 *
1150 * =============================================================================*/
1299enum nk_panel_flags {
1300 NK_WINDOW_BORDER = NK_FLAG(0),
1301 NK_WINDOW_MOVABLE = NK_FLAG(1),
1302 NK_WINDOW_SCALABLE = NK_FLAG(2),
1303 NK_WINDOW_CLOSABLE = NK_FLAG(3),
1304 NK_WINDOW_MINIMIZABLE = NK_FLAG(4),
1305 NK_WINDOW_NO_SCROLLBAR = NK_FLAG(5),
1306 NK_WINDOW_TITLE = NK_FLAG(6),
1307 NK_WINDOW_SCROLL_AUTO_HIDE = NK_FLAG(7),
1308 NK_WINDOW_BACKGROUND = NK_FLAG(8),
1309 NK_WINDOW_SCALE_LEFT = NK_FLAG(9),
1310 NK_WINDOW_NO_INPUT = NK_FLAG(10)
1311};
1312
1333NK_API nk_bool nk_begin(struct nk_context *ctx, const char *title, struct nk_rect bounds, nk_flags flags);
1334
1356NK_API nk_bool nk_begin_titled(struct nk_context *ctx, const char *name, const char *title, struct nk_rect bounds, nk_flags flags);
1357
1372NK_API void nk_end(struct nk_context *ctx);
1373
1390NK_API struct nk_window *nk_window_find(const struct nk_context *ctx, const char *name);
1391
1409NK_API struct nk_rect nk_window_get_bounds(const struct nk_context *ctx);
1410
1428NK_API struct nk_vec2 nk_window_get_position(const struct nk_context *ctx);
1429
1447NK_API struct nk_vec2 nk_window_get_size(const struct nk_context *ctx);
1448
1465NK_API float nk_window_get_width(const struct nk_context *ctx);
1466
1484NK_API float nk_window_get_height(const struct nk_context* ctx);
1485
1505NK_API struct nk_panel* nk_window_get_panel(const struct nk_context* ctx);
1506
1527NK_API struct nk_rect nk_window_get_content_region(const struct nk_context* ctx);
1528
1549NK_API struct nk_vec2 nk_window_get_content_region_min(const struct nk_context *ctx);
1550
1571NK_API struct nk_vec2 nk_window_get_content_region_max(const struct nk_context *ctx);
1572
1592NK_API struct nk_vec2 nk_window_get_content_region_size(const struct nk_context *ctx);
1593
1613NK_API struct nk_command_buffer* nk_window_get_canvas(const struct nk_context* ctx);
1614
1632NK_API void nk_window_get_scroll(const struct nk_context *ctx, nk_uint *offset_x, nk_uint *offset_y);
1633
1650NK_API nk_bool nk_window_has_focus(const struct nk_context *ctx);
1651
1668NK_API nk_bool nk_window_is_hovered(const struct nk_context *ctx);
1669
1686NK_API nk_bool nk_window_is_collapsed(const struct nk_context *ctx, const char *name);
1687
1703NK_API nk_bool nk_window_is_closed(const struct nk_context *ctx, const char* name);
1704
1720NK_API nk_bool nk_window_is_hidden(const struct nk_context *ctx, const char* name);
1721
1736NK_API nk_bool nk_window_is_active(const struct nk_context *ctx, const char* name);
1737
1751NK_API nk_bool nk_window_is_any_hovered(const struct nk_context *ctx);
1752
1769NK_API nk_bool nk_item_is_any_active(const struct nk_context *ctx);
1770
1785NK_API void nk_window_set_bounds(struct nk_context *ctx, const char *name, struct nk_rect bounds);
1786
1801NK_API void nk_window_set_position(struct nk_context *ctx, const char *name, struct nk_vec2 pos);
1802
1817NK_API void nk_window_set_size(struct nk_context *ctx, const char *name, struct nk_vec2 size);
1818
1832NK_API void nk_window_set_focus(struct nk_context *ctx, const char *name);
1833
1851NK_API void nk_window_set_scroll(struct nk_context *ctx, nk_uint offset_x, nk_uint offset_y);
1852
1866NK_API void nk_window_close(struct nk_context *ctx, const char *name);
1867
1882NK_API void nk_window_collapse(struct nk_context *ctx, const char *name, enum nk_collapse_states state);
1883
1899NK_API void nk_window_collapse_if(struct nk_context *ctx, const char *name, enum nk_collapse_states state, int cond);
1900
1914NK_API void nk_window_show(struct nk_context *ctx, const char *name, enum nk_show_states state);
1915
1931NK_API void nk_window_show_if(struct nk_context *ctx, const char *name, enum nk_show_states state, int cond);
1932
1946NK_API void nk_rule_horizontal(struct nk_context *ctx, struct nk_color color, nk_bool rounding);
1947
1948/* =============================================================================
1949 *
1950 * LAYOUT
1951 *
1952 * =============================================================================*/
2221enum nk_widget_align {
2222 NK_WIDGET_ALIGN_LEFT = 0x01,
2223 NK_WIDGET_ALIGN_CENTERED = 0x02,
2224 NK_WIDGET_ALIGN_RIGHT = 0x04,
2225 NK_WIDGET_ALIGN_TOP = 0x08,
2226 NK_WIDGET_ALIGN_MIDDLE = 0x10,
2227 NK_WIDGET_ALIGN_BOTTOM = 0x20
2228};
2229enum nk_widget_alignment {
2230 NK_WIDGET_LEFT = NK_WIDGET_ALIGN_MIDDLE|NK_WIDGET_ALIGN_LEFT,
2231 NK_WIDGET_CENTERED = NK_WIDGET_ALIGN_MIDDLE|NK_WIDGET_ALIGN_CENTERED,
2232 NK_WIDGET_RIGHT = NK_WIDGET_ALIGN_MIDDLE|NK_WIDGET_ALIGN_RIGHT
2233};
2234
2248NK_API void nk_layout_set_min_row_height(struct nk_context*, float height);
2249
2258NK_API void nk_layout_reset_min_row_height(struct nk_context*);
2259
2272NK_API struct nk_rect nk_layout_widget_bounds(const struct nk_context *ctx);
2273
2287NK_API float nk_layout_ratio_from_pixel(const struct nk_context *ctx, float pixel_width);
2288
2303NK_API void nk_layout_row_dynamic(struct nk_context *ctx, float height, int cols);
2304
2320NK_API void nk_layout_row_static(struct nk_context *ctx, float height, int item_width, int cols);
2321
2335NK_API void nk_layout_row_begin(struct nk_context *ctx, enum nk_layout_format fmt, float row_height, int cols);
2336
2348NK_API void nk_layout_row_push(struct nk_context*, float value);
2349
2360NK_API void nk_layout_row_end(struct nk_context*);
2361
2375NK_API void nk_layout_row(struct nk_context*, enum nk_layout_format, float height, int cols, const float *ratio);
2376
2389NK_API void nk_layout_row_template_begin(struct nk_context*, float row_height);
2390
2404
2417NK_API void nk_layout_row_template_push_variable(struct nk_context*, float min_width);
2418
2431NK_API void nk_layout_row_template_push_static(struct nk_context*, float width);
2432
2444NK_API void nk_layout_row_template_end(struct nk_context*);
2445
2460NK_API void nk_layout_space_begin(struct nk_context*, enum nk_layout_format, float height, int widget_count);
2461
2474NK_API void nk_layout_space_push(struct nk_context*, struct nk_rect bounds);
2475
2487NK_API void nk_layout_space_end(struct nk_context*);
2488
2502NK_API struct nk_rect nk_layout_space_bounds(const struct nk_context *ctx);
2503
2518NK_API struct nk_vec2 nk_layout_space_to_screen(const struct nk_context* ctx, struct nk_vec2 vec);
2519
2534NK_API struct nk_vec2 nk_layout_space_to_local(const struct nk_context *ctx, struct nk_vec2 vec);
2535
2550NK_API struct nk_rect nk_layout_space_rect_to_screen(const struct nk_context *ctx, struct nk_rect bounds);
2551
2566NK_API struct nk_rect nk_layout_space_rect_to_local(const struct nk_context *ctx, struct nk_rect bounds);
2567
2580NK_API void nk_spacer(struct nk_context *ctx);
2581
2582
2583/* =============================================================================
2584 *
2585 * GROUP
2586 *
2587 * =============================================================================*/
2687NK_API nk_bool nk_group_begin(struct nk_context*, const char *title, nk_flags);
2688
2702NK_API nk_bool nk_group_begin_titled(struct nk_context*, const char *name, const char *title, nk_flags);
2703
2715NK_API void nk_group_end(struct nk_context*);
2716
2735NK_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);
2736
2754NK_API nk_bool nk_group_scrolled_begin(struct nk_context*, struct nk_scroll *off, const char *title, nk_flags);
2755
2767NK_API void nk_group_scrolled_end(struct nk_context*);
2768
2783NK_API void nk_group_get_scroll(struct nk_context*, const char *id, nk_uint *x_offset, nk_uint *y_offset);
2784
2799NK_API void nk_group_set_scroll(struct nk_context*, const char *id, nk_uint x_offset, nk_uint y_offset);
2800
2801/* =============================================================================
2802 *
2803 * TREE
2804 *
2805 * =============================================================================*/
2894#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__)
2895
2913#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)
2914
2935NK_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);
2936
2959#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__)
2960
2981#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)
2982
3004NK_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);
3005
3017NK_API void nk_tree_pop(struct nk_context*);
3018
3035NK_API nk_bool nk_tree_state_push(struct nk_context*, enum nk_tree_type, const char *title, enum nk_collapse_states *state);
3036
3054NK_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);
3055
3067NK_API void nk_tree_state_pop(struct nk_context*);
3068
3069#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__)
3070#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)
3071NK_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);
3072NK_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);
3073NK_API void nk_tree_element_pop(struct nk_context*);
3074
3075/* =============================================================================
3076 *
3077 * LIST VIEW
3078 *
3079 * ============================================================================= */
3081/* public: */
3082 int begin, end, count;
3083/* private: */
3084 int total_height;
3085 struct nk_context *ctx;
3086 nk_uint *scroll_pointer;
3087 nk_uint scroll_value;
3088};
3089NK_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);
3090NK_API void nk_list_view_end(struct nk_list_view*);
3091/* =============================================================================
3092 *
3093 * WIDGET
3094 *
3095 * ============================================================================= */
3103 NK_WIDGET_STATE_MODIFIED = NK_FLAG(1),
3104 NK_WIDGET_STATE_INACTIVE = NK_FLAG(2),
3110 NK_WIDGET_STATE_ACTIVE = NK_WIDGET_STATE_ACTIVED|NK_WIDGET_STATE_MODIFIED
3112NK_API enum nk_widget_layout_states nk_widget(struct nk_rect*, const struct nk_context*);
3113NK_API enum nk_widget_layout_states nk_widget_fitting(struct nk_rect*, const struct nk_context*, struct nk_vec2);
3114NK_API struct nk_rect nk_widget_bounds(const struct nk_context*);
3115NK_API struct nk_vec2 nk_widget_position(const struct nk_context*);
3116NK_API struct nk_vec2 nk_widget_size(const struct nk_context*);
3117NK_API float nk_widget_width(const struct nk_context*);
3118NK_API float nk_widget_height(const struct nk_context*);
3119NK_API nk_bool nk_widget_is_hovered(const struct nk_context*);
3120NK_API nk_bool nk_widget_is_mouse_clicked(const struct nk_context*, enum nk_buttons);
3121NK_API nk_bool nk_widget_has_mouse_click_down(const struct nk_context*, enum nk_buttons, nk_bool down);
3122NK_API void nk_spacing(struct nk_context*, int cols);
3123NK_API void nk_widget_disable_begin(struct nk_context* ctx);
3124NK_API void nk_widget_disable_end(struct nk_context* ctx);
3125/* =============================================================================
3126 *
3127 * TEXT
3128 *
3129 * ============================================================================= */
3130enum nk_text_align {
3131 NK_TEXT_ALIGN_LEFT = 0x01,
3132 NK_TEXT_ALIGN_CENTERED = 0x02,
3133 NK_TEXT_ALIGN_RIGHT = 0x04,
3134 NK_TEXT_ALIGN_TOP = 0x08,
3135 NK_TEXT_ALIGN_MIDDLE = 0x10,
3136 NK_TEXT_ALIGN_BOTTOM = 0x20
3137};
3138enum nk_text_alignment {
3139 NK_TEXT_LEFT = NK_TEXT_ALIGN_MIDDLE|NK_TEXT_ALIGN_LEFT,
3140 NK_TEXT_CENTERED = NK_TEXT_ALIGN_MIDDLE|NK_TEXT_ALIGN_CENTERED,
3141 NK_TEXT_RIGHT = NK_TEXT_ALIGN_MIDDLE|NK_TEXT_ALIGN_RIGHT
3142};
3143NK_API void nk_text(struct nk_context*, const char*, int, nk_flags);
3144NK_API void nk_text_colored(struct nk_context*, const char*, int, nk_flags, struct nk_color);
3145NK_API void nk_text_wrap(struct nk_context*, const char*, int);
3146NK_API void nk_text_wrap_colored(struct nk_context*, const char*, int, struct nk_color);
3147NK_API void nk_label(struct nk_context*, const char*, nk_flags align);
3148NK_API void nk_label_colored(struct nk_context*, const char*, nk_flags align, struct nk_color);
3149NK_API void nk_label_wrap(struct nk_context*, const char*);
3150NK_API void nk_label_colored_wrap(struct nk_context*, const char*, struct nk_color);
3151NK_API void nk_image(struct nk_context*, struct nk_image);
3152NK_API void nk_image_color(struct nk_context*, struct nk_image, struct nk_color);
3153#ifdef NK_INCLUDE_STANDARD_VARARGS
3154NK_API void nk_labelf(struct nk_context*, nk_flags, NK_PRINTF_FORMAT_STRING const char*, ...) NK_PRINTF_VARARG_FUNC(3);
3155NK_API void nk_labelf_colored(struct nk_context*, nk_flags, struct nk_color, NK_PRINTF_FORMAT_STRING const char*,...) NK_PRINTF_VARARG_FUNC(4);
3156NK_API void nk_labelf_wrap(struct nk_context*, NK_PRINTF_FORMAT_STRING const char*,...) NK_PRINTF_VARARG_FUNC(2);
3157NK_API void nk_labelf_colored_wrap(struct nk_context*, struct nk_color, NK_PRINTF_FORMAT_STRING const char*,...) NK_PRINTF_VARARG_FUNC(3);
3158NK_API void nk_labelfv(struct nk_context*, nk_flags, NK_PRINTF_FORMAT_STRING const char*, va_list) NK_PRINTF_VALIST_FUNC(3);
3159NK_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);
3160NK_API void nk_labelfv_wrap(struct nk_context*, NK_PRINTF_FORMAT_STRING const char*, va_list) NK_PRINTF_VALIST_FUNC(2);
3161NK_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);
3162NK_API void nk_value_bool(struct nk_context*, const char *prefix, int);
3163NK_API void nk_value_int(struct nk_context*, const char *prefix, int);
3164NK_API void nk_value_uint(struct nk_context*, const char *prefix, unsigned int);
3165NK_API void nk_value_float(struct nk_context*, const char *prefix, float);
3166NK_API void nk_value_color_byte(struct nk_context*, const char *prefix, struct nk_color);
3167NK_API void nk_value_color_float(struct nk_context*, const char *prefix, struct nk_color);
3168NK_API void nk_value_color_hex(struct nk_context*, const char *prefix, struct nk_color);
3169#endif
3170/* =============================================================================
3171 *
3172 * BUTTON
3173 *
3174 * ============================================================================= */
3175NK_API nk_bool nk_button_text(struct nk_context*, const char *title, int len);
3176NK_API nk_bool nk_button_label(struct nk_context*, const char *title);
3177NK_API nk_bool nk_button_color(struct nk_context*, struct nk_color);
3178NK_API nk_bool nk_button_symbol(struct nk_context*, enum nk_symbol_type);
3179NK_API nk_bool nk_button_image(struct nk_context*, struct nk_image img);
3180NK_API nk_bool nk_button_symbol_label(struct nk_context*, enum nk_symbol_type, const char*, nk_flags text_alignment);
3181NK_API nk_bool nk_button_symbol_text(struct nk_context*, enum nk_symbol_type, const char*, int, nk_flags alignment);
3182NK_API nk_bool nk_button_image_label(struct nk_context*, struct nk_image img, const char*, nk_flags text_alignment);
3183NK_API nk_bool nk_button_image_text(struct nk_context*, struct nk_image img, const char*, int, nk_flags alignment);
3184NK_API nk_bool nk_button_text_styled(struct nk_context*, const struct nk_style_button*, const char *title, int len);
3185NK_API nk_bool nk_button_label_styled(struct nk_context*, const struct nk_style_button*, const char *title);
3186NK_API nk_bool nk_button_symbol_styled(struct nk_context*, const struct nk_style_button*, enum nk_symbol_type);
3187NK_API nk_bool nk_button_image_styled(struct nk_context*, const struct nk_style_button*, struct nk_image img);
3188NK_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);
3189NK_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);
3190NK_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);
3191NK_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);
3192NK_API void nk_button_set_behavior(struct nk_context*, enum nk_button_behavior);
3193NK_API nk_bool nk_button_push_behavior(struct nk_context*, enum nk_button_behavior);
3194NK_API nk_bool nk_button_pop_behavior(struct nk_context*);
3195/* =============================================================================
3196 *
3197 * CHECKBOX
3198 *
3199 * ============================================================================= */
3200NK_API nk_bool nk_check_label(struct nk_context*, const char*, nk_bool active);
3201NK_API nk_bool nk_check_text(struct nk_context*, const char*, int, nk_bool active);
3202NK_API nk_bool nk_check_text_align(struct nk_context*, const char*, int, nk_bool active, nk_flags widget_alignment, nk_flags text_alignment);
3203NK_API unsigned nk_check_flags_label(struct nk_context*, const char*, unsigned int flags, unsigned int value);
3204NK_API unsigned nk_check_flags_text(struct nk_context*, const char*, int, unsigned int flags, unsigned int value);
3205NK_API nk_bool nk_checkbox_label(struct nk_context*, const char*, nk_bool *active);
3206NK_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);
3207NK_API nk_bool nk_checkbox_text(struct nk_context*, const char*, int, nk_bool *active);
3208NK_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);
3209NK_API nk_bool nk_checkbox_flags_label(struct nk_context*, const char*, unsigned int *flags, unsigned int value);
3210NK_API nk_bool nk_checkbox_flags_text(struct nk_context*, const char*, int, unsigned int *flags, unsigned int value);
3211/* =============================================================================
3212 *
3213 * RADIO BUTTON
3214 *
3215 * ============================================================================= */
3216NK_API nk_bool nk_radio_label(struct nk_context*, const char*, nk_bool *active);
3217NK_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);
3218NK_API nk_bool nk_radio_text(struct nk_context*, const char*, int, nk_bool *active);
3219NK_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);
3220NK_API nk_bool nk_option_label(struct nk_context*, const char*, nk_bool active);
3221NK_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);
3222NK_API nk_bool nk_option_text(struct nk_context*, const char*, int, nk_bool active);
3223NK_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);
3224/* =============================================================================
3225 *
3226 * SELECTABLE
3227 *
3228 * ============================================================================= */
3229NK_API nk_bool nk_selectable_label(struct nk_context*, const char*, nk_flags align, nk_bool *value);
3230NK_API nk_bool nk_selectable_text(struct nk_context*, const char*, int, nk_flags align, nk_bool *value);
3231NK_API nk_bool nk_selectable_image_label(struct nk_context*,struct nk_image, const char*, nk_flags align, nk_bool *value);
3232NK_API nk_bool nk_selectable_image_text(struct nk_context*,struct nk_image, const char*, int, nk_flags align, nk_bool *value);
3233NK_API nk_bool nk_selectable_symbol_label(struct nk_context*,enum nk_symbol_type, const char*, nk_flags align, nk_bool *value);
3234NK_API nk_bool nk_selectable_symbol_text(struct nk_context*,enum nk_symbol_type, const char*, int, nk_flags align, nk_bool *value);
3235
3236NK_API nk_bool nk_select_label(struct nk_context*, const char*, nk_flags align, nk_bool value);
3237NK_API nk_bool nk_select_text(struct nk_context*, const char*, int, nk_flags align, nk_bool value);
3238NK_API nk_bool nk_select_image_label(struct nk_context*, struct nk_image,const char*, nk_flags align, nk_bool value);
3239NK_API nk_bool nk_select_image_text(struct nk_context*, struct nk_image,const char*, int, nk_flags align, nk_bool value);
3240NK_API nk_bool nk_select_symbol_label(struct nk_context*,enum nk_symbol_type, const char*, nk_flags align, nk_bool value);
3241NK_API nk_bool nk_select_symbol_text(struct nk_context*,enum nk_symbol_type, const char*, int, nk_flags align, nk_bool value);
3242
3243/* =============================================================================
3244 *
3245 * SLIDER
3246 *
3247 * ============================================================================= */
3248NK_API float nk_slide_float(struct nk_context*, float min, float val, float max, float step);
3249NK_API int nk_slide_int(struct nk_context*, int min, int val, int max, int step);
3250NK_API nk_bool nk_slider_float(struct nk_context*, float min, float *val, float max, float step);
3251NK_API nk_bool nk_slider_int(struct nk_context*, int min, int *val, int max, int step);
3252
3253/* =============================================================================
3254 *
3255 * KNOB
3256 *
3257 * ============================================================================= */
3258NK_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);
3259NK_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);
3260
3261/* =============================================================================
3262 *
3263 * PROGRESSBAR
3264 *
3265 * ============================================================================= */
3266NK_API nk_bool nk_progress(struct nk_context*, nk_size *cur, nk_size max, nk_bool modifyable);
3267NK_API nk_size nk_prog(struct nk_context*, nk_size cur, nk_size max, nk_bool modifyable);
3268
3269/* =============================================================================
3270 *
3271 * COLOR PICKER
3272 *
3273 * ============================================================================= */
3274NK_API struct nk_colorf nk_color_picker(struct nk_context*, struct nk_colorf, enum nk_color_format);
3275NK_API nk_bool nk_color_pick(struct nk_context*, struct nk_colorf*, enum nk_color_format);
3276/* =============================================================================
3277 *
3278 * PROPERTIES
3279 *
3280 * =============================================================================*/
3373NK_API void nk_property_int(struct nk_context*, const char *name, int min, int *val, int max, int step, float inc_per_pixel);
3374
3396NK_API void nk_property_float(struct nk_context*, const char *name, float min, float *val, float max, float step, float inc_per_pixel);
3397
3419NK_API void nk_property_double(struct nk_context*, const char *name, double min, double *val, double max, double step, float inc_per_pixel);
3420
3442NK_API int nk_propertyi(struct nk_context*, const char *name, int min, int val, int max, int step, float inc_per_pixel);
3443
3465NK_API float nk_propertyf(struct nk_context*, const char *name, float min, float val, float max, float step, float inc_per_pixel);
3466
3488NK_API double nk_propertyd(struct nk_context*, const char *name, double min, double val, double max, double step, float inc_per_pixel);
3489
3490/* =============================================================================
3491 *
3492 * TEXT EDIT
3493 *
3494 * ============================================================================= */
3495enum nk_edit_flags {
3496 NK_EDIT_DEFAULT = 0,
3497 NK_EDIT_READ_ONLY = NK_FLAG(0),
3498 NK_EDIT_AUTO_SELECT = NK_FLAG(1),
3499 NK_EDIT_SIG_ENTER = NK_FLAG(2),
3500 NK_EDIT_ALLOW_TAB = NK_FLAG(3),
3501 NK_EDIT_NO_CURSOR = NK_FLAG(4),
3502 NK_EDIT_SELECTABLE = NK_FLAG(5),
3503 NK_EDIT_CLIPBOARD = NK_FLAG(6),
3504 NK_EDIT_CTRL_ENTER_NEWLINE = NK_FLAG(7),
3505 NK_EDIT_NO_HORIZONTAL_SCROLL = NK_FLAG(8),
3506 NK_EDIT_ALWAYS_INSERT_MODE = NK_FLAG(9),
3507 NK_EDIT_MULTILINE = NK_FLAG(10),
3508 NK_EDIT_GOTO_END_ON_ACTIVATE = NK_FLAG(11)
3509};
3510enum nk_edit_types {
3511 NK_EDIT_SIMPLE = NK_EDIT_ALWAYS_INSERT_MODE,
3512 NK_EDIT_FIELD = NK_EDIT_SIMPLE|NK_EDIT_SELECTABLE|NK_EDIT_CLIPBOARD,
3513 NK_EDIT_BOX = NK_EDIT_ALWAYS_INSERT_MODE| NK_EDIT_SELECTABLE| NK_EDIT_MULTILINE|NK_EDIT_ALLOW_TAB|NK_EDIT_CLIPBOARD,
3514 NK_EDIT_EDITOR = NK_EDIT_SELECTABLE|NK_EDIT_MULTILINE|NK_EDIT_ALLOW_TAB| NK_EDIT_CLIPBOARD
3515};
3517 NK_EDIT_ACTIVE = NK_FLAG(0),
3518 NK_EDIT_INACTIVE = NK_FLAG(1),
3519 NK_EDIT_ACTIVATED = NK_FLAG(2),
3520 NK_EDIT_DEACTIVATED = NK_FLAG(3),
3521 NK_EDIT_COMMITED = NK_FLAG(4)
3523NK_API nk_flags nk_edit_string(struct nk_context*, nk_flags, char *buffer, int *len, int max, nk_plugin_filter);
3524NK_API nk_flags nk_edit_string_zero_terminated(struct nk_context*, nk_flags, char *buffer, int max, nk_plugin_filter);
3525NK_API nk_flags nk_edit_buffer(struct nk_context*, nk_flags, struct nk_text_edit*, nk_plugin_filter);
3526NK_API void nk_edit_focus(struct nk_context*, nk_flags flags);
3527NK_API void nk_edit_unfocus(struct nk_context*);
3528/* =============================================================================
3529 *
3530 * CHART
3531 *
3532 * ============================================================================= */
3533NK_API nk_bool nk_chart_begin(struct nk_context*, enum nk_chart_type, int num, float min, float max);
3534NK_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);
3535NK_API void nk_chart_add_slot(struct nk_context *ctx, const enum nk_chart_type, int count, float min_value, float max_value);
3536NK_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);
3537NK_API nk_flags nk_chart_push(struct nk_context*, float);
3538NK_API nk_flags nk_chart_push_slot(struct nk_context*, float, int);
3539NK_API void nk_chart_end(struct nk_context*);
3540NK_API void nk_plot(struct nk_context*, enum nk_chart_type, const float *values, int count, int offset);
3541NK_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);
3542/* =============================================================================
3543 *
3544 * POPUP
3545 *
3546 * ============================================================================= */
3547NK_API nk_bool nk_popup_begin(struct nk_context*, enum nk_popup_type, const char*, nk_flags, struct nk_rect bounds);
3548NK_API void nk_popup_close(struct nk_context*);
3549NK_API void nk_popup_end(struct nk_context*);
3550NK_API void nk_popup_get_scroll(const struct nk_context*, nk_uint *offset_x, nk_uint *offset_y);
3551NK_API void nk_popup_set_scroll(struct nk_context*, nk_uint offset_x, nk_uint offset_y);
3552/* =============================================================================
3553 *
3554 * COMBOBOX
3555 *
3556 * ============================================================================= */
3557NK_API int nk_combo(struct nk_context*, const char *const *items, int count, int selected, int item_height, struct nk_vec2 size);
3558NK_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);
3559NK_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);
3560NK_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);
3561NK_API void nk_combobox(struct nk_context*, const char *const *items, int count, int *selected, int item_height, struct nk_vec2 size);
3562NK_API void nk_combobox_string(struct nk_context*, const char *items_separated_by_zeros, int *selected, int count, int item_height, struct nk_vec2 size);
3563NK_API void 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);
3564NK_API void 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);
3565/* =============================================================================
3566 *
3567 * ABSTRACT COMBOBOX
3568 *
3569 * ============================================================================= */
3570NK_API nk_bool nk_combo_begin_text(struct nk_context*, const char *selected, int, struct nk_vec2 size);
3571NK_API nk_bool nk_combo_begin_label(struct nk_context*, const char *selected, struct nk_vec2 size);
3572NK_API nk_bool nk_combo_begin_color(struct nk_context*, struct nk_color color, struct nk_vec2 size);
3573NK_API nk_bool nk_combo_begin_symbol(struct nk_context*, enum nk_symbol_type, struct nk_vec2 size);
3574NK_API nk_bool nk_combo_begin_symbol_label(struct nk_context*, const char *selected, enum nk_symbol_type, struct nk_vec2 size);
3575NK_API nk_bool nk_combo_begin_symbol_text(struct nk_context*, const char *selected, int, enum nk_symbol_type, struct nk_vec2 size);
3576NK_API nk_bool nk_combo_begin_image(struct nk_context*, struct nk_image img, struct nk_vec2 size);
3577NK_API nk_bool nk_combo_begin_image_label(struct nk_context*, const char *selected, struct nk_image, struct nk_vec2 size);
3578NK_API nk_bool nk_combo_begin_image_text(struct nk_context*, const char *selected, int, struct nk_image, struct nk_vec2 size);
3579NK_API nk_bool nk_combo_item_label(struct nk_context*, const char*, nk_flags alignment);
3580NK_API nk_bool nk_combo_item_text(struct nk_context*, const char*,int, nk_flags alignment);
3581NK_API nk_bool nk_combo_item_image_label(struct nk_context*, struct nk_image, const char*, nk_flags alignment);
3582NK_API nk_bool nk_combo_item_image_text(struct nk_context*, struct nk_image, const char*, int,nk_flags alignment);
3583NK_API nk_bool nk_combo_item_symbol_label(struct nk_context*, enum nk_symbol_type, const char*, nk_flags alignment);
3584NK_API nk_bool nk_combo_item_symbol_text(struct nk_context*, enum nk_symbol_type, const char*, int, nk_flags alignment);
3585NK_API void nk_combo_close(struct nk_context*);
3586NK_API void nk_combo_end(struct nk_context*);
3587/* =============================================================================
3588 *
3589 * CONTEXTUAL
3590 *
3591 * ============================================================================= */
3592NK_API nk_bool nk_contextual_begin(struct nk_context*, nk_flags, struct nk_vec2, struct nk_rect trigger_bounds);
3593NK_API nk_bool nk_contextual_item_text(struct nk_context*, const char*, int,nk_flags align);
3594NK_API nk_bool nk_contextual_item_label(struct nk_context*, const char*, nk_flags align);
3595NK_API nk_bool nk_contextual_item_image_label(struct nk_context*, struct nk_image, const char*, nk_flags alignment);
3596NK_API nk_bool nk_contextual_item_image_text(struct nk_context*, struct nk_image, const char*, int len, nk_flags alignment);
3597NK_API nk_bool nk_contextual_item_symbol_label(struct nk_context*, enum nk_symbol_type, const char*, nk_flags alignment);
3598NK_API nk_bool nk_contextual_item_symbol_text(struct nk_context*, enum nk_symbol_type, const char*, int, nk_flags alignment);
3599NK_API void nk_contextual_close(struct nk_context*);
3600NK_API void nk_contextual_end(struct nk_context*);
3601/* =============================================================================
3602 *
3603 * TOOLTIP
3604 *
3605 * ============================================================================= */
3606NK_API void nk_tooltip(struct nk_context*, const char*);
3607#ifdef NK_INCLUDE_STANDARD_VARARGS
3608NK_API void nk_tooltipf(struct nk_context*, NK_PRINTF_FORMAT_STRING const char*, ...) NK_PRINTF_VARARG_FUNC(2);
3609NK_API void nk_tooltipfv(struct nk_context*, NK_PRINTF_FORMAT_STRING const char*, va_list) NK_PRINTF_VALIST_FUNC(2);
3610#endif
3611NK_API nk_bool nk_tooltip_begin(struct nk_context*, float width);
3612NK_API void nk_tooltip_end(struct nk_context*);
3613/* =============================================================================
3614 *
3615 * MENU
3616 *
3617 * ============================================================================= */
3618NK_API void nk_menubar_begin(struct nk_context*);
3619NK_API void nk_menubar_end(struct nk_context*);
3620NK_API nk_bool nk_menu_begin_text(struct nk_context*, const char* title, int title_len, nk_flags align, struct nk_vec2 size);
3621NK_API nk_bool nk_menu_begin_label(struct nk_context*, const char*, nk_flags align, struct nk_vec2 size);
3622NK_API nk_bool nk_menu_begin_image(struct nk_context*, const char*, struct nk_image, struct nk_vec2 size);
3623NK_API nk_bool nk_menu_begin_image_text(struct nk_context*, const char*, int,nk_flags align,struct nk_image, struct nk_vec2 size);
3624NK_API nk_bool nk_menu_begin_image_label(struct nk_context*, const char*, nk_flags align,struct nk_image, struct nk_vec2 size);
3625NK_API nk_bool nk_menu_begin_symbol(struct nk_context*, const char*, enum nk_symbol_type, struct nk_vec2 size);
3626NK_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);
3627NK_API nk_bool nk_menu_begin_symbol_label(struct nk_context*, const char*, nk_flags align,enum nk_symbol_type, struct nk_vec2 size);
3628NK_API nk_bool nk_menu_item_text(struct nk_context*, const char*, int,nk_flags align);
3629NK_API nk_bool nk_menu_item_label(struct nk_context*, const char*, nk_flags alignment);
3630NK_API nk_bool nk_menu_item_image_label(struct nk_context*, struct nk_image, const char*, nk_flags alignment);
3631NK_API nk_bool nk_menu_item_image_text(struct nk_context*, struct nk_image, const char*, int len, nk_flags alignment);
3632NK_API nk_bool nk_menu_item_symbol_text(struct nk_context*, enum nk_symbol_type, const char*, int, nk_flags alignment);
3633NK_API nk_bool nk_menu_item_symbol_label(struct nk_context*, enum nk_symbol_type, const char*, nk_flags alignment);
3634NK_API void nk_menu_close(struct nk_context*);
3635NK_API void nk_menu_end(struct nk_context*);
3636/* =============================================================================
3637 *
3638 * STYLE
3639 *
3640 * ============================================================================= */
3641
3642#define NK_WIDGET_DISABLED_FACTOR 0.5f
3643
3644enum nk_style_colors {
3645 NK_COLOR_TEXT,
3646 NK_COLOR_WINDOW,
3647 NK_COLOR_HEADER,
3648 NK_COLOR_BORDER,
3649 NK_COLOR_BUTTON,
3650 NK_COLOR_BUTTON_HOVER,
3651 NK_COLOR_BUTTON_ACTIVE,
3652 NK_COLOR_TOGGLE,
3653 NK_COLOR_TOGGLE_HOVER,
3654 NK_COLOR_TOGGLE_CURSOR,
3655 NK_COLOR_SELECT,
3656 NK_COLOR_SELECT_ACTIVE,
3657 NK_COLOR_SLIDER,
3658 NK_COLOR_SLIDER_CURSOR,
3659 NK_COLOR_SLIDER_CURSOR_HOVER,
3660 NK_COLOR_SLIDER_CURSOR_ACTIVE,
3661 NK_COLOR_PROPERTY,
3662 NK_COLOR_EDIT,
3663 NK_COLOR_EDIT_CURSOR,
3664 NK_COLOR_COMBO,
3665 NK_COLOR_CHART,
3666 NK_COLOR_CHART_COLOR,
3667 NK_COLOR_CHART_COLOR_HIGHLIGHT,
3668 NK_COLOR_SCROLLBAR,
3669 NK_COLOR_SCROLLBAR_CURSOR,
3670 NK_COLOR_SCROLLBAR_CURSOR_HOVER,
3671 NK_COLOR_SCROLLBAR_CURSOR_ACTIVE,
3672 NK_COLOR_TAB_HEADER,
3673 NK_COLOR_KNOB,
3674 NK_COLOR_KNOB_CURSOR,
3675 NK_COLOR_KNOB_CURSOR_HOVER,
3676 NK_COLOR_KNOB_CURSOR_ACTIVE,
3677 NK_COLOR_COUNT
3678};
3679enum nk_style_cursor {
3680 NK_CURSOR_ARROW,
3681 NK_CURSOR_TEXT,
3682 NK_CURSOR_MOVE,
3683 NK_CURSOR_RESIZE_VERTICAL,
3684 NK_CURSOR_RESIZE_HORIZONTAL,
3685 NK_CURSOR_RESIZE_TOP_LEFT_DOWN_RIGHT,
3686 NK_CURSOR_RESIZE_TOP_RIGHT_DOWN_LEFT,
3687 NK_CURSOR_COUNT
3688};
3689NK_API void nk_style_default(struct nk_context*);
3690NK_API void nk_style_from_table(struct nk_context*, const struct nk_color*);
3691NK_API void nk_style_load_cursor(struct nk_context*, enum nk_style_cursor, const struct nk_cursor*);
3692NK_API void nk_style_load_all_cursors(struct nk_context*, const struct nk_cursor*);
3693NK_API const char* nk_style_get_color_by_name(enum nk_style_colors);
3694NK_API void nk_style_set_font(struct nk_context*, const struct nk_user_font*);
3695NK_API nk_bool nk_style_set_cursor(struct nk_context*, enum nk_style_cursor);
3696NK_API void nk_style_show_cursor(struct nk_context*);
3697NK_API void nk_style_hide_cursor(struct nk_context*);
3698
3699NK_API nk_bool nk_style_push_font(struct nk_context*, const struct nk_user_font*);
3700NK_API nk_bool nk_style_push_float(struct nk_context*, float*, float);
3701NK_API nk_bool nk_style_push_vec2(struct nk_context*, struct nk_vec2*, struct nk_vec2);
3702NK_API nk_bool nk_style_push_style_item(struct nk_context*, struct nk_style_item*, struct nk_style_item);
3703NK_API nk_bool nk_style_push_flags(struct nk_context*, nk_flags*, nk_flags);
3704NK_API nk_bool nk_style_push_color(struct nk_context*, struct nk_color*, struct nk_color);
3705
3706NK_API nk_bool nk_style_pop_font(struct nk_context*);
3707NK_API nk_bool nk_style_pop_float(struct nk_context*);
3708NK_API nk_bool nk_style_pop_vec2(struct nk_context*);
3709NK_API nk_bool nk_style_pop_style_item(struct nk_context*);
3710NK_API nk_bool nk_style_pop_flags(struct nk_context*);
3711NK_API nk_bool nk_style_pop_color(struct nk_context*);
3712/* =============================================================================
3713 *
3714 * COLOR
3715 *
3716 * ============================================================================= */
3717NK_API struct nk_color nk_rgb(int r, int g, int b);
3718NK_API struct nk_color nk_rgb_iv(const int *rgb);
3719NK_API struct nk_color nk_rgb_bv(const nk_byte* rgb);
3720NK_API struct nk_color nk_rgb_f(float r, float g, float b);
3721NK_API struct nk_color nk_rgb_fv(const float *rgb);
3722NK_API struct nk_color nk_rgb_cf(struct nk_colorf c);
3723NK_API struct nk_color nk_rgb_hex(const char *rgb);
3724NK_API struct nk_color nk_rgb_factor(struct nk_color col, float factor);
3725
3726NK_API struct nk_color nk_rgba(int r, int g, int b, int a);
3727NK_API struct nk_color nk_rgba_u32(nk_uint);
3728NK_API struct nk_color nk_rgba_iv(const int *rgba);
3729NK_API struct nk_color nk_rgba_bv(const nk_byte *rgba);
3730NK_API struct nk_color nk_rgba_f(float r, float g, float b, float a);
3731NK_API struct nk_color nk_rgba_fv(const float *rgba);
3732NK_API struct nk_color nk_rgba_cf(struct nk_colorf c);
3733NK_API struct nk_color nk_rgba_hex(const char *rgb);
3734
3735NK_API struct nk_colorf nk_hsva_colorf(float h, float s, float v, float a);
3736NK_API struct nk_colorf nk_hsva_colorfv(const float *c);
3737NK_API void nk_colorf_hsva_f(float *out_h, float *out_s, float *out_v, float *out_a, struct nk_colorf in);
3738NK_API void nk_colorf_hsva_fv(float *hsva, struct nk_colorf in);
3739
3740NK_API struct nk_color nk_hsv(int h, int s, int v);
3741NK_API struct nk_color nk_hsv_iv(const int *hsv);
3742NK_API struct nk_color nk_hsv_bv(const nk_byte *hsv);
3743NK_API struct nk_color nk_hsv_f(float h, float s, float v);
3744NK_API struct nk_color nk_hsv_fv(const float *hsv);
3745
3746NK_API struct nk_color nk_hsva(int h, int s, int v, int a);
3747NK_API struct nk_color nk_hsva_iv(const int *hsva);
3748NK_API struct nk_color nk_hsva_bv(const nk_byte *hsva);
3749NK_API struct nk_color nk_hsva_f(float h, float s, float v, float a);
3750NK_API struct nk_color nk_hsva_fv(const float *hsva);
3751
3752/* color (conversion nuklear --> user) */
3753NK_API void nk_color_f(float *r, float *g, float *b, float *a, struct nk_color);
3754NK_API void nk_color_fv(float *rgba_out, struct nk_color);
3755NK_API struct nk_colorf nk_color_cf(struct nk_color);
3756NK_API void nk_color_d(double *r, double *g, double *b, double *a, struct nk_color);
3757NK_API void nk_color_dv(double *rgba_out, struct nk_color);
3758
3759NK_API nk_uint nk_color_u32(struct nk_color);
3760NK_API void nk_color_hex_rgba(char *output, struct nk_color);
3761NK_API void nk_color_hex_rgb(char *output, struct nk_color);
3762
3763NK_API void nk_color_hsv_i(int *out_h, int *out_s, int *out_v, struct nk_color);
3764NK_API void nk_color_hsv_b(nk_byte *out_h, nk_byte *out_s, nk_byte *out_v, struct nk_color);
3765NK_API void nk_color_hsv_iv(int *hsv_out, struct nk_color);
3766NK_API void nk_color_hsv_bv(nk_byte *hsv_out, struct nk_color);
3767NK_API void nk_color_hsv_f(float *out_h, float *out_s, float *out_v, struct nk_color);
3768NK_API void nk_color_hsv_fv(float *hsv_out, struct nk_color);
3769
3770NK_API void nk_color_hsva_i(int *h, int *s, int *v, int *a, struct nk_color);
3771NK_API void nk_color_hsva_b(nk_byte *h, nk_byte *s, nk_byte *v, nk_byte *a, struct nk_color);
3772NK_API void nk_color_hsva_iv(int *hsva_out, struct nk_color);
3773NK_API void nk_color_hsva_bv(nk_byte *hsva_out, struct nk_color);
3774NK_API void nk_color_hsva_f(float *out_h, float *out_s, float *out_v, float *out_a, struct nk_color);
3775NK_API void nk_color_hsva_fv(float *hsva_out, struct nk_color);
3776/* =============================================================================
3777 *
3778 * IMAGE
3779 *
3780 * ============================================================================= */
3781NK_API nk_handle nk_handle_ptr(void*);
3782NK_API nk_handle nk_handle_id(int);
3783NK_API struct nk_image nk_image_handle(nk_handle);
3784NK_API struct nk_image nk_image_ptr(void*);
3785NK_API struct nk_image nk_image_id(int);
3786NK_API nk_bool nk_image_is_subimage(const struct nk_image* img);
3787NK_API struct nk_image nk_subimage_ptr(void*, nk_ushort w, nk_ushort h, struct nk_rect sub_region);
3788NK_API struct nk_image nk_subimage_id(int, nk_ushort w, nk_ushort h, struct nk_rect sub_region);
3789NK_API struct nk_image nk_subimage_handle(nk_handle, nk_ushort w, nk_ushort h, struct nk_rect sub_region);
3790/* =============================================================================
3791 *
3792 * 9-SLICE
3793 *
3794 * ============================================================================= */
3795NK_API struct nk_nine_slice nk_nine_slice_handle(nk_handle, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b);
3796NK_API struct nk_nine_slice nk_nine_slice_ptr(void*, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b);
3797NK_API struct nk_nine_slice nk_nine_slice_id(int, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b);
3798NK_API int nk_nine_slice_is_sub9slice(const struct nk_nine_slice* img);
3799NK_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);
3800NK_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);
3801NK_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);
3802/* =============================================================================
3803 *
3804 * MATH
3805 *
3806 * ============================================================================= */
3807NK_API nk_hash nk_murmur_hash(const void *key, int len, nk_hash seed);
3808NK_API void nk_triangle_from_direction(struct nk_vec2 *result, struct nk_rect r, float pad_x, float pad_y, enum nk_heading);
3809
3810NK_API struct nk_vec2 nk_vec2(float x, float y);
3811NK_API struct nk_vec2 nk_vec2i(int x, int y);
3812NK_API struct nk_vec2 nk_vec2v(const float *xy);
3813NK_API struct nk_vec2 nk_vec2iv(const int *xy);
3814
3815NK_API struct nk_rect nk_get_null_rect(void);
3816NK_API struct nk_rect nk_rect(float x, float y, float w, float h);
3817NK_API struct nk_rect nk_recti(int x, int y, int w, int h);
3818NK_API struct nk_rect nk_recta(struct nk_vec2 pos, struct nk_vec2 size);
3819NK_API struct nk_rect nk_rectv(const float *xywh);
3820NK_API struct nk_rect nk_rectiv(const int *xywh);
3821NK_API struct nk_vec2 nk_rect_pos(struct nk_rect);
3822NK_API struct nk_vec2 nk_rect_size(struct nk_rect);
3823/* =============================================================================
3824 *
3825 * STRING
3826 *
3827 * ============================================================================= */
3828NK_API int nk_strlen(const char *str);
3829NK_API int nk_stricmp(const char *s1, const char *s2);
3830NK_API int nk_stricmpn(const char *s1, const char *s2, int n);
3831NK_API int nk_strtoi(const char *str, char **endptr);
3832NK_API float nk_strtof(const char *str, char **endptr);
3833#ifndef NK_STRTOD
3834#define NK_STRTOD nk_strtod
3835#define NK_STRTOD_NEEDED
3836NK_API double nk_strtod(const char *str, char **endptr);
3837#endif
3838NK_API int nk_strfilter(const char *text, const char *regexp);
3839NK_API int nk_strmatch_fuzzy_string(char const *str, char const *pattern, int *out_score);
3840NK_API int nk_strmatch_fuzzy_text(const char *txt, int txt_len, const char *pattern, int *out_score);
3841/* =============================================================================
3842 *
3843 * UTF-8
3844 *
3845 * ============================================================================= */
3846NK_API int nk_utf_decode(const char*, nk_rune*, int);
3847NK_API int nk_utf_encode(nk_rune, char*, int);
3848NK_API int nk_utf_len(const char*, int byte_len);
3849NK_API const char* nk_utf_at(const char *buffer, int length, int index, nk_rune *unicode, int *len);
3850/* ===============================================================
3851 *
3852 * FONT
3853 *
3854 * ===============================================================*/
4007struct nk_user_font_glyph;
4008typedef float(*nk_text_width_f)(nk_handle, float h, const char*, int len);
4009typedef void(*nk_query_font_glyph_f)(nk_handle handle, float font_height,
4010 struct nk_user_font_glyph *glyph,
4011 nk_rune codepoint, nk_rune next_codepoint);
4012
4013#if defined(NK_INCLUDE_VERTEX_BUFFER_OUTPUT) || defined(NK_INCLUDE_SOFTWARE_FONT)
4014struct nk_user_font_glyph {
4015 struct nk_vec2 uv[2];
4016 struct nk_vec2 offset;
4017 float width, height;
4018 float xadvance;
4019};
4020#endif
4021
4023 nk_handle userdata;
4024 float height;
4025 nk_text_width_f width;
4026#ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
4027 nk_query_font_glyph_f query;
4028 nk_handle texture;
4029#endif
4030};
4031
4032#ifdef NK_INCLUDE_FONT_BAKING
4033enum nk_font_coord_type {
4034 NK_COORD_UV,
4035 NK_COORD_PIXEL
4036};
4037
4038struct nk_font;
4039struct nk_baked_font {
4040 float height;
4041 float ascent;
4042 float descent;
4043 nk_rune glyph_offset;
4044 nk_rune glyph_count;
4045 const nk_rune *ranges;
4046};
4047
4048struct nk_font_config {
4049 struct nk_font_config *next;
4050 void *ttf_blob;
4051 nk_size ttf_size;
4053 unsigned char ttf_data_owned_by_atlas;
4054 unsigned char merge_mode;
4055 unsigned char pixel_snap;
4056 unsigned char oversample_v, oversample_h;
4057 unsigned char padding[3];
4058
4059 float size;
4060 enum nk_font_coord_type coord_type;
4061 struct nk_vec2 spacing;
4062 const nk_rune *range;
4063 struct nk_baked_font *font;
4064 nk_rune fallback_glyph;
4065 struct nk_font_config *n;
4066 struct nk_font_config *p;
4067};
4068
4069struct nk_font_glyph {
4070 nk_rune codepoint;
4071 float xadvance;
4072 float x0, y0, x1, y1, w, h;
4073 float u0, v0, u1, v1;
4074};
4075
4076struct nk_font {
4077 struct nk_font *next;
4078 struct nk_user_font handle;
4079 struct nk_baked_font info;
4080 float scale;
4081 struct nk_font_glyph *glyphs;
4082 const struct nk_font_glyph *fallback;
4083 nk_rune fallback_codepoint;
4084 nk_handle texture;
4085 struct nk_font_config *config;
4086};
4087
4088enum nk_font_atlas_format {
4089 NK_FONT_ATLAS_ALPHA8,
4090 NK_FONT_ATLAS_RGBA32
4091};
4092
4093struct nk_font_atlas {
4094 void *pixel;
4095 int tex_width;
4096 int tex_height;
4097
4098 struct nk_allocator permanent;
4099 struct nk_allocator temporary;
4100
4101 struct nk_recti custom;
4102 struct nk_cursor cursors[NK_CURSOR_COUNT];
4103
4104 int glyph_count;
4105 struct nk_font_glyph *glyphs;
4106 struct nk_font *default_font;
4107 struct nk_font *fonts;
4108 struct nk_font_config *config;
4109 int font_num;
4110};
4111
4113NK_API const nk_rune *nk_font_default_glyph_ranges(void);
4114NK_API const nk_rune *nk_font_chinese_glyph_ranges(void);
4115NK_API const nk_rune *nk_font_cyrillic_glyph_ranges(void);
4116NK_API const nk_rune *nk_font_korean_glyph_ranges(void);
4117
4118#ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
4119NK_API void nk_font_atlas_init_default(struct nk_font_atlas*);
4120#endif
4121NK_API void nk_font_atlas_init(struct nk_font_atlas*, const struct nk_allocator*);
4122NK_API void nk_font_atlas_init_custom(struct nk_font_atlas*, const struct nk_allocator *persistent, const struct nk_allocator *transient);
4123NK_API void nk_font_atlas_begin(struct nk_font_atlas*);
4124NK_API struct nk_font_config nk_font_config(float pixel_height);
4125NK_API struct nk_font *nk_font_atlas_add(struct nk_font_atlas*, const struct nk_font_config*);
4126#ifdef NK_INCLUDE_DEFAULT_FONT
4127NK_API struct nk_font* nk_font_atlas_add_default(struct nk_font_atlas*, float height, const struct nk_font_config*);
4128#endif
4129NK_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);
4130#ifdef NK_INCLUDE_STANDARD_IO
4131NK_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*);
4132#endif
4133NK_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*);
4134NK_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);
4135NK_API const void* nk_font_atlas_bake(struct nk_font_atlas*, int *width, int *height, enum nk_font_atlas_format);
4136NK_API void nk_font_atlas_end(struct nk_font_atlas*, nk_handle tex, struct nk_draw_null_texture*);
4137NK_API const struct nk_font_glyph* nk_font_find_glyph(const struct nk_font*, nk_rune unicode);
4138NK_API void nk_font_atlas_cleanup(struct nk_font_atlas *atlas);
4139NK_API void nk_font_atlas_clear(struct nk_font_atlas*);
4140
4141#endif
4142
4143/* ==============================================================
4144 *
4145 * MEMORY BUFFER
4146 *
4147 * ===============================================================*/
4180 void *memory;
4181 unsigned int type;
4182 nk_size size;
4183 nk_size allocated;
4184 nk_size needed;
4185 nk_size calls;
4186};
4187
4188enum nk_allocation_type {
4189 NK_BUFFER_FIXED,
4190 NK_BUFFER_DYNAMIC
4191};
4192
4193enum nk_buffer_allocation_type {
4194 NK_BUFFER_FRONT,
4195 NK_BUFFER_BACK,
4196 NK_BUFFER_MAX
4197};
4198
4200 nk_bool active;
4201 nk_size offset;
4202};
4203
4204struct nk_memory {void *ptr;nk_size size;};
4206 struct nk_buffer_marker marker[NK_BUFFER_MAX];
4208 enum nk_allocation_type type;
4211 nk_size allocated;
4212 nk_size needed;
4213 nk_size calls;
4214 nk_size size;
4215};
4216
4217#ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
4218NK_API void nk_buffer_init_default(struct nk_buffer*);
4219#endif
4220NK_API void nk_buffer_init(struct nk_buffer*, const struct nk_allocator*, nk_size size);
4221NK_API void nk_buffer_init_fixed(struct nk_buffer*, void *memory, nk_size size);
4222NK_API void nk_buffer_info(struct nk_memory_status*, const struct nk_buffer*);
4223NK_API void nk_buffer_push(struct nk_buffer*, enum nk_buffer_allocation_type type, const void *memory, nk_size size, nk_size align);
4224NK_API void nk_buffer_mark(struct nk_buffer*, enum nk_buffer_allocation_type type);
4225NK_API void nk_buffer_reset(struct nk_buffer*, enum nk_buffer_allocation_type type);
4226NK_API void nk_buffer_clear(struct nk_buffer*);
4227NK_API void nk_buffer_free(struct nk_buffer*);
4228NK_API void *nk_buffer_memory(struct nk_buffer*);
4229NK_API const void *nk_buffer_memory_const(const struct nk_buffer*);
4230NK_API nk_size nk_buffer_total(const struct nk_buffer*);
4231
4232/* ==============================================================
4233 *
4234 * STRING
4235 *
4236 * ===============================================================*/
4242struct nk_str {
4243 struct nk_buffer buffer;
4244 int len;
4245};
4246
4247#ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
4248NK_API void nk_str_init_default(struct nk_str*);
4249#endif
4250NK_API void nk_str_init(struct nk_str*, const struct nk_allocator*, nk_size size);
4251NK_API void nk_str_init_fixed(struct nk_str*, void *memory, nk_size size);
4252NK_API void nk_str_clear(struct nk_str*);
4253NK_API void nk_str_free(struct nk_str*);
4254
4255NK_API int nk_str_append_text_char(struct nk_str*, const char*, int);
4256NK_API int nk_str_append_str_char(struct nk_str*, const char*);
4257NK_API int nk_str_append_text_utf8(struct nk_str*, const char*, int);
4258NK_API int nk_str_append_str_utf8(struct nk_str*, const char*);
4259NK_API int nk_str_append_text_runes(struct nk_str*, const nk_rune*, int);
4260NK_API int nk_str_append_str_runes(struct nk_str*, const nk_rune*);
4261
4262NK_API int nk_str_insert_at_char(struct nk_str*, int pos, const char*, int);
4263NK_API int nk_str_insert_at_rune(struct nk_str*, int pos, const char*, int);
4264
4265NK_API int nk_str_insert_text_char(struct nk_str*, int pos, const char*, int);
4266NK_API int nk_str_insert_str_char(struct nk_str*, int pos, const char*);
4267NK_API int nk_str_insert_text_utf8(struct nk_str*, int pos, const char*, int);
4268NK_API int nk_str_insert_str_utf8(struct nk_str*, int pos, const char*);
4269NK_API int nk_str_insert_text_runes(struct nk_str*, int pos, const nk_rune*, int);
4270NK_API int nk_str_insert_str_runes(struct nk_str*, int pos, const nk_rune*);
4271
4272NK_API void nk_str_remove_chars(struct nk_str*, int len);
4273NK_API void nk_str_remove_runes(struct nk_str *str, int len);
4274NK_API void nk_str_delete_chars(struct nk_str*, int pos, int len);
4275NK_API void nk_str_delete_runes(struct nk_str*, int pos, int len);
4276
4277NK_API char *nk_str_at_char(struct nk_str*, int pos);
4278NK_API char *nk_str_at_rune(struct nk_str*, int pos, nk_rune *unicode, int *len);
4279NK_API nk_rune nk_str_rune_at(const struct nk_str*, int pos);
4280NK_API const char *nk_str_at_char_const(const struct nk_str*, int pos);
4281NK_API const char *nk_str_at_const(const struct nk_str*, int pos, nk_rune *unicode, int *len);
4282
4283NK_API char *nk_str_get(struct nk_str*);
4284NK_API const char *nk_str_get_const(const struct nk_str*);
4285NK_API int nk_str_len(const struct nk_str*);
4286NK_API int nk_str_len_char(const struct nk_str*);
4287
4288/* ===============================================================
4289 *
4290 * TEXT EDITOR
4291 *
4292 * ===============================================================*/
4319#ifndef NK_TEXTEDIT_UNDOSTATECOUNT
4320#define NK_TEXTEDIT_UNDOSTATECOUNT 99
4321#endif
4322
4323#ifndef NK_TEXTEDIT_UNDOCHARCOUNT
4324#define NK_TEXTEDIT_UNDOCHARCOUNT 999
4325#endif
4326
4327struct nk_text_edit;
4329 nk_handle userdata;
4330 nk_plugin_paste paste;
4331 nk_plugin_copy copy;
4332};
4333
4335 int where;
4336 short insert_length;
4337 short delete_length;
4338 short char_storage;
4339};
4340
4342 struct nk_text_undo_record undo_rec[NK_TEXTEDIT_UNDOSTATECOUNT];
4343 nk_rune undo_char[NK_TEXTEDIT_UNDOCHARCOUNT];
4344 short undo_point;
4345 short redo_point;
4346 short undo_char_point;
4347 short redo_char_point;
4348};
4349
4350enum nk_text_edit_type {
4351 NK_TEXT_EDIT_SINGLE_LINE,
4352 NK_TEXT_EDIT_MULTI_LINE
4353};
4354
4355enum nk_text_edit_mode {
4356 NK_TEXT_EDIT_MODE_VIEW,
4357 NK_TEXT_EDIT_MODE_INSERT,
4358 NK_TEXT_EDIT_MODE_REPLACE
4359};
4360
4362 struct nk_clipboard clip;
4363 struct nk_str string;
4364 nk_plugin_filter filter;
4365 struct nk_vec2 scrollbar;
4366
4367 int cursor;
4368 int select_start;
4369 int select_end;
4370 unsigned char mode;
4371 unsigned char cursor_at_end_of_line;
4372 unsigned char initialized;
4373 unsigned char has_preferred_x;
4374 unsigned char single_line;
4375 unsigned char active;
4376 unsigned char padding1;
4377 float preferred_x;
4378 struct nk_text_undo_state undo;
4379};
4380
4382NK_API nk_bool nk_filter_default(const struct nk_text_edit*, nk_rune unicode);
4383NK_API nk_bool nk_filter_ascii(const struct nk_text_edit*, nk_rune unicode);
4384NK_API nk_bool nk_filter_float(const struct nk_text_edit*, nk_rune unicode);
4385NK_API nk_bool nk_filter_decimal(const struct nk_text_edit*, nk_rune unicode);
4386NK_API nk_bool nk_filter_hex(const struct nk_text_edit*, nk_rune unicode);
4387NK_API nk_bool nk_filter_oct(const struct nk_text_edit*, nk_rune unicode);
4388NK_API nk_bool nk_filter_binary(const struct nk_text_edit*, nk_rune unicode);
4389
4391#ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
4392NK_API void nk_textedit_init_default(struct nk_text_edit*);
4393#endif
4394NK_API void nk_textedit_init(struct nk_text_edit*, const struct nk_allocator*, nk_size size);
4395NK_API void nk_textedit_init_fixed(struct nk_text_edit*, void *memory, nk_size size);
4396NK_API void nk_textedit_free(struct nk_text_edit*);
4397NK_API void nk_textedit_text(struct nk_text_edit*, const char*, int total_len);
4398NK_API void nk_textedit_delete(struct nk_text_edit*, int where, int len);
4399NK_API void nk_textedit_delete_selection(struct nk_text_edit*);
4400NK_API void nk_textedit_select_all(struct nk_text_edit*);
4401NK_API nk_bool nk_textedit_cut(struct nk_text_edit*);
4402NK_API nk_bool nk_textedit_paste(struct nk_text_edit*, char const*, int len);
4403NK_API void nk_textedit_undo(struct nk_text_edit*);
4404NK_API void nk_textedit_redo(struct nk_text_edit*);
4405
4406/* ===============================================================
4407 *
4408 * DRAWING
4409 *
4410 * ===============================================================*/
4460enum nk_command_type {
4461 NK_COMMAND_NOP,
4462 NK_COMMAND_SCISSOR,
4463 NK_COMMAND_LINE,
4464 NK_COMMAND_CURVE,
4465 NK_COMMAND_RECT,
4466 NK_COMMAND_RECT_FILLED,
4467 NK_COMMAND_RECT_MULTI_COLOR,
4468 NK_COMMAND_CIRCLE,
4469 NK_COMMAND_CIRCLE_FILLED,
4470 NK_COMMAND_ARC,
4471 NK_COMMAND_ARC_FILLED,
4472 NK_COMMAND_TRIANGLE,
4473 NK_COMMAND_TRIANGLE_FILLED,
4474 NK_COMMAND_POLYGON,
4475 NK_COMMAND_POLYGON_FILLED,
4476 NK_COMMAND_POLYLINE,
4477 NK_COMMAND_TEXT,
4478 NK_COMMAND_IMAGE,
4479 NK_COMMAND_CUSTOM
4480};
4481
4484 enum nk_command_type type;
4485 nk_size next;
4486#ifdef NK_INCLUDE_COMMAND_USERDATA
4487 nk_handle userdata;
4488#endif
4489};
4490
4492 struct nk_command header;
4493 short x, y;
4494 unsigned short w, h;
4495};
4496
4498 struct nk_command header;
4499 unsigned short line_thickness;
4500 struct nk_vec2i begin;
4501 struct nk_vec2i end;
4502 struct nk_color color;
4503};
4504
4506 struct nk_command header;
4507 unsigned short line_thickness;
4508 struct nk_vec2i begin;
4509 struct nk_vec2i end;
4510 struct nk_vec2i ctrl[2];
4511 struct nk_color color;
4512};
4513
4515 struct nk_command header;
4516 unsigned short rounding;
4517 unsigned short line_thickness;
4518 short x, y;
4519 unsigned short w, h;
4520 struct nk_color color;
4521};
4522
4524 struct nk_command header;
4525 unsigned short rounding;
4526 short x, y;
4527 unsigned short w, h;
4528 struct nk_color color;
4529};
4530
4532 struct nk_command header;
4533 short x, y;
4534 unsigned short w, h;
4535 struct nk_color left;
4536 struct nk_color top;
4537 struct nk_color bottom;
4538 struct nk_color right;
4539};
4540
4542 struct nk_command header;
4543 unsigned short line_thickness;
4544 struct nk_vec2i a;
4545 struct nk_vec2i b;
4546 struct nk_vec2i c;
4547 struct nk_color color;
4548};
4549
4551 struct nk_command header;
4552 struct nk_vec2i a;
4553 struct nk_vec2i b;
4554 struct nk_vec2i c;
4555 struct nk_color color;
4556};
4557
4559 struct nk_command header;
4560 short x, y;
4561 unsigned short line_thickness;
4562 unsigned short w, h;
4563 struct nk_color color;
4564};
4565
4567 struct nk_command header;
4568 short x, y;
4569 unsigned short w, h;
4570 struct nk_color color;
4571};
4572
4574 struct nk_command header;
4575 short cx, cy;
4576 unsigned short r;
4577 unsigned short line_thickness;
4578 float a[2];
4579 struct nk_color color;
4580};
4581
4583 struct nk_command header;
4584 short cx, cy;
4585 unsigned short r;
4586 float a[2];
4587 struct nk_color color;
4588};
4589
4591 struct nk_command header;
4592 struct nk_color color;
4593 unsigned short line_thickness;
4594 unsigned short point_count;
4595 struct nk_vec2i points[1];
4596};
4597
4599 struct nk_command header;
4600 struct nk_color color;
4601 unsigned short point_count;
4602 struct nk_vec2i points[1];
4603};
4604
4606 struct nk_command header;
4607 struct nk_color color;
4608 unsigned short line_thickness;
4609 unsigned short point_count;
4610 struct nk_vec2i points[1];
4611};
4612
4614 struct nk_command header;
4615 short x, y;
4616 unsigned short w, h;
4617 struct nk_image img;
4618 struct nk_color col;
4619};
4620
4621typedef void (*nk_command_custom_callback)(void *canvas, short x,short y,
4622 unsigned short w, unsigned short h, nk_handle callback_data);
4624 struct nk_command header;
4625 short x, y;
4626 unsigned short w, h;
4627 nk_handle callback_data;
4628 nk_command_custom_callback callback;
4629};
4630
4632 struct nk_command header;
4633 const struct nk_user_font *font;
4634 struct nk_color background;
4635 struct nk_color foreground;
4636 short x, y;
4637 unsigned short w, h;
4638 float height;
4639 int length;
4640 char string[2];
4641};
4642
4643enum nk_command_clipping {
4644 NK_CLIPPING_OFF = nk_false,
4645 NK_CLIPPING_ON = nk_true
4646};
4647
4649 struct nk_buffer *base;
4650 struct nk_rect clip;
4651 int use_clipping;
4652 nk_handle userdata;
4653 nk_size begin, end, last;
4654};
4655
4657NK_API void nk_stroke_line(struct nk_command_buffer *b, float x0, float y0, float x1, float y1, float line_thickness, struct nk_color);
4658NK_API void nk_stroke_curve(struct nk_command_buffer*, float, float, float, float, float, float, float, float, float line_thickness, struct nk_color);
4659NK_API void nk_stroke_rect(struct nk_command_buffer*, struct nk_rect, float rounding, float line_thickness, struct nk_color);
4660NK_API void nk_stroke_circle(struct nk_command_buffer*, struct nk_rect, float line_thickness, struct nk_color);
4661NK_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);
4662NK_API void nk_stroke_triangle(struct nk_command_buffer*, float, float, float, float, float, float, float line_thichness, struct nk_color);
4663NK_API void nk_stroke_polyline(struct nk_command_buffer*, const float *points, int point_count, float line_thickness, struct nk_color col);
4664NK_API void nk_stroke_polygon(struct nk_command_buffer*, const float *points, int point_count, float line_thickness, struct nk_color);
4665
4667NK_API void nk_fill_rect(struct nk_command_buffer*, struct nk_rect, float rounding, struct nk_color);
4668NK_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);
4669NK_API void nk_fill_circle(struct nk_command_buffer*, struct nk_rect, struct nk_color);
4670NK_API void nk_fill_arc(struct nk_command_buffer*, float cx, float cy, float radius, float a_min, float a_max, struct nk_color);
4671NK_API void nk_fill_triangle(struct nk_command_buffer*, float x0, float y0, float x1, float y1, float x2, float y2, struct nk_color);
4672NK_API void nk_fill_polygon(struct nk_command_buffer*, const float *points, int point_count, struct nk_color);
4673
4675NK_API void nk_draw_image(struct nk_command_buffer*, struct nk_rect, const struct nk_image*, struct nk_color);
4676NK_API void nk_draw_nine_slice(struct nk_command_buffer*, struct nk_rect, const struct nk_nine_slice*, struct nk_color);
4677NK_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);
4678NK_API void nk_push_scissor(struct nk_command_buffer*, struct nk_rect);
4679NK_API void nk_push_custom(struct nk_command_buffer*, struct nk_rect, nk_command_custom_callback, nk_handle usr);
4680
4681/* ===============================================================
4682 *
4683 * INPUT
4684 *
4685 * ===============================================================*/
4687 nk_bool down;
4688 unsigned int clicked;
4689 struct nk_vec2 clicked_pos;
4690};
4691struct nk_mouse {
4692 struct nk_mouse_button buttons[NK_BUTTON_MAX];
4693 struct nk_vec2 pos;
4694#ifdef NK_BUTTON_TRIGGER_ON_RELEASE
4695 struct nk_vec2 down_pos;
4696#endif
4697 struct nk_vec2 prev;
4698 struct nk_vec2 delta;
4699 struct nk_vec2 scroll_delta;
4700 unsigned char grab;
4701 unsigned char grabbed;
4702 unsigned char ungrab;
4703};
4704
4705struct nk_key {
4706 nk_bool down;
4707 unsigned int clicked;
4708};
4710 struct nk_key keys[NK_KEY_MAX];
4711 char text[NK_INPUT_MAX];
4712 int text_len;
4713};
4714
4715struct nk_input {
4716 struct nk_keyboard keyboard;
4717 struct nk_mouse mouse;
4718};
4719
4720NK_API nk_bool nk_input_has_mouse_click(const struct nk_input*, enum nk_buttons);
4721NK_API nk_bool nk_input_has_mouse_click_in_rect(const struct nk_input*, enum nk_buttons, struct nk_rect);
4722NK_API nk_bool nk_input_has_mouse_click_in_button_rect(const struct nk_input*, enum nk_buttons, struct nk_rect);
4723NK_API nk_bool nk_input_has_mouse_click_down_in_rect(const struct nk_input*, enum nk_buttons, struct nk_rect, nk_bool down);
4724NK_API nk_bool nk_input_is_mouse_click_in_rect(const struct nk_input*, enum nk_buttons, struct nk_rect);
4725NK_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);
4726NK_API nk_bool nk_input_any_mouse_click_in_rect(const struct nk_input*, struct nk_rect);
4727NK_API nk_bool nk_input_is_mouse_prev_hovering_rect(const struct nk_input*, struct nk_rect);
4728NK_API nk_bool nk_input_is_mouse_hovering_rect(const struct nk_input*, struct nk_rect);
4729NK_API nk_bool nk_input_is_mouse_moved(const struct nk_input*);
4730NK_API nk_bool nk_input_mouse_clicked(const struct nk_input*, enum nk_buttons, struct nk_rect);
4731NK_API nk_bool nk_input_is_mouse_down(const struct nk_input*, enum nk_buttons);
4732NK_API nk_bool nk_input_is_mouse_pressed(const struct nk_input*, enum nk_buttons);
4733NK_API nk_bool nk_input_is_mouse_released(const struct nk_input*, enum nk_buttons);
4734NK_API nk_bool nk_input_is_key_pressed(const struct nk_input*, enum nk_keys);
4735NK_API nk_bool nk_input_is_key_released(const struct nk_input*, enum nk_keys);
4736NK_API nk_bool nk_input_is_key_down(const struct nk_input*, enum nk_keys);
4737
4738/* ===============================================================
4739 *
4740 * DRAW LIST
4741 *
4742 * ===============================================================*/
4743#ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
4760#ifdef NK_UINT_DRAW_INDEX
4761typedef nk_uint nk_draw_index;
4762#else
4763typedef nk_ushort nk_draw_index;
4764#endif
4765enum nk_draw_list_stroke {
4766 NK_STROKE_OPEN = nk_false, /***< build up path has no connection back to the beginning */
4767 NK_STROKE_CLOSED = nk_true /***< build up path has a connection back to the beginning */
4768};
4769
4770enum nk_draw_vertex_layout_attribute {
4771 NK_VERTEX_POSITION,
4772 NK_VERTEX_COLOR,
4773 NK_VERTEX_TEXCOORD,
4774 NK_VERTEX_ATTRIBUTE_COUNT
4775};
4776
4777enum nk_draw_vertex_layout_format {
4778 NK_FORMAT_SCHAR,
4779 NK_FORMAT_SSHORT,
4780 NK_FORMAT_SINT,
4781 NK_FORMAT_UCHAR,
4782 NK_FORMAT_USHORT,
4783 NK_FORMAT_UINT,
4784 NK_FORMAT_FLOAT,
4785 NK_FORMAT_DOUBLE,
4786
4787NK_FORMAT_COLOR_BEGIN,
4788 NK_FORMAT_R8G8B8 = NK_FORMAT_COLOR_BEGIN,
4789 NK_FORMAT_R16G15B16,
4790 NK_FORMAT_R32G32B32,
4791
4792 NK_FORMAT_R8G8B8A8,
4793 NK_FORMAT_B8G8R8A8,
4794 NK_FORMAT_R16G15B16A16,
4795 NK_FORMAT_R32G32B32A32,
4796 NK_FORMAT_R32G32B32A32_FLOAT,
4797 NK_FORMAT_R32G32B32A32_DOUBLE,
4798
4799 NK_FORMAT_RGB32,
4800 NK_FORMAT_RGBA32,
4801NK_FORMAT_COLOR_END = NK_FORMAT_RGBA32,
4802 NK_FORMAT_COUNT
4803};
4804
4805#define NK_VERTEX_LAYOUT_END NK_VERTEX_ATTRIBUTE_COUNT,NK_FORMAT_COUNT,0
4806struct nk_draw_vertex_layout_element {
4807 enum nk_draw_vertex_layout_attribute attribute;
4808 enum nk_draw_vertex_layout_format format;
4809 nk_size offset;
4810};
4811
4812struct nk_draw_command {
4813 unsigned int elem_count;
4814 struct nk_rect clip_rect;
4815 nk_handle texture;
4816#ifdef NK_INCLUDE_COMMAND_USERDATA
4817 nk_handle userdata;
4818#endif
4819};
4820
4821struct nk_draw_list {
4822 struct nk_rect clip_rect;
4823 struct nk_vec2 circle_vtx[12];
4824 struct nk_convert_config config;
4825
4826 struct nk_buffer *buffer;
4827 struct nk_buffer *vertices;
4828 struct nk_buffer *elements;
4829
4830 unsigned int element_count;
4831 unsigned int vertex_count;
4832 unsigned int cmd_count;
4833 nk_size cmd_offset;
4834
4835 unsigned int path_count;
4836 unsigned int path_offset;
4837
4838 enum nk_anti_aliasing line_AA;
4839 enum nk_anti_aliasing shape_AA;
4840
4841#ifdef NK_INCLUDE_COMMAND_USERDATA
4842 nk_handle userdata;
4843#endif
4844};
4845
4846/* draw list */
4847NK_API void nk_draw_list_init(struct nk_draw_list*);
4848NK_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);
4849
4850/* drawing */
4851#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))
4852NK_API const struct nk_draw_command* nk__draw_list_begin(const struct nk_draw_list*, const struct nk_buffer*);
4853NK_API const struct nk_draw_command* nk__draw_list_next(const struct nk_draw_command*, const struct nk_buffer*, const struct nk_draw_list*);
4854NK_API const struct nk_draw_command* nk__draw_list_end(const struct nk_draw_list*, const struct nk_buffer*);
4855
4856/* path */
4857NK_API void nk_draw_list_path_clear(struct nk_draw_list*);
4858NK_API void nk_draw_list_path_line_to(struct nk_draw_list*, struct nk_vec2 pos);
4859NK_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);
4860NK_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);
4861NK_API void nk_draw_list_path_rect_to(struct nk_draw_list*, struct nk_vec2 a, struct nk_vec2 b, float rounding);
4862NK_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);
4863NK_API void nk_draw_list_path_fill(struct nk_draw_list*, struct nk_color);
4864NK_API void nk_draw_list_path_stroke(struct nk_draw_list*, struct nk_color, enum nk_draw_list_stroke closed, float thickness);
4865
4866/* stroke */
4867NK_API void nk_draw_list_stroke_line(struct nk_draw_list*, struct nk_vec2 a, struct nk_vec2 b, struct nk_color, float thickness);
4868NK_API void nk_draw_list_stroke_rect(struct nk_draw_list*, struct nk_rect rect, struct nk_color, float rounding, float thickness);
4869NK_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);
4870NK_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);
4871NK_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);
4872NK_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);
4873
4874/* fill */
4875NK_API void nk_draw_list_fill_rect(struct nk_draw_list*, struct nk_rect rect, struct nk_color, float rounding);
4876NK_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);
4877NK_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);
4878NK_API void nk_draw_list_fill_circle(struct nk_draw_list*, struct nk_vec2 center, float radius, struct nk_color col, unsigned int segs);
4879NK_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);
4880
4881/* misc */
4882NK_API void nk_draw_list_add_image(struct nk_draw_list*, struct nk_image texture, struct nk_rect rect, struct nk_color);
4883NK_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);
4884#ifdef NK_INCLUDE_COMMAND_USERDATA
4885NK_API void nk_draw_list_push_userdata(struct nk_draw_list*, nk_handle userdata);
4886#endif
4887
4888#endif
4889
4890/* ===============================================================
4891 *
4892 * GUI
4893 *
4894 * ===============================================================*/
4895enum nk_style_item_type {
4896 NK_STYLE_ITEM_COLOR,
4897 NK_STYLE_ITEM_IMAGE,
4898 NK_STYLE_ITEM_NINE_SLICE
4899};
4900
4902 struct nk_color color;
4903 struct nk_image image;
4904 struct nk_nine_slice slice;
4905};
4906
4908 enum nk_style_item_type type;
4909 union nk_style_item_data data;
4910};
4911
4913 struct nk_color color;
4914 struct nk_vec2 padding;
4915 float color_factor;
4916 float disabled_factor;
4917};
4918
4920 /* background */
4921 struct nk_style_item normal;
4922 struct nk_style_item hover;
4923 struct nk_style_item active;
4924 struct nk_color border_color;
4925 float color_factor_background;
4926
4927 /* text */
4928 struct nk_color text_background;
4929 struct nk_color text_normal;
4930 struct nk_color text_hover;
4931 struct nk_color text_active;
4932 nk_flags text_alignment;
4933 float color_factor_text;
4934
4935 /* properties */
4936 float border;
4937 float rounding;
4938 struct nk_vec2 padding;
4939 struct nk_vec2 image_padding;
4940 struct nk_vec2 touch_padding;
4941 float disabled_factor;
4942
4943 /* optional user callbacks */
4944 nk_handle userdata;
4945 void(*draw_begin)(struct nk_command_buffer*, nk_handle userdata);
4946 void(*draw_end)(struct nk_command_buffer*, nk_handle userdata);
4947};
4948
4950 /* background */
4951 struct nk_style_item normal;
4952 struct nk_style_item hover;
4953 struct nk_style_item active;
4954 struct nk_color border_color;
4955
4956 /* cursor */
4957 struct nk_style_item cursor_normal;
4958 struct nk_style_item cursor_hover;
4959
4960 /* text */
4961 struct nk_color text_normal;
4962 struct nk_color text_hover;
4963 struct nk_color text_active;
4964 struct nk_color text_background;
4965 nk_flags text_alignment;
4966
4967 /* properties */
4968 struct nk_vec2 padding;
4969 struct nk_vec2 touch_padding;
4970 float spacing;
4971 float border;
4972 float color_factor;
4973 float disabled_factor;
4974
4975 /* optional user callbacks */
4976 nk_handle userdata;
4977 void(*draw_begin)(struct nk_command_buffer*, nk_handle);
4978 void(*draw_end)(struct nk_command_buffer*, nk_handle);
4979};
4980
4982 /* background (inactive) */
4983 struct nk_style_item normal;
4984 struct nk_style_item hover;
4985 struct nk_style_item pressed;
4986
4987 /* background (active) */
4988 struct nk_style_item normal_active;
4989 struct nk_style_item hover_active;
4990 struct nk_style_item pressed_active;
4991
4992 /* text color (inactive) */
4993 struct nk_color text_normal;
4994 struct nk_color text_hover;
4995 struct nk_color text_pressed;
4996
4997 /* text color (active) */
4998 struct nk_color text_normal_active;
4999 struct nk_color text_hover_active;
5000 struct nk_color text_pressed_active;
5001 struct nk_color text_background;
5002 nk_flags text_alignment;
5003
5004 /* properties */
5005 float rounding;
5006 struct nk_vec2 padding;
5007 struct nk_vec2 touch_padding;
5008 struct nk_vec2 image_padding;
5009 float color_factor;
5010 float disabled_factor;
5011
5012 /* optional user callbacks */
5013 nk_handle userdata;
5014 void(*draw_begin)(struct nk_command_buffer*, nk_handle);
5015 void(*draw_end)(struct nk_command_buffer*, nk_handle);
5016};
5017
5019 /* background */
5020 struct nk_style_item normal;
5021 struct nk_style_item hover;
5022 struct nk_style_item active;
5023 struct nk_color border_color;
5024
5025 /* background bar */
5026 struct nk_color bar_normal;
5027 struct nk_color bar_hover;
5028 struct nk_color bar_active;
5029 struct nk_color bar_filled;
5030
5031 /* cursor */
5032 struct nk_style_item cursor_normal;
5033 struct nk_style_item cursor_hover;
5034 struct nk_style_item cursor_active;
5035
5036 /* properties */
5037 float border;
5038 float rounding;
5039 float bar_height;
5040 struct nk_vec2 padding;
5041 struct nk_vec2 spacing;
5042 struct nk_vec2 cursor_size;
5043 float color_factor;
5044 float disabled_factor;
5045
5046 /* optional buttons */
5047 int show_buttons;
5048 struct nk_style_button inc_button;
5049 struct nk_style_button dec_button;
5050 enum nk_symbol_type inc_symbol;
5051 enum nk_symbol_type dec_symbol;
5052
5053 /* optional user callbacks */
5054 nk_handle userdata;
5055 void(*draw_begin)(struct nk_command_buffer*, nk_handle);
5056 void(*draw_end)(struct nk_command_buffer*, nk_handle);
5057};
5058
5060 /* background */
5061 struct nk_style_item normal;
5062 struct nk_style_item hover;
5063 struct nk_style_item active;
5064 struct nk_color border_color;
5065
5066 /* knob */
5067 struct nk_color knob_normal;
5068 struct nk_color knob_hover;
5069 struct nk_color knob_active;
5070 struct nk_color knob_border_color;
5071
5072 /* cursor */
5073 struct nk_color cursor_normal;
5074 struct nk_color cursor_hover;
5075 struct nk_color cursor_active;
5076
5077 /* properties */
5078 float border;
5079 float knob_border;
5080 struct nk_vec2 padding;
5081 struct nk_vec2 spacing;
5082 float cursor_width;
5083 float color_factor;
5084 float disabled_factor;
5085
5086 /* optional user callbacks */
5087 nk_handle userdata;
5088 void(*draw_begin)(struct nk_command_buffer*, nk_handle);
5089 void(*draw_end)(struct nk_command_buffer*, nk_handle);
5090};
5091
5093 /* background */
5094 struct nk_style_item normal;
5095 struct nk_style_item hover;
5096 struct nk_style_item active;
5097 struct nk_color border_color;
5098
5099 /* cursor */
5100 struct nk_style_item cursor_normal;
5101 struct nk_style_item cursor_hover;
5102 struct nk_style_item cursor_active;
5103 struct nk_color cursor_border_color;
5104
5105 /* properties */
5106 float rounding;
5107 float border;
5108 float cursor_border;
5109 float cursor_rounding;
5110 struct nk_vec2 padding;
5111 float color_factor;
5112 float disabled_factor;
5113
5114 /* optional user callbacks */
5115 nk_handle userdata;
5116 void(*draw_begin)(struct nk_command_buffer*, nk_handle);
5117 void(*draw_end)(struct nk_command_buffer*, nk_handle);
5118};
5119
5121 /* background */
5122 struct nk_style_item normal;
5123 struct nk_style_item hover;
5124 struct nk_style_item active;
5125 struct nk_color border_color;
5126
5127 /* cursor */
5128 struct nk_style_item cursor_normal;
5129 struct nk_style_item cursor_hover;
5130 struct nk_style_item cursor_active;
5131 struct nk_color cursor_border_color;
5132
5133 /* properties */
5134 float border;
5135 float rounding;
5136 float border_cursor;
5137 float rounding_cursor;
5138 struct nk_vec2 padding;
5139 float color_factor;
5140 float disabled_factor;
5141
5142 /* optional buttons */
5143 int show_buttons;
5144 struct nk_style_button inc_button;
5145 struct nk_style_button dec_button;
5146 enum nk_symbol_type inc_symbol;
5147 enum nk_symbol_type dec_symbol;
5148
5149 /* optional user callbacks */
5150 nk_handle userdata;
5151 void(*draw_begin)(struct nk_command_buffer*, nk_handle);
5152 void(*draw_end)(struct nk_command_buffer*, nk_handle);
5153};
5154
5156 /* background */
5157 struct nk_style_item normal;
5158 struct nk_style_item hover;
5159 struct nk_style_item active;
5160 struct nk_color border_color;
5161 struct nk_style_scrollbar scrollbar;
5162
5163 /* cursor */
5164 struct nk_color cursor_normal;
5165 struct nk_color cursor_hover;
5166 struct nk_color cursor_text_normal;
5167 struct nk_color cursor_text_hover;
5168
5169 /* text (unselected) */
5170 struct nk_color text_normal;
5171 struct nk_color text_hover;
5172 struct nk_color text_active;
5173
5174 /* text (selected) */
5175 struct nk_color selected_normal;
5176 struct nk_color selected_hover;
5177 struct nk_color selected_text_normal;
5178 struct nk_color selected_text_hover;
5179
5180 /* properties */
5181 float border;
5182 float rounding;
5183 float cursor_size;
5184 struct nk_vec2 scrollbar_size;
5185 struct nk_vec2 padding;
5186 float row_padding;
5187 float color_factor;
5188 float disabled_factor;
5189};
5190
5192 /* background */
5193 struct nk_style_item normal;
5194 struct nk_style_item hover;
5195 struct nk_style_item active;
5196 struct nk_color border_color;
5197
5198 /* text */
5199 struct nk_color label_normal;
5200 struct nk_color label_hover;
5201 struct nk_color label_active;
5202
5203 /* symbols */
5204 enum nk_symbol_type sym_left;
5205 enum nk_symbol_type sym_right;
5206
5207 /* properties */
5208 float border;
5209 float rounding;
5210 struct nk_vec2 padding;
5211 float color_factor;
5212 float disabled_factor;
5213
5214 struct nk_style_edit edit;
5215 struct nk_style_button inc_button;
5216 struct nk_style_button dec_button;
5217
5218 /* optional user callbacks */
5219 nk_handle userdata;
5220 void(*draw_begin)(struct nk_command_buffer*, nk_handle);
5221 void(*draw_end)(struct nk_command_buffer*, nk_handle);
5222};
5223
5225 /* colors */
5226 struct nk_style_item background;
5227 struct nk_color border_color;
5228 struct nk_color selected_color;
5229 struct nk_color color;
5230
5231 /* properties */
5232 float border;
5233 float rounding;
5234 struct nk_vec2 padding;
5235 float color_factor;
5236 float disabled_factor;
5237 nk_bool show_markers;
5238};
5239
5241 /* background */
5242 struct nk_style_item normal;
5243 struct nk_style_item hover;
5244 struct nk_style_item active;
5245 struct nk_color border_color;
5246
5247 /* label */
5248 struct nk_color label_normal;
5249 struct nk_color label_hover;
5250 struct nk_color label_active;
5251
5252 /* symbol */
5253 struct nk_color symbol_normal;
5254 struct nk_color symbol_hover;
5255 struct nk_color symbol_active;
5256
5257 /* button */
5258 struct nk_style_button button;
5259 enum nk_symbol_type sym_normal;
5260 enum nk_symbol_type sym_hover;
5261 enum nk_symbol_type sym_active;
5262
5263 /* properties */
5264 float border;
5265 float rounding;
5266 struct nk_vec2 content_padding;
5267 struct nk_vec2 button_padding;
5268 struct nk_vec2 spacing;
5269 float color_factor;
5270 float disabled_factor;
5271};
5272
5274 /* background */
5275 struct nk_style_item background;
5276 struct nk_color border_color;
5277 struct nk_color text;
5278
5279 /* button */
5280 struct nk_style_button tab_maximize_button;
5281 struct nk_style_button tab_minimize_button;
5282 struct nk_style_button node_maximize_button;
5283 struct nk_style_button node_minimize_button;
5284 enum nk_symbol_type sym_minimize;
5285 enum nk_symbol_type sym_maximize;
5286
5287 /* properties */
5288 float border;
5289 float rounding;
5290 float indent;
5291 struct nk_vec2 padding;
5292 struct nk_vec2 spacing;
5293 float color_factor;
5294 float disabled_factor;
5295};
5296
5297enum nk_style_header_align {
5298 NK_HEADER_LEFT,
5299 NK_HEADER_RIGHT
5300};
5302 /* background */
5303 struct nk_style_item normal;
5304 struct nk_style_item hover;
5305 struct nk_style_item active;
5306
5307 /* button */
5308 struct nk_style_button close_button;
5309 struct nk_style_button minimize_button;
5310 enum nk_symbol_type close_symbol;
5311 enum nk_symbol_type minimize_symbol;
5312 enum nk_symbol_type maximize_symbol;
5313
5314 /* title */
5315 struct nk_color label_normal;
5316 struct nk_color label_hover;
5317 struct nk_color label_active;
5318
5319 /* properties */
5320 enum nk_style_header_align align;
5321 struct nk_vec2 padding;
5322 struct nk_vec2 label_padding;
5323 struct nk_vec2 spacing;
5324};
5325
5327 struct nk_style_window_header header;
5328 struct nk_style_item fixed_background;
5329 struct nk_color background;
5330
5331 struct nk_color border_color;
5332 struct nk_color popup_border_color;
5333 struct nk_color combo_border_color;
5334 struct nk_color contextual_border_color;
5335 struct nk_color menu_border_color;
5336 struct nk_color group_border_color;
5337 struct nk_color tooltip_border_color;
5338 struct nk_style_item scaler;
5339
5340 float border;
5341 float combo_border;
5342 float contextual_border;
5343 float menu_border;
5344 float group_border;
5345 float tooltip_border;
5346 float popup_border;
5347 float min_row_height_padding;
5348
5349 float rounding;
5350 struct nk_vec2 spacing;
5351 struct nk_vec2 scrollbar_size;
5352 struct nk_vec2 min_size;
5353
5354 struct nk_vec2 padding;
5355 struct nk_vec2 group_padding;
5356 struct nk_vec2 popup_padding;
5357 struct nk_vec2 combo_padding;
5358 struct nk_vec2 contextual_padding;
5359 struct nk_vec2 menu_padding;
5360 struct nk_vec2 tooltip_padding;
5361};
5362
5363struct nk_style {
5364 const struct nk_user_font *font;
5365 const struct nk_cursor *cursors[NK_CURSOR_COUNT];
5366 const struct nk_cursor *cursor_active;
5367 struct nk_cursor *cursor_last;
5368 int cursor_visible;
5369
5370 struct nk_style_text text;
5371 struct nk_style_button button;
5372 struct nk_style_button contextual_button;
5373 struct nk_style_button menu_button;
5374 struct nk_style_toggle option;
5375 struct nk_style_toggle checkbox;
5376 struct nk_style_selectable selectable;
5377 struct nk_style_slider slider;
5378 struct nk_style_knob knob;
5379 struct nk_style_progress progress;
5380 struct nk_style_property property;
5381 struct nk_style_edit edit;
5382 struct nk_style_chart chart;
5383 struct nk_style_scrollbar scrollh;
5384 struct nk_style_scrollbar scrollv;
5385 struct nk_style_tab tab;
5386 struct nk_style_combo combo;
5387 struct nk_style_window window;
5388};
5389
5390NK_API struct nk_style_item nk_style_item_color(struct nk_color);
5391NK_API struct nk_style_item nk_style_item_image(struct nk_image img);
5392NK_API struct nk_style_item nk_style_item_nine_slice(struct nk_nine_slice slice);
5393NK_API struct nk_style_item nk_style_item_hide(void);
5394
5395/*==============================================================
5396 * PANEL
5397 * =============================================================*/
5398#ifndef NK_MAX_LAYOUT_ROW_TEMPLATE_COLUMNS
5399#define NK_MAX_LAYOUT_ROW_TEMPLATE_COLUMNS 16
5400#endif
5401#ifndef NK_CHART_MAX_SLOT
5402#define NK_CHART_MAX_SLOT 4
5403#endif
5404
5405enum nk_panel_type {
5406 NK_PANEL_NONE = 0,
5407 NK_PANEL_WINDOW = NK_FLAG(0),
5408 NK_PANEL_GROUP = NK_FLAG(1),
5409 NK_PANEL_POPUP = NK_FLAG(2),
5410 NK_PANEL_CONTEXTUAL = NK_FLAG(4),
5411 NK_PANEL_COMBO = NK_FLAG(5),
5412 NK_PANEL_MENU = NK_FLAG(6),
5413 NK_PANEL_TOOLTIP = NK_FLAG(7)
5414};
5415enum nk_panel_set {
5416 NK_PANEL_SET_NONBLOCK = NK_PANEL_CONTEXTUAL|NK_PANEL_COMBO|NK_PANEL_MENU|NK_PANEL_TOOLTIP,
5417 NK_PANEL_SET_POPUP = NK_PANEL_SET_NONBLOCK|NK_PANEL_POPUP,
5418 NK_PANEL_SET_SUB = NK_PANEL_SET_POPUP|NK_PANEL_GROUP
5419};
5420
5422 enum nk_chart_type type;
5423 struct nk_color color;
5424 struct nk_color highlight;
5425 float min, max, range;
5426 int count;
5427 struct nk_vec2 last;
5428 int index;
5429 nk_bool show_markers;
5430};
5431
5432struct nk_chart {
5433 int slot;
5434 float x, y, w, h;
5435 struct nk_chart_slot slots[NK_CHART_MAX_SLOT];
5436};
5437
5438enum nk_panel_row_layout_type {
5439 NK_LAYOUT_DYNAMIC_FIXED = 0,
5440 NK_LAYOUT_DYNAMIC_ROW,
5441 NK_LAYOUT_DYNAMIC_FREE,
5442 NK_LAYOUT_DYNAMIC,
5443 NK_LAYOUT_STATIC_FIXED,
5444 NK_LAYOUT_STATIC_ROW,
5445 NK_LAYOUT_STATIC_FREE,
5446 NK_LAYOUT_STATIC,
5447 NK_LAYOUT_TEMPLATE,
5448 NK_LAYOUT_COUNT
5449};
5451 enum nk_panel_row_layout_type type;
5452 int index;
5453 float height;
5454 float min_height;
5455 int columns;
5456 const float *ratio;
5457 float item_width;
5458 float item_height;
5459 float item_offset;
5460 float filled;
5461 struct nk_rect item;
5462 int tree_depth;
5463 float templates[NK_MAX_LAYOUT_ROW_TEMPLATE_COLUMNS];
5464};
5465
5467 nk_size begin;
5468 nk_size parent;
5469 nk_size last;
5470 nk_size end;
5471 nk_bool active;
5472};
5473
5475 float x, y, w, h;
5476 struct nk_scroll offset;
5477};
5478
5479struct nk_panel {
5480 enum nk_panel_type type;
5481 nk_flags flags;
5482 struct nk_rect bounds;
5483 nk_uint *offset_x;
5484 nk_uint *offset_y;
5485 float at_x, at_y, max_x;
5486 float footer_height;
5487 float header_height;
5488 float border;
5489 unsigned int has_scrolling;
5490 struct nk_rect clip;
5491 struct nk_menu_state menu;
5492 struct nk_row_layout row;
5493 struct nk_chart chart;
5494 struct nk_command_buffer *buffer;
5495 struct nk_panel *parent;
5496};
5497
5498/*==============================================================
5499 * WINDOW
5500 * =============================================================*/
5501#ifndef NK_WINDOW_MAX_NAME
5502#define NK_WINDOW_MAX_NAME 64
5503#endif
5504
5505struct nk_table;
5507 NK_WINDOW_PRIVATE = NK_FLAG(11),
5508 NK_WINDOW_DYNAMIC = NK_WINDOW_PRIVATE,
5509 NK_WINDOW_ROM = NK_FLAG(12),
5511 NK_WINDOW_HIDDEN = NK_FLAG(13),
5512 NK_WINDOW_CLOSED = NK_FLAG(14),
5513 NK_WINDOW_MINIMIZED = NK_FLAG(15),
5514 NK_WINDOW_REMOVE_ROM = NK_FLAG(16)
5516
5518 struct nk_window *win;
5519 enum nk_panel_type type;
5520 struct nk_popup_buffer buf;
5521 nk_hash name;
5522 nk_bool active;
5523 unsigned combo_count;
5524 unsigned con_count, con_old;
5525 unsigned active_con;
5526 struct nk_rect header;
5527};
5528
5530 nk_hash name;
5531 unsigned int seq;
5532 unsigned int old;
5533 int active, prev;
5534 int cursor;
5535 int sel_start;
5536 int sel_end;
5537 struct nk_scroll scrollbar;
5538 unsigned char mode;
5539 unsigned char single_line;
5540};
5541
5543 int active, prev;
5544 char buffer[NK_MAX_NUMBER_BUFFER];
5545 int length;
5546 int cursor;
5547 int select_start;
5548 int select_end;
5549 nk_hash name;
5550 unsigned int seq;
5551 unsigned int old;
5552 int state;
5553 int prev_state;
5554 nk_hash prev_name;
5555 char prev_buffer[NK_MAX_NUMBER_BUFFER];
5556 int prev_length;
5557};
5558
5560 unsigned int seq;
5561 nk_hash name;
5562 char name_string[NK_WINDOW_MAX_NAME];
5563 nk_flags flags;
5564
5565 struct nk_rect bounds;
5566 struct nk_scroll scrollbar;
5567 struct nk_command_buffer buffer;
5568 struct nk_panel *layout;
5569 float scrollbar_hiding_timer;
5570
5571 /* persistent widget state */
5572 struct nk_property_state property;
5573 struct nk_popup_state popup;
5574 struct nk_edit_state edit;
5575 unsigned int scrolled;
5576 nk_bool widgets_disabled;
5577
5578 struct nk_table *tables;
5579 unsigned int table_count;
5580
5581 /* window list hooks */
5582 struct nk_window *next;
5583 struct nk_window *prev;
5584 struct nk_window *parent;
5585};
5586
5587/*==============================================================
5588 * STACK
5589 * =============================================================*/
5615#ifndef NK_BUTTON_BEHAVIOR_STACK_SIZE
5616#define NK_BUTTON_BEHAVIOR_STACK_SIZE 8
5617#endif
5618
5619#ifndef NK_FONT_STACK_SIZE
5620#define NK_FONT_STACK_SIZE 8
5621#endif
5622
5623#ifndef NK_STYLE_ITEM_STACK_SIZE
5624#define NK_STYLE_ITEM_STACK_SIZE 16
5625#endif
5626
5627#ifndef NK_FLOAT_STACK_SIZE
5628#define NK_FLOAT_STACK_SIZE 32
5629#endif
5630
5631#ifndef NK_VECTOR_STACK_SIZE
5632#define NK_VECTOR_STACK_SIZE 16
5633#endif
5634
5635#ifndef NK_FLAGS_STACK_SIZE
5636#define NK_FLAGS_STACK_SIZE 32
5637#endif
5638
5639#ifndef NK_COLOR_STACK_SIZE
5640#define NK_COLOR_STACK_SIZE 32
5641#endif
5642
5643#define NK_CONFIGURATION_STACK_TYPE(prefix, name, type)\
5644 struct nk_config_stack_##name##_element {\
5645 prefix##_##type *address;\
5646 prefix##_##type old_value;\
5647 }
5648#define NK_CONFIG_STACK(type,size)\
5649 struct nk_config_stack_##type {\
5650 int head;\
5651 struct nk_config_stack_##type##_element elements[size];\
5652 }
5653
5654#define nk_float float
5655NK_CONFIGURATION_STACK_TYPE(struct nk, style_item, style_item);
5656NK_CONFIGURATION_STACK_TYPE(nk ,float, float);
5657NK_CONFIGURATION_STACK_TYPE(struct nk, vec2, vec2);
5658NK_CONFIGURATION_STACK_TYPE(nk ,flags, flags);
5659NK_CONFIGURATION_STACK_TYPE(struct nk, color, color);
5660NK_CONFIGURATION_STACK_TYPE(const struct nk, user_font, user_font*);
5661NK_CONFIGURATION_STACK_TYPE(enum nk, button_behavior, button_behavior);
5662
5663NK_CONFIG_STACK(style_item, NK_STYLE_ITEM_STACK_SIZE);
5664NK_CONFIG_STACK(float, NK_FLOAT_STACK_SIZE);
5665NK_CONFIG_STACK(vec2, NK_VECTOR_STACK_SIZE);
5666NK_CONFIG_STACK(flags, NK_FLAGS_STACK_SIZE);
5667NK_CONFIG_STACK(color, NK_COLOR_STACK_SIZE);
5668NK_CONFIG_STACK(user_font, NK_FONT_STACK_SIZE);
5669NK_CONFIG_STACK(button_behavior, NK_BUTTON_BEHAVIOR_STACK_SIZE);
5670
5672 struct nk_config_stack_style_item style_items;
5673 struct nk_config_stack_float floats;
5674 struct nk_config_stack_vec2 vectors;
5675 struct nk_config_stack_flags flags;
5676 struct nk_config_stack_color colors;
5677 struct nk_config_stack_user_font fonts;
5678 struct nk_config_stack_button_behavior button_behaviors;
5679};
5680
5681/*==============================================================
5682 * CONTEXT
5683 * =============================================================*/
5684#define NK_VALUE_PAGE_CAPACITY \
5685 (((NK_MAX(sizeof(struct nk_window),sizeof(struct nk_panel)) / sizeof(nk_uint))) / 2)
5686
5687struct nk_table {
5688 unsigned int seq;
5689 unsigned int size;
5690 nk_hash keys[NK_VALUE_PAGE_CAPACITY];
5691 nk_uint values[NK_VALUE_PAGE_CAPACITY];
5692 struct nk_table *next, *prev;
5693};
5694
5696 struct nk_table tbl;
5697 struct nk_panel pan;
5698 struct nk_window win;
5699};
5700
5702 union nk_page_data data;
5703 struct nk_page_element *next;
5704 struct nk_page_element *prev;
5705};
5706
5707struct nk_page {
5708 unsigned int size;
5709 struct nk_page *next;
5710 struct nk_page_element win[1];
5711};
5712
5713struct nk_pool {
5714 struct nk_allocator alloc;
5715 enum nk_allocation_type type;
5716 unsigned int page_count;
5717 struct nk_page *pages;
5718 struct nk_page_element *freelist;
5719 unsigned capacity;
5720 nk_size size;
5721 nk_size cap;
5722};
5723
5725/* public: can be accessed freely */
5726 struct nk_input input;
5727 struct nk_style style;
5728 struct nk_buffer memory;
5729 struct nk_clipboard clip;
5730 nk_flags last_widget_state;
5731 enum nk_button_behavior button_behavior;
5732 struct nk_configuration_stacks stacks;
5733 float delta_time_seconds;
5734
5735/* private:
5736 should only be accessed if you
5737 know what you are doing */
5738#ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
5739 struct nk_draw_list draw_list;
5740#endif
5741#ifdef NK_INCLUDE_COMMAND_USERDATA
5742 nk_handle userdata;
5743#endif
5751
5754 int use_pool;
5755 struct nk_pool pool;
5756 struct nk_window *begin;
5757 struct nk_window *end;
5758 struct nk_window *active;
5759 struct nk_window *current;
5760 struct nk_page_element *freelist;
5761 unsigned int count;
5762 unsigned int seq;
5763};
5764
5765/* ==============================================================
5766 * MATH
5767 * =============================================================== */
5768#define NK_PI 3.141592654f
5769#define NK_PI_HALF 1.570796326f
5770#define NK_UTF_INVALID 0xFFFD
5771#define NK_MAX_FLOAT_PRECISION 2
5772
5773#define NK_UNUSED(x) ((void)(x))
5774#define NK_SATURATE(x) (NK_MAX(0, NK_MIN(1.0f, x)))
5775#define NK_LEN(a) (sizeof(a)/sizeof(a)[0])
5776#define NK_ABS(a) (((a) < 0) ? -(a) : (a))
5777#define NK_BETWEEN(x, a, b) ((a) <= (x) && (x) < (b))
5778#define NK_INBOX(px, py, x, y, w, h)\
5779 (NK_BETWEEN(px,x,x+w) && NK_BETWEEN(py,y,y+h))
5780#define NK_INTERSECT(x0, y0, w0, h0, x1, y1, w1, h1) \
5781 ((x1 < (x0 + w0)) && (x0 < (x1 + w1)) && \
5782 (y1 < (y0 + h0)) && (y0 < (y1 + h1)))
5783#define NK_CONTAINS(x, y, w, h, bx, by, bw, bh)\
5784 (NK_INBOX(x,y, bx, by, bw, bh) && NK_INBOX(x+w,y+h, bx, by, bw, bh))
5785
5786#define nk_vec2_sub(a, b) nk_vec2((a).x - (b).x, (a).y - (b).y)
5787#define nk_vec2_add(a, b) nk_vec2((a).x + (b).x, (a).y + (b).y)
5788#define nk_vec2_len_sqr(a) ((a).x*(a).x+(a).y*(a).y)
5789#define nk_vec2_muls(a, t) nk_vec2((a).x * (t), (a).y * (t))
5790
5791#define nk_ptr_add(t, p, i) ((t*)((void*)((nk_byte*)(p) + (i))))
5792#define nk_ptr_add_const(t, p, i) ((const t*)((const void*)((const nk_byte*)(p) + (i))))
5793#define nk_zero_struct(s) nk_zero(&s, sizeof(s))
5794
5795/* ==============================================================
5796 * ALIGNMENT
5797 * =============================================================== */
5798/* Pointer to Integer type conversion for pointer alignment */
5799#if defined(__PTRDIFF_TYPE__) /* This case should work for GCC*/
5800# define NK_UINT_TO_PTR(x) ((void*)(__PTRDIFF_TYPE__)(x))
5801# define NK_PTR_TO_UINT(x) ((nk_size)(__PTRDIFF_TYPE__)(x))
5802#elif !defined(__GNUC__) /* works for compilers other than LLVM */
5803# define NK_UINT_TO_PTR(x) ((void*)&((char*)0)[x])
5804# define NK_PTR_TO_UINT(x) ((nk_size)(((char*)x)-(char*)0))
5805#elif defined(NK_USE_FIXED_TYPES) /* used if we have <stdint.h> */
5806# define NK_UINT_TO_PTR(x) ((void*)(uintptr_t)(x))
5807# define NK_PTR_TO_UINT(x) ((uintptr_t)(x))
5808#else /* generates warning but works */
5809# define NK_UINT_TO_PTR(x) ((void*)(x))
5810# define NK_PTR_TO_UINT(x) ((nk_size)(x))
5811#endif
5812
5813#define NK_ALIGN_PTR(x, mask)\
5814 (NK_UINT_TO_PTR((NK_PTR_TO_UINT((nk_byte*)(x) + (mask-1)) & ~(mask-1))))
5815#define NK_ALIGN_PTR_BACK(x, mask)\
5816 (NK_UINT_TO_PTR((NK_PTR_TO_UINT((nk_byte*)(x)) & ~(mask-1))))
5817
5818#if ((defined(__GNUC__) && __GNUC__ >= 4) || defined(__clang__)) && !defined(EMSCRIPTEN)
5819#define NK_OFFSETOF(st,m) (__builtin_offsetof(st,m))
5820#else
5821#define NK_OFFSETOF(st,m) ((nk_ptr)&(((st*)0)->m))
5822#endif
5823
5824#ifdef __cplusplus
5825}
5826#endif
5827
5828#ifdef __cplusplus
5829template<typename T> struct nk_alignof;
5830template<typename T, int size_diff> struct nk_helper{enum {value = size_diff};};
5831template<typename T> struct nk_helper<T,0>{enum {value = nk_alignof<T>::value};};
5832template<typename T> struct nk_alignof{struct Big {T x; char c;}; enum {
5833 diff = sizeof(Big) - sizeof(T), value = nk_helper<Big, diff>::value};};
5834#define NK_ALIGNOF(t) (nk_alignof<t>::value)
5835#else
5836#define NK_ALIGNOF(t) NK_OFFSETOF(struct {char c; t _h;}, _h)
5837#endif
5838
5839#define NK_CONTAINER_OF(ptr,type,member)\
5840 (type*)((void*)((char*)(1 ? (ptr): &((type*)0)->member) - NK_OFFSETOF(type, member)))
5841
5842
5843
5844#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 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_API void nk_property_float(struct nk_context *, const char *name, float min, float *val, float max, float step, float inc_per_pixel)
nk_window_flags
Definition nuklear.h:5506
@ NK_WINDOW_CLOSED
Directly closes and frees the window at the end of the frame.
Definition nuklear.h:5512
@ NK_WINDOW_MINIMIZED
marks the window as minimized
Definition nuklear.h:5513
@ NK_WINDOW_HIDDEN
Hides window and stops any window interaction and drawing.
Definition nuklear.h:5511
@ NK_WINDOW_ROM
sets window widgets into a read only mode and does not allow input changes
Definition nuklear.h:5509
@ NK_WINDOW_NOT_INTERACTIVE
prevents all interaction caused by input to either window or widgets inside
Definition nuklear.h:5510
@ NK_WINDOW_DYNAMIC
special window type growing up in height while being filled to a certain maximum height
Definition nuklear.h:5508
@ NK_WINDOW_REMOVE_ROM
Removes read only mode at the end of the window.
Definition nuklear.h:5514
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_property_double(struct nk_context *, const char *name, double min, double *val, double max, double step, float inc_per_pixel)
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:3102
@ NK_WIDGET_STATE_LEFT
!< widget is currently activated
Definition nuklear.h:3108
@ NK_WIDGET_STATE_ACTIVED
!< widget is being hovered
Definition nuklear.h:3107
@ NK_WIDGET_STATE_ENTERED
!< widget is neither active nor hovered
Definition nuklear.h:3105
@ NK_WIDGET_STATE_HOVER
!< widget has been hovered on the current frame
Definition nuklear.h:3106
@ NK_WIDGET_STATE_ACTIVE
!< widget is being hovered
Definition nuklear.h:3110
@ NK_WIDGET_STATE_HOVERED
!< widget is from this frame on not hovered anymore
Definition nuklear.h:3109
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:3096
@ NK_WIDGET_DISABLED
The widget is manually disabled and acts like NK_WIDGET_ROM.
Definition nuklear.h:3100
@ NK_WIDGET_ROM
The widget is partially visible and cannot be updated.
Definition nuklear.h:3099
@ NK_WIDGET_VALID
The widget is completely inside the window and can be updated and drawn.
Definition nuklear.h:3098
@ NK_WIDGET_INVALID
The widget cannot be seen and is completely out of view.
Definition nuklear.h:3097
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 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:3516
@ NK_EDIT_INACTIVE
!< edit widget is currently being modified
Definition nuklear.h:3518
@ NK_EDIT_DEACTIVATED
!< edit widget went from state inactive to state active
Definition nuklear.h:3520
@ NK_EDIT_COMMITED
!< edit widget went from state active to state inactive
Definition nuklear.h:3521
@ NK_EDIT_ACTIVATED
!< edit widget is not active and is not being modified
Definition nuklear.h:3519
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:4207
struct nk_memory memory
!< memory management type
Definition nuklear.h:4209
enum nk_allocation_type type
!< allocator callback for dynamic buffers
Definition nuklear.h:4208
nk_size needed
!< total amount of memory allocated
Definition nuklear.h:4212
nk_size size
!< number of allocation calls
Definition nuklear.h:4214
nk_size allocated
!< growing factor for dynamic memory management
Definition nuklear.h:4211
float grow_factor
!< memory and size of the current memory block
Definition nuklear.h:4210
nk_size calls
!< totally consumed memory given that enough memory is present
Definition nuklear.h:4213
command base and header of every command inside the buffer
Definition nuklear.h:4483
int build
windows
Definition nuklear.h:5753
struct nk_text_edit text_edit
text editor objects are quite big because of an internal undo/redo stack.
Definition nuklear.h:5748
struct nk_command_buffer overlay
draw buffer used for overlay drawing operation like cursor
Definition nuklear.h:5750
enum nk_anti_aliasing shape_AA
!< line anti-aliasing flag can be turned off if you are tight on memory
Definition nuklear.h:990
enum nk_anti_aliasing line_AA
!< global alpha value
Definition nuklear.h:989
nk_size vertex_alignment
!< sizeof one vertex for vertex packing
Definition nuklear.h:997
nk_size vertex_size
!< describes the vertex output format and packing
Definition nuklear.h:996
const struct nk_draw_vertex_layout_element * vertex_layout
!< handle to texture with a white pixel for shape drawing
Definition nuklear.h:995
unsigned arc_segment_count
!< number of segments used for circles: default to 22
Definition nuklear.h:992
unsigned circle_segment_count
!< shape anti-aliasing flag can be turned off if you are tight on memory
Definition nuklear.h:991
unsigned curve_segment_count
!< number of segments used for arcs: default to 22
Definition nuklear.h:993
struct nk_draw_null_texture tex_null
!< number of segments used for curves: default to 22
Definition nuklear.h:994
struct nk_vec2 uv
!< texture handle to a texture with a white pixel
Definition nuklear.h:985
Basic string buffer which is only used in context with the text editor to manage and manipulate dynam...
Definition nuklear.h:4242
nk_text_width_f width
!< max height of the font
Definition nuklear.h:4025
float height
!< user provided font handle
Definition nuklear.h:4024