nuklear.h
Go to the documentation of this file.
1 /*
212 */
213 #ifndef NK_SINGLE_FILE
214  #define NK_SINGLE_FILE
215 #endif
216 
217 #ifndef NK_NUKLEAR_H_
218 #define NK_NUKLEAR_H_
219 
220 #ifdef __cplusplus
221 extern "C" {
222 #endif
223 /*
224  * ==============================================================
225  *
226  * CONSTANTS
227  *
228  * ===============================================================
229  */
230 #define NK_UNDEFINED (-1.0f)
231 #define NK_UTF_INVALID 0xFFFD /* internal invalid utf8 rune */
232 #define NK_UTF_SIZE 4 /* describes the number of bytes a glyph consists of*/
233 #ifndef NK_INPUT_MAX
234  #define NK_INPUT_MAX 16
235 #endif
236 #ifndef NK_MAX_NUMBER_BUFFER
237  #define NK_MAX_NUMBER_BUFFER 64
238 #endif
239 #ifndef NK_SCROLLBAR_HIDING_TIMEOUT
240  #define NK_SCROLLBAR_HIDING_TIMEOUT 4.0f
241 #endif
242 /*
243  * ==============================================================
244  *
245  * HELPER
246  *
247  * ===============================================================
248  */
249 #ifndef NK_API
250  #ifdef NK_PRIVATE
251  #if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199409L))
252  #define NK_API static inline
253  #elif defined(__cplusplus)
254  #define NK_API static inline
255  #else
256  #define NK_API static
257  #endif
258  #else
259  #define NK_API extern
260  #endif
261 #endif
262 #ifndef NK_LIB
263  #ifdef NK_SINGLE_FILE
264  #define NK_LIB static
265  #else
266  #define NK_LIB extern
267  #endif
268 #endif
269 
270 #define NK_INTERN static
271 #define NK_STORAGE static
272 #define NK_GLOBAL static
273 
274 #define NK_FLAG(x) (1 << (x))
275 #define NK_STRINGIFY(x) #x
276 #define NK_MACRO_STRINGIFY(x) NK_STRINGIFY(x)
277 #define NK_STRING_JOIN_IMMEDIATE(arg1, arg2) arg1 ## arg2
278 #define NK_STRING_JOIN_DELAY(arg1, arg2) NK_STRING_JOIN_IMMEDIATE(arg1, arg2)
279 #define NK_STRING_JOIN(arg1, arg2) NK_STRING_JOIN_DELAY(arg1, arg2)
280 
281 #ifdef _MSC_VER
282  #define NK_UNIQUE_NAME(name) NK_STRING_JOIN(name,__COUNTER__)
283 #else
284  #define NK_UNIQUE_NAME(name) NK_STRING_JOIN(name,__LINE__)
285 #endif
286 
287 #ifndef NK_STATIC_ASSERT
288  #define NK_STATIC_ASSERT(exp) typedef char NK_UNIQUE_NAME(_dummy_array)[(exp)?1:-1]
289 #endif
290 
291 #ifndef NK_FILE_LINE
292 #ifdef _MSC_VER
293  #define NK_FILE_LINE __FILE__ ":" NK_MACRO_STRINGIFY(__COUNTER__)
294 #else
295  #define NK_FILE_LINE __FILE__ ":" NK_MACRO_STRINGIFY(__LINE__)
296 #endif
297 #endif
298 
299 #define NK_MIN(a,b) ((a) < (b) ? (a) : (b))
300 #define NK_MAX(a,b) ((a) < (b) ? (b) : (a))
301 #define NK_CLAMP(i,v,x) (NK_MAX(NK_MIN(v,x), i))
302 
303 #ifdef NK_INCLUDE_STANDARD_VARARGS
304  #if defined(_MSC_VER) && (_MSC_VER >= 1600) /* VS 2010 and above */
305  #include <sal.h>
306  #define NK_PRINTF_FORMAT_STRING _Printf_format_string_
307  #else
308  #define NK_PRINTF_FORMAT_STRING
309  #endif
310  #if defined(__GNUC__)
311  #define NK_PRINTF_VARARG_FUNC(fmtargnumber) __attribute__((format(__printf__, fmtargnumber, fmtargnumber+1)))
312  #define NK_PRINTF_VALIST_FUNC(fmtargnumber) __attribute__((format(__printf__, fmtargnumber, 0)))
313  #else
314  #define NK_PRINTF_VARARG_FUNC(fmtargnumber)
315  #define NK_PRINTF_VALIST_FUNC(fmtargnumber)
316  #endif
317  #include <stdarg.h> /* valist, va_start, va_end, ... */
318 #endif
319 
320 /*
321  * ===============================================================
322  *
323  * BASIC
324  *
325  * ===============================================================
326  */
327 #ifdef NK_INCLUDE_FIXED_TYPES
328  #include <stdint.h>
329  #define NK_INT8 int8_t
330  #define NK_UINT8 uint8_t
331  #define NK_INT16 int16_t
332  #define NK_UINT16 uint16_t
333  #define NK_INT32 int32_t
334  #define NK_UINT32 uint32_t
335  #define NK_SIZE_TYPE uintptr_t
336  #define NK_POINTER_TYPE uintptr_t
337 #else
338  #ifndef NK_INT8
339  #define NK_INT8 char
340  #endif
341  #ifndef NK_UINT8
342  #define NK_UINT8 unsigned char
343  #endif
344  #ifndef NK_INT16
345  #define NK_INT16 signed short
346  #endif
347  #ifndef NK_UINT16
348  #define NK_UINT16 unsigned short
349  #endif
350  #ifndef NK_INT32
351  #if defined(_MSC_VER)
352  #define NK_INT32 __int32
353  #else
354  #define NK_INT32 signed int
355  #endif
356  #endif
357  #ifndef NK_UINT32
358  #if defined(_MSC_VER)
359  #define NK_UINT32 unsigned __int32
360  #else
361  #define NK_UINT32 unsigned int
362  #endif
363  #endif
364  #ifndef NK_SIZE_TYPE
365  #if defined(_WIN64) && defined(_MSC_VER)
366  #define NK_SIZE_TYPE unsigned __int64
367  #elif (defined(_WIN32) || defined(WIN32)) && defined(_MSC_VER)
368  #define NK_SIZE_TYPE unsigned __int32
369  #elif defined(__GNUC__) || defined(__clang__)
370  #if defined(__x86_64__) || defined(__ppc64__)
371  #define NK_SIZE_TYPE unsigned long
372  #else
373  #define NK_SIZE_TYPE unsigned int
374  #endif
375  #else
376  #define NK_SIZE_TYPE unsigned long
377  #endif
378  #endif
379  #ifndef NK_POINTER_TYPE
380  #if defined(_WIN64) && defined(_MSC_VER)
381  #define NK_POINTER_TYPE unsigned __int64
382  #elif (defined(_WIN32) || defined(WIN32)) && defined(_MSC_VER)
383  #define NK_POINTER_TYPE unsigned __int32
384  #elif defined(__GNUC__) || defined(__clang__)
385  #if defined(__x86_64__) || defined(__ppc64__)
386  #define NK_POINTER_TYPE unsigned long
387  #else
388  #define NK_POINTER_TYPE unsigned int
389  #endif
390  #else
391  #define NK_POINTER_TYPE unsigned long
392  #endif
393  #endif
394 #endif
395 
396 typedef NK_INT8 nk_char;
401 typedef NK_INT32 nk_int;
405 
406 typedef nk_uint nk_hash;
407 typedef nk_uint nk_flags;
408 typedef nk_uint nk_rune;
409 
410 /* Make sure correct type size:
411  * This will fire with a negative subscript error if the type sizes
412  * are set incorrectly by the compiler, and compile out if not */
413 NK_STATIC_ASSERT(sizeof(nk_short) == 2);
414 NK_STATIC_ASSERT(sizeof(nk_ushort) == 2);
415 NK_STATIC_ASSERT(sizeof(nk_uint) == 4);
416 NK_STATIC_ASSERT(sizeof(nk_int) == 4);
417 NK_STATIC_ASSERT(sizeof(nk_byte) == 1);
418 NK_STATIC_ASSERT(sizeof(nk_flags) >= 4);
419 NK_STATIC_ASSERT(sizeof(nk_rune) >= 4);
420 NK_STATIC_ASSERT(sizeof(nk_size) >= sizeof(void*));
421 NK_STATIC_ASSERT(sizeof(nk_ptr) >= sizeof(void*));
422 
423 /* ============================================================================
424  *
425  * API
426  *
427  * =========================================================================== */
428 struct nk_buffer;
429 struct nk_allocator;
430 struct nk_command_buffer;
431 struct nk_draw_command;
432 struct nk_convert_config;
433 struct nk_style_item;
434 struct nk_text_edit;
435 struct nk_draw_list;
436 struct nk_user_font;
437 struct nk_panel;
438 struct nk_context;
439 struct nk_draw_vertex_layout_element;
440 struct nk_style_button;
441 struct nk_style_toggle;
442 struct nk_style_selectable;
443 struct nk_style_slide;
444 struct nk_style_progress;
445 struct nk_style_scrollbar;
446 struct nk_style_edit;
447 struct nk_style_property;
448 struct nk_style_chart;
449 struct nk_style_combo;
450 struct nk_style_tab;
452 struct nk_style_window;
453 
455 struct nk_color {nk_byte r,g,b,a;};
456 struct nk_colorf {float r,g,b,a;};
457 struct nk_vec2 {float x,y;};
458 struct nk_vec2i {short x, y;};
459 struct nk_rect {float x,y,w,h;};
460 struct nk_recti {short x,y,w,h;};
461 typedef char nk_glyph[NK_UTF_SIZE];
462 typedef union {void *ptr; int id;} nk_handle;
463 struct nk_image {nk_handle handle;unsigned short w,h;unsigned short region[4];};
464 struct nk_cursor {struct nk_image img; struct nk_vec2 size, offset;};
465 struct nk_scroll {nk_uint x, y;};
466 
479 
480 typedef void*(*nk_plugin_alloc)(nk_handle, void *old, nk_size);
481 typedef void (*nk_plugin_free)(nk_handle, void *old);
482 typedef int(*nk_plugin_filter)(const struct nk_text_edit*, nk_rune unicode);
483 typedef void(*nk_plugin_paste)(nk_handle, struct nk_text_edit*);
484 typedef void(*nk_plugin_copy)(nk_handle, const char*, int len);
485 
486 struct nk_allocator {
487  nk_handle userdata;
490 };
506 };
507 /* =============================================================================
508  *
509  * CONTEXT
510  *
511  * =============================================================================*/
512 /*/// ### Context
544  */
545 #ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
546 /*/// #### nk_init_default
561 */
562 NK_API int nk_init_default(struct nk_context*, const struct nk_user_font*);
563 #endif
564 /*/// #### nk_init_fixed
586 */
587 NK_API int nk_init_fixed(struct nk_context*, void *memory, nk_size size, const struct nk_user_font*);
588 /*/// #### nk_init
604 */
605 NK_API int nk_init(struct nk_context*, struct nk_allocator*, const struct nk_user_font*);
606 /*/// #### nk_init_custom
623 */
624 NK_API int nk_init_custom(struct nk_context*, struct nk_buffer *cmds, struct nk_buffer *pool, const struct nk_user_font*);
625 /*/// #### nk_clear
637 */
638 NK_API void nk_clear(struct nk_context*);
639 /*/// #### nk_free
650 */
651 NK_API void nk_free(struct nk_context*);
652 #ifdef NK_INCLUDE_COMMAND_USERDATA
653 /*/// #### nk_set_user_data
664 */
665 NK_API void nk_set_user_data(struct nk_context*, nk_handle handle);
666 #endif
667 /* =============================================================================
668  *
669  * INPUT
670  *
671  * =============================================================================*/
672 /*/// ### Input
732 */
733 enum nk_keys {
748  /* Shortcuts: text field */
761  /* Shortcuts: scrollbar */
767 };
774 };
775 /*/// #### nk_input_begin
786 */
787 NK_API void nk_input_begin(struct nk_context*);
788 /*/// #### nk_input_motion
800 */
801 NK_API void nk_input_motion(struct nk_context*, int x, int y);
802 /*/// #### nk_input_key
814 */
815 NK_API void nk_input_key(struct nk_context*, enum nk_keys, int down);
816 /*/// #### nk_input_button
830 */
831 NK_API void nk_input_button(struct nk_context*, enum nk_buttons, int x, int y, int down);
832 /*/// #### nk_input_scroll
845 */
846 NK_API void nk_input_scroll(struct nk_context*, struct nk_vec2 val);
847 /*/// #### nk_input_char
863 */
864 NK_API void nk_input_char(struct nk_context*, char);
865 /*/// #### nk_input_glyph
880 */
881 NK_API void nk_input_glyph(struct nk_context*, const nk_glyph);
882 /*/// #### nk_input_unicode
896 */
897 NK_API void nk_input_unicode(struct nk_context*, nk_rune);
898 /*/// #### nk_input_end
909 */
910 NK_API void nk_input_end(struct nk_context*);
911 /* =============================================================================
912  *
913  * DRAWING
914  *
915  * =============================================================================*/
916 /*/// ### Drawing
1133 */
1141 };
1143  nk_handle texture; /* texture handle to a texture with a white pixel */
1144  struct nk_vec2 uv; /* coordinates to a white pixel in the texture */
1145 };
1147  float global_alpha; /* global alpha value */
1148  enum nk_anti_aliasing line_AA; /* line anti-aliasing flag can be turned off if you are tight on memory */
1149  enum nk_anti_aliasing shape_AA; /* shape anti-aliasing flag can be turned off if you are tight on memory */
1150  unsigned circle_segment_count; /* number of segments used for circles: default to 22 */
1151  unsigned arc_segment_count; /* number of segments used for arcs: default to 22 */
1152  unsigned curve_segment_count; /* number of segments used for curves: default to 22 */
1153  struct nk_draw_null_texture null; /* handle to texture with a white pixel for shape drawing */
1154  const struct nk_draw_vertex_layout_element *vertex_layout; /* describes the vertex output format and packing */
1155  nk_size vertex_size; /* sizeof one vertex for vertex packing */
1156  nk_size vertex_alignment; /* vertex alignment: Can be obtained by NK_ALIGNOF */
1157 };
1158 /*/// #### nk__begin
1171 */
1172 NK_API const struct nk_command* nk__begin(struct nk_context*);
1173 /*/// #### nk__next
1186 */
1187 NK_API const struct nk_command* nk__next(struct nk_context*, const struct nk_command*);
1188 /*/// #### nk_foreach
1201 */
1202 #define nk_foreach(c, ctx) for((c) = nk__begin(ctx); (c) != 0; (c) = nk__next(ctx,c))
1203 #ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
1204 /*/// #### nk_convert
1212 // struct nk_buffer *vertices, struct nk_buffer *elements, const struct nk_convert_config*);
1232 */
1233 NK_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*);
1234 /*/// #### nk__draw_begin
1247 */
1248 NK_API const struct nk_draw_command* nk__draw_begin(const struct nk_context*, const struct nk_buffer*);
1249 /*/// #### nk__draw_end
1262 */
1263 NK_API const struct nk_draw_command* nk__draw_end(const struct nk_context*, const struct nk_buffer*);
1264 /*/// #### nk__draw_next
1278 */
1279 NK_API const struct nk_draw_command* nk__draw_next(const struct nk_draw_command*, const struct nk_buffer*, const struct nk_context*);
1280 /*/// #### nk_draw_foreach
1292 */
1293 #define nk_draw_foreach(cmd,ctx, b) for((cmd)=nk__draw_begin(ctx, b); (cmd)!=0; (cmd)=nk__draw_next(cmd, b, ctx))
1294 #endif
1295 /* =============================================================================
1296  *
1297  * WINDOW
1298  *
1299  * =============================================================================
1384 //
1405 //
1410 //
1416 */
1417 /*
1439 */
1452 };
1453 /*/// #### nk_begin
1470 */
1471 NK_API int nk_begin(struct nk_context *ctx, const char *title, struct nk_rect bounds, nk_flags flags);
1472 /*/// #### nk_begin_titled
1490 */
1491 NK_API int nk_begin_titled(struct nk_context *ctx, const char *name, const char *title, struct nk_rect bounds, nk_flags flags);
1492 /*/// #### nk_end
1503 */
1504 NK_API void nk_end(struct nk_context *ctx);
1505 /*/// #### nk_window_find
1519 */
1520 NK_API struct nk_window *nk_window_find(struct nk_context *ctx, const char *name);
1521 /*/// #### nk_window_get_bounds
1535 */
1536 NK_API struct nk_rect nk_window_get_bounds(const struct nk_context *ctx);
1537 /*/// #### nk_window_get_position
1551 */
1552 NK_API struct nk_vec2 nk_window_get_position(const struct nk_context *ctx);
1553 /*/// #### nk_window_get_size
1567 */
1568 NK_API struct nk_vec2 nk_window_get_size(const struct nk_context*);
1569 /*/// #### nk_window_get_width
1583 */
1584 NK_API float nk_window_get_width(const struct nk_context*);
1585 /*/// #### nk_window_get_height
1599 */
1600 NK_API float nk_window_get_height(const struct nk_context*);
1601 /*/// #### nk_window_get_panel
1617 */
1619 /*/// #### nk_window_get_content_region
1636 */
1638 /*/// #### nk_window_get_content_region_min
1655 */
1657 /*/// #### nk_window_get_content_region_max
1674 */
1676 /*/// #### nk_window_get_content_region_size
1692 */
1694 /*/// #### nk_window_get_canvas
1711 */
1713 /*/// #### nk_window_has_focus
1726 */
1727 NK_API int nk_window_has_focus(const struct nk_context*);
1728 /*/// #### nk_window_is_hovered
1741 */
1743 /*/// #### nk_window_is_collapsed
1756 */
1757 NK_API int nk_window_is_collapsed(struct nk_context *ctx, const char *name);
1758 /*/// #### nk_window_is_closed
1770 */
1771 NK_API int nk_window_is_closed(struct nk_context*, const char*);
1772 /*/// #### nk_window_is_hidden
1784 */
1785 NK_API int nk_window_is_hidden(struct nk_context*, const char*);
1786 /*/// #### nk_window_is_active
1798 */
1799 NK_API int nk_window_is_active(struct nk_context*, const char*);
1800 /*/// #### nk_window_is_any_hovered
1811 */
1813 /*/// #### nk_item_is_any_active
1826 */
1828 /*/// #### nk_window_set_bounds
1839 */
1840 NK_API void nk_window_set_bounds(struct nk_context*, const char *name, struct nk_rect bounds);
1841 /*/// #### nk_window_set_position
1852 */
1853 NK_API void nk_window_set_position(struct nk_context*, const char *name, struct nk_vec2 pos);
1854 /*/// #### nk_window_set_size
1865 */
1866 NK_API void nk_window_set_size(struct nk_context*, const char *name, struct nk_vec2);
1867 /*/// #### nk_window_set_focus
1877 */
1878 NK_API void nk_window_set_focus(struct nk_context*, const char *name);
1879 /*/// #### nk_window_close
1889 */
1890 NK_API void nk_window_close(struct nk_context *ctx, const char *name);
1891 /*/// #### nk_window_collapse
1902 */
1903 NK_API void nk_window_collapse(struct nk_context*, const char *name, enum nk_collapse_states state);
1904 /*/// #### nk_window_collapse_if
1916 */
1917 NK_API void nk_window_collapse_if(struct nk_context*, const char *name, enum nk_collapse_states, int cond);
1918 /*/// #### nk_window_show
1929 */
1930 NK_API void nk_window_show(struct nk_context*, const char *name, enum nk_show_states);
1931 /*/// #### nk_window_show_if
1943 */
1944 NK_API void nk_window_show_if(struct nk_context*, const char *name, enum nk_show_states, int cond);
1945 /* =============================================================================
1946  *
1947  * LAYOUT
1948  *
1949  * =============================================================================
2194 //
2201 //
2207 //
2211 //
2217 */
2218 /*/// #### nk_layout_set_min_row_height
2232 */
2234 /*/// #### nk_layout_reset_min_row_height
2243 */
2245 /*/// #### nk_layout_widget_bounds
2256 */
2258 /*/// #### nk_layout_ratio_from_pixel
2270 */
2271 NK_API float nk_layout_ratio_from_pixel(struct nk_context*, float pixel_width);
2272 /*/// #### nk_layout_row_dynamic
2285 */
2286 NK_API void nk_layout_row_dynamic(struct nk_context *ctx, float height, int cols);
2287 /*/// #### nk_layout_row_static
2301 */
2302 NK_API void nk_layout_row_static(struct nk_context *ctx, float height, int item_width, int cols);
2303 /*/// #### nk_layout_row_begin
2315 */
2316 NK_API void nk_layout_row_begin(struct nk_context *ctx, enum nk_layout_format fmt, float row_height, int cols);
2317 /*/// #### nk_layout_row_push
2327 */
2328 NK_API void nk_layout_row_push(struct nk_context*, float value);
2329 /*/// #### nk_layout_row_end
2338 */
2339 NK_API void nk_layout_row_end(struct nk_context*);
2340 /*/// #### nk_layout_row
2352 */
2353 NK_API void nk_layout_row(struct nk_context*, enum nk_layout_format, float height, int cols, const float *ratio);
2354 /*/// #### nk_layout_row_template_begin
2364 */
2365 NK_API void nk_layout_row_template_begin(struct nk_context*, float row_height);
2366 /*/// #### nk_layout_row_template_push_dynamic
2376 */
2378 /*/// #### nk_layout_row_template_push_variable
2388 */
2389 NK_API void nk_layout_row_template_push_variable(struct nk_context*, float min_width);
2390 /*/// #### nk_layout_row_template_push_static
2400 */
2402 /*/// #### nk_layout_row_template_end
2411 */
2413 /*/// #### nk_layout_space_begin
2425 */
2426 NK_API void nk_layout_space_begin(struct nk_context*, enum nk_layout_format, float height, int widget_count);
2427 /*/// #### nk_layout_space_push
2437 */
2438 NK_API void nk_layout_space_push(struct nk_context*, struct nk_rect bounds);
2439 /*/// #### nk_layout_space_end
2448 */
2449 NK_API void nk_layout_space_end(struct nk_context*);
2450 /*/// #### nk_layout_space_bounds
2461 */
2463 /*/// #### nk_layout_space_to_screen
2475 */
2477 /*/// #### nk_layout_space_to_local
2489 */
2490 NK_API struct nk_vec2 nk_layout_space_to_local(struct nk_context*, struct nk_vec2);
2491 /*/// #### nk_layout_space_rect_to_screen
2503 */
2505 /*/// #### nk_layout_space_rect_to_local
2517 */
2519 /* =============================================================================
2520  *
2521  * GROUP
2522  *
2523  * =============================================================================
2591 // nk_clear(&ctx);
2604 */
2605 /*/// #### nk_group_begin
2618 */
2619 NK_API int nk_group_begin(struct nk_context*, const char *title, nk_flags);
2620 /*/// #### nk_group_begin_titled
2634 */
2635 NK_API int nk_group_begin_titled(struct nk_context*, const char *name, const char *title, nk_flags);
2636 /*/// #### nk_group_end
2645 */
2646 NK_API void nk_group_end(struct nk_context*);
2647 /*/// #### nk_group_scrolled_offset_begin
2663 */
2664 NK_API int nk_group_scrolled_offset_begin(struct nk_context*, nk_uint *x_offset, nk_uint *y_offset, const char *title, nk_flags flags);
2665 /*/// #### nk_group_scrolled_begin
2680 */
2681 NK_API int nk_group_scrolled_begin(struct nk_context*, struct nk_scroll *off, const char *title, nk_flags);
2682 /*/// #### nk_group_scrolled_end
2691 */
2693 /* =============================================================================
2694  *
2695  * TREE
2696  *
2697  * =============================================================================
2752 //
2762 */
2763 /*/// #### nk_tree_push
2783 */
2784 #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__)
2785 /*/// #### nk_tree_push_id
2800 */
2801 #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)
2802 /*/// #### nk_tree_push_hashed
2820 */
2821 NK_API int 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);
2822 /*/// #### nk_tree_image_push
2833 //
2843 */
2844 #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__)
2845 /*/// #### nk_tree_image_push_id
2863 */
2864 #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)
2865 /*/// #### nk_tree_image_push_hashed
2884 */
2885 NK_API int 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);
2886 /*/// #### nk_tree_pop
2895 */
2896 NK_API void nk_tree_pop(struct nk_context*);
2897 /*/// #### nk_tree_state_push
2911 */
2912 NK_API int nk_tree_state_push(struct nk_context*, enum nk_tree_type, const char *title, enum nk_collapse_states *state);
2913 /*/// #### nk_tree_state_image_push
2928 */
2929 NK_API int nk_tree_state_image_push(struct nk_context*, enum nk_tree_type, struct nk_image, const char *title, enum nk_collapse_states *state);
2930 /*/// #### nk_tree_state_pop
2939 */
2940 NK_API void nk_tree_state_pop(struct nk_context*);
2941 
2942 #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__)
2943 #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)
2944 NK_API int nk_tree_element_push_hashed(struct nk_context*, enum nk_tree_type, const char *title, enum nk_collapse_states initial_state, int *selected, const char *hash, int len, int seed);
2945 NK_API int 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, int *selected, const char *hash, int len,int seed);
2946 NK_API void nk_tree_element_pop(struct nk_context*);
2947 
2948 /* =============================================================================
2949  *
2950  * LIST VIEW
2951  *
2952  * ============================================================================= */
2954 /* public: */
2955  int begin, end, count;
2956 /* private: */
2958  struct nk_context *ctx;
2959  nk_uint *scroll_pointer;
2960  nk_uint scroll_value;
2961 };
2962 NK_API int nk_list_view_begin(struct nk_context*, struct nk_list_view *out, const char *id, nk_flags, int row_height, int row_count);
2963 NK_API void nk_list_view_end(struct nk_list_view*);
2964 /* =============================================================================
2965  *
2966  * WIDGET
2967  *
2968  * ============================================================================= */
2970  NK_WIDGET_INVALID, /* The widget cannot be seen and is completely out of view */
2971  NK_WIDGET_VALID, /* The widget is completely inside the window and can be updated and drawn */
2972  NK_WIDGET_ROM /* The widget is partially visible and cannot be updated */
2973 };
2976  NK_WIDGET_STATE_INACTIVE = NK_FLAG(2), /* widget is neither active nor hovered */
2977  NK_WIDGET_STATE_ENTERED = NK_FLAG(3), /* widget has been hovered on the current frame */
2978  NK_WIDGET_STATE_HOVER = NK_FLAG(4), /* widget is being hovered */
2979  NK_WIDGET_STATE_ACTIVED = NK_FLAG(5),/* widget is currently activated */
2980  NK_WIDGET_STATE_LEFT = NK_FLAG(6), /* widget is from this frame on not hovered anymore */
2983 };
2984 NK_API enum nk_widget_layout_states nk_widget(struct nk_rect*, const struct nk_context*);
2986 NK_API struct nk_rect nk_widget_bounds(struct nk_context*);
2988 NK_API struct nk_vec2 nk_widget_size(struct nk_context*);
2989 NK_API float nk_widget_width(struct nk_context*);
2990 NK_API float nk_widget_height(struct nk_context*);
2993 NK_API int nk_widget_has_mouse_click_down(struct nk_context*, enum nk_buttons, int down);
2994 NK_API void nk_spacing(struct nk_context*, int cols);
2995 /* =============================================================================
2996  *
2997  * TEXT
2998  *
2999  * ============================================================================= */
3007 };
3012 };
3013 NK_API void nk_text(struct nk_context*, const char*, int, nk_flags);
3014 NK_API void nk_text_colored(struct nk_context*, const char*, int, nk_flags, struct nk_color);
3015 NK_API void nk_text_wrap(struct nk_context*, const char*, int);
3016 NK_API void nk_text_wrap_colored(struct nk_context*, const char*, int, struct nk_color);
3017 NK_API void nk_label(struct nk_context*, const char*, nk_flags align);
3018 NK_API void nk_label_colored(struct nk_context*, const char*, nk_flags align, struct nk_color);
3019 NK_API void nk_label_wrap(struct nk_context*, const char*);
3020 NK_API void nk_label_colored_wrap(struct nk_context*, const char*, struct nk_color);
3021 NK_API void nk_image(struct nk_context*, struct nk_image);
3022 NK_API void nk_image_color(struct nk_context*, struct nk_image, struct nk_color);
3023 #ifdef NK_INCLUDE_STANDARD_VARARGS
3024 NK_API void nk_labelf(struct nk_context*, nk_flags, NK_PRINTF_FORMAT_STRING const char*, ...) NK_PRINTF_VARARG_FUNC(3);
3025 NK_API void nk_labelf_colored(struct nk_context*, nk_flags, struct nk_color, NK_PRINTF_FORMAT_STRING const char*,...) NK_PRINTF_VARARG_FUNC(4);
3026 NK_API void nk_labelf_wrap(struct nk_context*, NK_PRINTF_FORMAT_STRING const char*,...) NK_PRINTF_VARARG_FUNC(2);
3027 NK_API void nk_labelf_colored_wrap(struct nk_context*, struct nk_color, NK_PRINTF_FORMAT_STRING const char*,...) NK_PRINTF_VARARG_FUNC(3);
3028 NK_API void nk_labelfv(struct nk_context*, nk_flags, NK_PRINTF_FORMAT_STRING const char*, va_list) NK_PRINTF_VALIST_FUNC(3);
3029 NK_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);
3030 NK_API void nk_labelfv_wrap(struct nk_context*, NK_PRINTF_FORMAT_STRING const char*, va_list) NK_PRINTF_VALIST_FUNC(2);
3031 NK_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);
3032 NK_API void nk_value_bool(struct nk_context*, const char *prefix, int);
3033 NK_API void nk_value_int(struct nk_context*, const char *prefix, int);
3034 NK_API void nk_value_uint(struct nk_context*, const char *prefix, unsigned int);
3035 NK_API void nk_value_float(struct nk_context*, const char *prefix, float);
3036 NK_API void nk_value_color_byte(struct nk_context*, const char *prefix, struct nk_color);
3037 NK_API void nk_value_color_float(struct nk_context*, const char *prefix, struct nk_color);
3038 NK_API void nk_value_color_hex(struct nk_context*, const char *prefix, struct nk_color);
3039 #endif
3040 /* =============================================================================
3041  *
3042  * BUTTON
3043  *
3044  * ============================================================================= */
3045 NK_API int nk_button_text(struct nk_context*, const char *title, int len);
3046 NK_API int nk_button_label(struct nk_context*, const char *title);
3047 NK_API int nk_button_color(struct nk_context*, struct nk_color);
3048 NK_API int nk_button_symbol(struct nk_context*, enum nk_symbol_type);
3049 NK_API int nk_button_image(struct nk_context*, struct nk_image img);
3050 NK_API int nk_button_symbol_label(struct nk_context*, enum nk_symbol_type, const char*, nk_flags text_alignment);
3051 NK_API int nk_button_symbol_text(struct nk_context*, enum nk_symbol_type, const char*, int, nk_flags alignment);
3052 NK_API int nk_button_image_label(struct nk_context*, struct nk_image img, const char*, nk_flags text_alignment);
3053 NK_API int nk_button_image_text(struct nk_context*, struct nk_image img, const char*, int, nk_flags alignment);
3054 NK_API int nk_button_text_styled(struct nk_context*, const struct nk_style_button*, const char *title, int len);
3055 NK_API int nk_button_label_styled(struct nk_context*, const struct nk_style_button*, const char *title);
3056 NK_API int nk_button_symbol_styled(struct nk_context*, const struct nk_style_button*, enum nk_symbol_type);
3057 NK_API int nk_button_image_styled(struct nk_context*, const struct nk_style_button*, struct nk_image img);
3058 NK_API int nk_button_symbol_text_styled(struct nk_context*,const struct nk_style_button*, enum nk_symbol_type, const char*, int, nk_flags alignment);
3059 NK_API int 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);
3060 NK_API int nk_button_image_label_styled(struct nk_context*,const struct nk_style_button*, struct nk_image img, const char*, nk_flags text_alignment);
3061 NK_API int nk_button_image_text_styled(struct nk_context*,const struct nk_style_button*, struct nk_image img, const char*, int, nk_flags alignment);
3062 NK_API void nk_button_set_behavior(struct nk_context*, enum nk_button_behavior);
3063 NK_API int nk_button_push_behavior(struct nk_context*, enum nk_button_behavior);
3064 NK_API int nk_button_pop_behavior(struct nk_context*);
3065 /* =============================================================================
3066  *
3067  * CHECKBOX
3068  *
3069  * ============================================================================= */
3070 NK_API int nk_check_label(struct nk_context*, const char*, int active);
3071 NK_API int nk_check_text(struct nk_context*, const char*, int,int active);
3072 NK_API unsigned nk_check_flags_label(struct nk_context*, const char*, unsigned int flags, unsigned int value);
3073 NK_API unsigned nk_check_flags_text(struct nk_context*, const char*, int, unsigned int flags, unsigned int value);
3074 NK_API int nk_checkbox_label(struct nk_context*, const char*, int *active);
3075 NK_API int nk_checkbox_text(struct nk_context*, const char*, int, int *active);
3076 NK_API int nk_checkbox_flags_label(struct nk_context*, const char*, unsigned int *flags, unsigned int value);
3077 NK_API int nk_checkbox_flags_text(struct nk_context*, const char*, int, unsigned int *flags, unsigned int value);
3078 /* =============================================================================
3079  *
3080  * RADIO BUTTON
3081  *
3082  * ============================================================================= */
3083 NK_API int nk_radio_label(struct nk_context*, const char*, int *active);
3084 NK_API int nk_radio_text(struct nk_context*, const char*, int, int *active);
3085 NK_API int nk_option_label(struct nk_context*, const char*, int active);
3086 NK_API int nk_option_text(struct nk_context*, const char*, int, int active);
3087 /* =============================================================================
3088  *
3089  * SELECTABLE
3090  *
3091  * ============================================================================= */
3092 NK_API int nk_selectable_label(struct nk_context*, const char*, nk_flags align, int *value);
3093 NK_API int nk_selectable_text(struct nk_context*, const char*, int, nk_flags align, int *value);
3094 NK_API int nk_selectable_image_label(struct nk_context*,struct nk_image, const char*, nk_flags align, int *value);
3095 NK_API int nk_selectable_image_text(struct nk_context*,struct nk_image, const char*, int, nk_flags align, int *value);
3096 NK_API int nk_selectable_symbol_label(struct nk_context*,enum nk_symbol_type, const char*, nk_flags align, int *value);
3097 NK_API int nk_selectable_symbol_text(struct nk_context*,enum nk_symbol_type, const char*, int, nk_flags align, int *value);
3098 
3099 NK_API int nk_select_label(struct nk_context*, const char*, nk_flags align, int value);
3100 NK_API int nk_select_text(struct nk_context*, const char*, int, nk_flags align, int value);
3101 NK_API int nk_select_image_label(struct nk_context*, struct nk_image,const char*, nk_flags align, int value);
3102 NK_API int nk_select_image_text(struct nk_context*, struct nk_image,const char*, int, nk_flags align, int value);
3103 NK_API int nk_select_symbol_label(struct nk_context*,enum nk_symbol_type, const char*, nk_flags align, int value);
3104 NK_API int nk_select_symbol_text(struct nk_context*,enum nk_symbol_type, const char*, int, nk_flags align, int value);
3105 
3106 /* =============================================================================
3107  *
3108  * SLIDER
3109  *
3110  * ============================================================================= */
3111 NK_API float nk_slide_float(struct nk_context*, float min, float val, float max, float step);
3112 NK_API int nk_slide_int(struct nk_context*, int min, int val, int max, int step);
3113 NK_API int nk_slider_float(struct nk_context*, float min, float *val, float max, float step);
3114 NK_API int nk_slider_int(struct nk_context*, int min, int *val, int max, int step);
3115 /* =============================================================================
3116  *
3117  * PROGRESSBAR
3118  *
3119  * ============================================================================= */
3120 NK_API int nk_progress(struct nk_context*, nk_size *cur, nk_size max, int modifyable);
3121 NK_API nk_size nk_prog(struct nk_context*, nk_size cur, nk_size max, int modifyable);
3122 
3123 /* =============================================================================
3124  *
3125  * COLOR PICKER
3126  *
3127  * ============================================================================= */
3128 NK_API struct nk_colorf nk_color_picker(struct nk_context*, struct nk_colorf, enum nk_color_format);
3129 NK_API int nk_color_pick(struct nk_context*, struct nk_colorf*, enum nk_color_format);
3130 /* =============================================================================
3131  *
3132  * PROPERTIES
3133  *
3134  * =============================================================================
3190 // nk_clear(&ctx);
3205 */
3206 /*/// #### nk_property_int
3225 */
3226 NK_API void nk_property_int(struct nk_context*, const char *name, int min, int *val, int max, int step, float inc_per_pixel);
3227 /*/// #### nk_property_float
3246 */
3247 NK_API void nk_property_float(struct nk_context*, const char *name, float min, float *val, float max, float step, float inc_per_pixel);
3248 /*/// #### nk_property_double
3267 */
3268 NK_API void nk_property_double(struct nk_context*, const char *name, double min, double *val, double max, double step, float inc_per_pixel);
3269 /*/// #### nk_propertyi
3290 */
3291 NK_API int nk_propertyi(struct nk_context*, const char *name, int min, int val, int max, int step, float inc_per_pixel);
3292 /*/// #### nk_propertyf
3313 */
3314 NK_API float nk_propertyf(struct nk_context*, const char *name, float min, float val, float max, float step, float inc_per_pixel);
3315 /*/// #### nk_propertyd
3336 */
3337 NK_API double nk_propertyd(struct nk_context*, const char *name, double min, double val, double max, double step, float inc_per_pixel);
3338 /* =============================================================================
3339  *
3340  * TEXT EDIT
3341  *
3342  * ============================================================================= */
3357 };
3363 };
3365  NK_EDIT_ACTIVE = NK_FLAG(0), /* edit widget is currently being modified */
3366  NK_EDIT_INACTIVE = NK_FLAG(1), /* edit widget is not active and is not being modified */
3367  NK_EDIT_ACTIVATED = NK_FLAG(2), /* edit widget went from state inactive to state active */
3368  NK_EDIT_DEACTIVATED = NK_FLAG(3), /* edit widget went from state active to state inactive */
3369  NK_EDIT_COMMITED = NK_FLAG(4) /* edit widget has received an enter and lost focus */
3370 };
3371 NK_API nk_flags nk_edit_string(struct nk_context*, nk_flags, char *buffer, int *len, int max, nk_plugin_filter);
3372 NK_API nk_flags nk_edit_string_zero_terminated(struct nk_context*, nk_flags, char *buffer, int max, nk_plugin_filter);
3373 NK_API nk_flags nk_edit_buffer(struct nk_context*, nk_flags, struct nk_text_edit*, nk_plugin_filter);
3374 NK_API void nk_edit_focus(struct nk_context*, nk_flags flags);
3375 NK_API void nk_edit_unfocus(struct nk_context*);
3376 /* =============================================================================
3377  *
3378  * CHART
3379  *
3380  * ============================================================================= */
3381 NK_API int nk_chart_begin(struct nk_context*, enum nk_chart_type, int num, float min, float max);
3382 NK_API int nk_chart_begin_colored(struct nk_context*, enum nk_chart_type, struct nk_color, struct nk_color active, int num, float min, float max);
3383 NK_API void nk_chart_add_slot(struct nk_context *ctx, const enum nk_chart_type, int count, float min_value, float max_value);
3384 NK_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);
3385 NK_API nk_flags nk_chart_push(struct nk_context*, float);
3386 NK_API nk_flags nk_chart_push_slot(struct nk_context*, float, int);
3387 NK_API void nk_chart_end(struct nk_context*);
3388 NK_API void nk_plot(struct nk_context*, enum nk_chart_type, const float *values, int count, int offset);
3389 NK_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);
3390 /* =============================================================================
3391  *
3392  * POPUP
3393  *
3394  * ============================================================================= */
3395 NK_API int nk_popup_begin(struct nk_context*, enum nk_popup_type, const char*, nk_flags, struct nk_rect bounds);
3396 NK_API void nk_popup_close(struct nk_context*);
3397 NK_API void nk_popup_end(struct nk_context*);
3398 /* =============================================================================
3399  *
3400  * COMBOBOX
3401  *
3402  * ============================================================================= */
3403 NK_API int nk_combo(struct nk_context*, const char **items, int count, int selected, int item_height, struct nk_vec2 size);
3404 NK_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);
3405 NK_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);
3406 NK_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);
3407 NK_API void nk_combobox(struct nk_context*, const char **items, int count, int *selected, int item_height, struct nk_vec2 size);
3408 NK_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);
3409 NK_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);
3410 NK_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);
3411 /* =============================================================================
3412  *
3413  * ABSTRACT COMBOBOX
3414  *
3415  * ============================================================================= */
3416 NK_API int nk_combo_begin_text(struct nk_context*, const char *selected, int, struct nk_vec2 size);
3417 NK_API int nk_combo_begin_label(struct nk_context*, const char *selected, struct nk_vec2 size);
3418 NK_API int nk_combo_begin_color(struct nk_context*, struct nk_color color, struct nk_vec2 size);
3419 NK_API int nk_combo_begin_symbol(struct nk_context*, enum nk_symbol_type, struct nk_vec2 size);
3420 NK_API int nk_combo_begin_symbol_label(struct nk_context*, const char *selected, enum nk_symbol_type, struct nk_vec2 size);
3421 NK_API int nk_combo_begin_symbol_text(struct nk_context*, const char *selected, int, enum nk_symbol_type, struct nk_vec2 size);
3422 NK_API int nk_combo_begin_image(struct nk_context*, struct nk_image img, struct nk_vec2 size);
3423 NK_API int nk_combo_begin_image_label(struct nk_context*, const char *selected, struct nk_image, struct nk_vec2 size);
3424 NK_API int nk_combo_begin_image_text(struct nk_context*, const char *selected, int, struct nk_image, struct nk_vec2 size);
3425 NK_API int nk_combo_item_label(struct nk_context*, const char*, nk_flags alignment);
3426 NK_API int nk_combo_item_text(struct nk_context*, const char*,int, nk_flags alignment);
3427 NK_API int nk_combo_item_image_label(struct nk_context*, struct nk_image, const char*, nk_flags alignment);
3428 NK_API int nk_combo_item_image_text(struct nk_context*, struct nk_image, const char*, int,nk_flags alignment);
3429 NK_API int nk_combo_item_symbol_label(struct nk_context*, enum nk_symbol_type, const char*, nk_flags alignment);
3430 NK_API int nk_combo_item_symbol_text(struct nk_context*, enum nk_symbol_type, const char*, int, nk_flags alignment);
3431 NK_API void nk_combo_close(struct nk_context*);
3432 NK_API void nk_combo_end(struct nk_context*);
3433 /* =============================================================================
3434  *
3435  * CONTEXTUAL
3436  *
3437  * ============================================================================= */
3438 NK_API int nk_contextual_begin(struct nk_context*, nk_flags, struct nk_vec2, struct nk_rect trigger_bounds);
3439 NK_API int nk_contextual_item_text(struct nk_context*, const char*, int,nk_flags align);
3440 NK_API int nk_contextual_item_label(struct nk_context*, const char*, nk_flags align);
3441 NK_API int nk_contextual_item_image_label(struct nk_context*, struct nk_image, const char*, nk_flags alignment);
3442 NK_API int nk_contextual_item_image_text(struct nk_context*, struct nk_image, const char*, int len, nk_flags alignment);
3443 NK_API int nk_contextual_item_symbol_label(struct nk_context*, enum nk_symbol_type, const char*, nk_flags alignment);
3444 NK_API int nk_contextual_item_symbol_text(struct nk_context*, enum nk_symbol_type, const char*, int, nk_flags alignment);
3445 NK_API void nk_contextual_close(struct nk_context*);
3446 NK_API void nk_contextual_end(struct nk_context*);
3447 /* =============================================================================
3448  *
3449  * TOOLTIP
3450  *
3451  * ============================================================================= */
3452 NK_API void nk_tooltip(struct nk_context*, const char*);
3453 #ifdef NK_INCLUDE_STANDARD_VARARGS
3454 NK_API void nk_tooltipf(struct nk_context*, NK_PRINTF_FORMAT_STRING const char*, ...) NK_PRINTF_VARARG_FUNC(2);
3455 NK_API void nk_tooltipfv(struct nk_context*, NK_PRINTF_FORMAT_STRING const char*, va_list) NK_PRINTF_VALIST_FUNC(2);
3456 #endif
3457 NK_API int nk_tooltip_begin(struct nk_context*, float width);
3458 NK_API void nk_tooltip_end(struct nk_context*);
3459 /* =============================================================================
3460  *
3461  * MENU
3462  *
3463  * ============================================================================= */
3464 NK_API void nk_menubar_begin(struct nk_context*);
3465 NK_API void nk_menubar_end(struct nk_context*);
3466 NK_API int nk_menu_begin_text(struct nk_context*, const char* title, int title_len, nk_flags align, struct nk_vec2 size);
3467 NK_API int nk_menu_begin_label(struct nk_context*, const char*, nk_flags align, struct nk_vec2 size);
3468 NK_API int nk_menu_begin_image(struct nk_context*, const char*, struct nk_image, struct nk_vec2 size);
3469 NK_API int nk_menu_begin_image_text(struct nk_context*, const char*, int,nk_flags align,struct nk_image, struct nk_vec2 size);
3470 NK_API int nk_menu_begin_image_label(struct nk_context*, const char*, nk_flags align,struct nk_image, struct nk_vec2 size);
3471 NK_API int nk_menu_begin_symbol(struct nk_context*, const char*, enum nk_symbol_type, struct nk_vec2 size);
3472 NK_API int nk_menu_begin_symbol_text(struct nk_context*, const char*, int,nk_flags align,enum nk_symbol_type, struct nk_vec2 size);
3473 NK_API int nk_menu_begin_symbol_label(struct nk_context*, const char*, nk_flags align,enum nk_symbol_type, struct nk_vec2 size);
3474 NK_API int nk_menu_item_text(struct nk_context*, const char*, int,nk_flags align);
3475 NK_API int nk_menu_item_label(struct nk_context*, const char*, nk_flags alignment);
3476 NK_API int nk_menu_item_image_label(struct nk_context*, struct nk_image, const char*, nk_flags alignment);
3477 NK_API int nk_menu_item_image_text(struct nk_context*, struct nk_image, const char*, int len, nk_flags alignment);
3478 NK_API int nk_menu_item_symbol_text(struct nk_context*, enum nk_symbol_type, const char*, int, nk_flags alignment);
3479 NK_API int nk_menu_item_symbol_label(struct nk_context*, enum nk_symbol_type, const char*, nk_flags alignment);
3480 NK_API void nk_menu_close(struct nk_context*);
3481 NK_API void nk_menu_end(struct nk_context*);
3482 /* =============================================================================
3483  *
3484  * STYLE
3485  *
3486  * ============================================================================= */
3517 };
3527 };
3528 NK_API void nk_style_default(struct nk_context*);
3529 NK_API void nk_style_from_table(struct nk_context*, const struct nk_color*);
3530 NK_API void nk_style_load_cursor(struct nk_context*, enum nk_style_cursor, const struct nk_cursor*);
3531 NK_API void nk_style_load_all_cursors(struct nk_context*, struct nk_cursor*);
3533 NK_API void nk_style_set_font(struct nk_context*, const struct nk_user_font*);
3534 NK_API int nk_style_set_cursor(struct nk_context*, enum nk_style_cursor);
3535 NK_API void nk_style_show_cursor(struct nk_context*);
3536 NK_API void nk_style_hide_cursor(struct nk_context*);
3537 
3538 NK_API int nk_style_push_font(struct nk_context*, const struct nk_user_font*);
3539 NK_API int nk_style_push_float(struct nk_context*, float*, float);
3540 NK_API int nk_style_push_vec2(struct nk_context*, struct nk_vec2*, struct nk_vec2);
3541 NK_API int nk_style_push_style_item(struct nk_context*, struct nk_style_item*, struct nk_style_item);
3542 NK_API int nk_style_push_flags(struct nk_context*, nk_flags*, nk_flags);
3543 NK_API int nk_style_push_color(struct nk_context*, struct nk_color*, struct nk_color);
3544 
3545 NK_API int nk_style_pop_font(struct nk_context*);
3546 NK_API int nk_style_pop_float(struct nk_context*);
3547 NK_API int nk_style_pop_vec2(struct nk_context*);
3548 NK_API int nk_style_pop_style_item(struct nk_context*);
3549 NK_API int nk_style_pop_flags(struct nk_context*);
3550 NK_API int nk_style_pop_color(struct nk_context*);
3551 /* =============================================================================
3552  *
3553  * COLOR
3554  *
3555  * ============================================================================= */
3556 NK_API struct nk_color nk_rgb(int r, int g, int b);
3557 NK_API struct nk_color nk_rgb_iv(const int *rgb);
3558 NK_API struct nk_color nk_rgb_bv(const nk_byte* rgb);
3559 NK_API struct nk_color nk_rgb_f(float r, float g, float b);
3560 NK_API struct nk_color nk_rgb_fv(const float *rgb);
3561 NK_API struct nk_color nk_rgb_cf(struct nk_colorf c);
3562 NK_API struct nk_color nk_rgb_hex(const char *rgb);
3563 
3564 NK_API struct nk_color nk_rgba(int r, int g, int b, int a);
3565 NK_API struct nk_color nk_rgba_u32(nk_uint);
3566 NK_API struct nk_color nk_rgba_iv(const int *rgba);
3567 NK_API struct nk_color nk_rgba_bv(const nk_byte *rgba);
3568 NK_API struct nk_color nk_rgba_f(float r, float g, float b, float a);
3569 NK_API struct nk_color nk_rgba_fv(const float *rgba);
3570 NK_API struct nk_color nk_rgba_cf(struct nk_colorf c);
3571 NK_API struct nk_color nk_rgba_hex(const char *rgb);
3572 
3573 NK_API struct nk_colorf nk_hsva_colorf(float h, float s, float v, float a);
3574 NK_API struct nk_colorf nk_hsva_colorfv(float *c);
3575 NK_API void nk_colorf_hsva_f(float *out_h, float *out_s, float *out_v, float *out_a, struct nk_colorf in);
3576 NK_API void nk_colorf_hsva_fv(float *hsva, struct nk_colorf in);
3577 
3578 NK_API struct nk_color nk_hsv(int h, int s, int v);
3579 NK_API struct nk_color nk_hsv_iv(const int *hsv);
3580 NK_API struct nk_color nk_hsv_bv(const nk_byte *hsv);
3581 NK_API struct nk_color nk_hsv_f(float h, float s, float v);
3582 NK_API struct nk_color nk_hsv_fv(const float *hsv);
3583 
3584 NK_API struct nk_color nk_hsva(int h, int s, int v, int a);
3585 NK_API struct nk_color nk_hsva_iv(const int *hsva);
3586 NK_API struct nk_color nk_hsva_bv(const nk_byte *hsva);
3587 NK_API struct nk_color nk_hsva_f(float h, float s, float v, float a);
3588 NK_API struct nk_color nk_hsva_fv(const float *hsva);
3589 
3590 /* color (conversion nuklear --> user) */
3591 NK_API void nk_color_f(float *r, float *g, float *b, float *a, struct nk_color);
3592 NK_API void nk_color_fv(float *rgba_out, struct nk_color);
3593 NK_API struct nk_colorf nk_color_cf(struct nk_color);
3594 NK_API void nk_color_d(double *r, double *g, double *b, double *a, struct nk_color);
3595 NK_API void nk_color_dv(double *rgba_out, struct nk_color);
3596 
3597 NK_API nk_uint nk_color_u32(struct nk_color);
3598 NK_API void nk_color_hex_rgba(char *output, struct nk_color);
3599 NK_API void nk_color_hex_rgb(char *output, struct nk_color);
3600 
3601 NK_API void nk_color_hsv_i(int *out_h, int *out_s, int *out_v, struct nk_color);
3602 NK_API void nk_color_hsv_b(nk_byte *out_h, nk_byte *out_s, nk_byte *out_v, struct nk_color);
3603 NK_API void nk_color_hsv_iv(int *hsv_out, struct nk_color);
3604 NK_API void nk_color_hsv_bv(nk_byte *hsv_out, struct nk_color);
3605 NK_API void nk_color_hsv_f(float *out_h, float *out_s, float *out_v, struct nk_color);
3606 NK_API void nk_color_hsv_fv(float *hsv_out, struct nk_color);
3607 
3608 NK_API void nk_color_hsva_i(int *h, int *s, int *v, int *a, struct nk_color);
3609 NK_API void nk_color_hsva_b(nk_byte *h, nk_byte *s, nk_byte *v, nk_byte *a, struct nk_color);
3610 NK_API void nk_color_hsva_iv(int *hsva_out, struct nk_color);
3611 NK_API void nk_color_hsva_bv(nk_byte *hsva_out, struct nk_color);
3612 NK_API void nk_color_hsva_f(float *out_h, float *out_s, float *out_v, float *out_a, struct nk_color);
3613 NK_API void nk_color_hsva_fv(float *hsva_out, struct nk_color);
3614 /* =============================================================================
3615  *
3616  * IMAGE
3617  *
3618  * ============================================================================= */
3619 NK_API nk_handle nk_handle_ptr(void*);
3620 NK_API nk_handle nk_handle_id(int);
3621 NK_API struct nk_image nk_image_handle(nk_handle);
3622 NK_API struct nk_image nk_image_ptr(void*);
3623 NK_API struct nk_image nk_image_id(int);
3624 NK_API int nk_image_is_subimage(const struct nk_image* img);
3625 NK_API struct nk_image nk_subimage_ptr(void*, unsigned short w, unsigned short h, struct nk_rect sub_region);
3626 NK_API struct nk_image nk_subimage_id(int, unsigned short w, unsigned short h, struct nk_rect sub_region);
3627 NK_API struct nk_image nk_subimage_handle(nk_handle, unsigned short w, unsigned short h, struct nk_rect sub_region);
3628 /* =============================================================================
3629  *
3630  * MATH
3631  *
3632  * ============================================================================= */
3633 NK_API nk_hash nk_murmur_hash(const void *key, int len, nk_hash seed);
3634 NK_API void nk_triangle_from_direction(struct nk_vec2 *result, struct nk_rect r, float pad_x, float pad_y, enum nk_heading);
3635 
3636 NK_API struct nk_vec2 nk_vec2(float x, float y);
3637 NK_API struct nk_vec2 nk_vec2i(int x, int y);
3638 NK_API struct nk_vec2 nk_vec2v(const float *xy);
3639 NK_API struct nk_vec2 nk_vec2iv(const int *xy);
3640 
3642 NK_API struct nk_rect nk_rect(float x, float y, float w, float h);
3643 NK_API struct nk_rect nk_recti(int x, int y, int w, int h);
3644 NK_API struct nk_rect nk_recta(struct nk_vec2 pos, struct nk_vec2 size);
3645 NK_API struct nk_rect nk_rectv(const float *xywh);
3646 NK_API struct nk_rect nk_rectiv(const int *xywh);
3647 NK_API struct nk_vec2 nk_rect_pos(struct nk_rect);
3648 NK_API struct nk_vec2 nk_rect_size(struct nk_rect);
3649 /* =============================================================================
3650  *
3651  * STRING
3652  *
3653  * ============================================================================= */
3654 NK_API int nk_strlen(const char *str);
3655 NK_API int nk_stricmp(const char *s1, const char *s2);
3656 NK_API int nk_stricmpn(const char *s1, const char *s2, int n);
3657 NK_API int nk_strtoi(const char *str, const char **endptr);
3658 NK_API float nk_strtof(const char *str, const char **endptr);
3659 NK_API double nk_strtod(const char *str, const char **endptr);
3660 NK_API int nk_strfilter(const char *text, const char *regexp);
3661 NK_API int nk_strmatch_fuzzy_string(char const *str, char const *pattern, int *out_score);
3662 NK_API int nk_strmatch_fuzzy_text(const char *txt, int txt_len, const char *pattern, int *out_score);
3663 /* =============================================================================
3664  *
3665  * UTF-8
3666  *
3667  * ============================================================================= */
3668 NK_API int nk_utf_decode(const char*, nk_rune*, int);
3669 NK_API int nk_utf_encode(nk_rune, char*, int);
3670 NK_API int nk_utf_len(const char*, int byte_len);
3671 NK_API const char* nk_utf_at(const char *buffer, int length, int index, nk_rune *unicode, int *len);
3672 /* ===============================================================
3673  *
3674  * FONT
3675  *
3676  * ===============================================================*/
3677 /* Font handling in this library was designed to be quite customizable and lets
3678  you decide what you want to use and what you want to provide. There are three
3679  different ways to use the font atlas. The first two will use your font
3680  handling scheme and only requires essential data to run nuklear. The next
3681  slightly more advanced features is font handling with vertex buffer output.
3682  Finally the most complex API wise is using nuklear's font baking API.
3683 
3684  1.) Using your own implementation without vertex buffer output
3685  --------------------------------------------------------------
3686  So first up the easiest way to do font handling is by just providing a
3687  `nk_user_font` struct which only requires the height in pixel of the used
3688  font and a callback to calculate the width of a string. This way of handling
3689  fonts is best fitted for using the normal draw shape command API where you
3690  do all the text drawing yourself and the library does not require any kind
3691  of deeper knowledge about which font handling mechanism you use.
3692  IMPORTANT: the `nk_user_font` pointer provided to nuklear has to persist
3693  over the complete life time! I know this sucks but it is currently the only
3694  way to switch between fonts.
3695 
3696  float your_text_width_calculation(nk_handle handle, float height, const char *text, int len)
3697  {
3698  your_font_type *type = handle.ptr;
3699  float text_width = ...;
3700  return text_width;
3701  }
3702 
3703  struct nk_user_font font;
3704  font.userdata.ptr = &your_font_class_or_struct;
3705  font.height = your_font_height;
3706  font.width = your_text_width_calculation;
3707 
3708  struct nk_context ctx;
3709  nk_init_default(&ctx, &font);
3710 
3711  2.) Using your own implementation with vertex buffer output
3712  --------------------------------------------------------------
3713  While the first approach works fine if you don't want to use the optional
3714  vertex buffer output it is not enough if you do. To get font handling working
3715  for these cases you have to provide two additional parameters inside the
3716  `nk_user_font`. First a texture atlas handle used to draw text as subimages
3717  of a bigger font atlas texture and a callback to query a character's glyph
3718  information (offset, size, ...). So it is still possible to provide your own
3719  font and use the vertex buffer output.
3720 
3721  float your_text_width_calculation(nk_handle handle, float height, const char *text, int len)
3722  {
3723  your_font_type *type = handle.ptr;
3724  float text_width = ...;
3725  return text_width;
3726  }
3727  void query_your_font_glyph(nk_handle handle, float font_height, struct nk_user_font_glyph *glyph, nk_rune codepoint, nk_rune next_codepoint)
3728  {
3729  your_font_type *type = handle.ptr;
3730  glyph.width = ...;
3731  glyph.height = ...;
3732  glyph.xadvance = ...;
3733  glyph.uv[0].x = ...;
3734  glyph.uv[0].y = ...;
3735  glyph.uv[1].x = ...;
3736  glyph.uv[1].y = ...;
3737  glyph.offset.x = ...;
3738  glyph.offset.y = ...;
3739  }
3740 
3741  struct nk_user_font font;
3742  font.userdata.ptr = &your_font_class_or_struct;
3743  font.height = your_font_height;
3744  font.width = your_text_width_calculation;
3745  font.query = query_your_font_glyph;
3746  font.texture.id = your_font_texture;
3747 
3748  struct nk_context ctx;
3749  nk_init_default(&ctx, &font);
3750 
3751  3.) Nuklear font baker
3752  ------------------------------------
3753  The final approach if you do not have a font handling functionality or don't
3754  want to use it in this library is by using the optional font baker.
3755  The font baker APIs can be used to create a font plus font atlas texture
3756  and can be used with or without the vertex buffer output.
3757 
3758  It still uses the `nk_user_font` struct and the two different approaches
3759  previously stated still work. The font baker is not located inside
3760  `nk_context` like all other systems since it can be understood as more of
3761  an extension to nuklear and does not really depend on any `nk_context` state.
3762 
3763  Font baker need to be initialized first by one of the nk_font_atlas_init_xxx
3764  functions. If you don't care about memory just call the default version
3765  `nk_font_atlas_init_default` which will allocate all memory from the standard library.
3766  If you want to control memory allocation but you don't care if the allocated
3767  memory is temporary and therefore can be freed directly after the baking process
3768  is over or permanent you can call `nk_font_atlas_init`.
3769 
3770  After successfully initializing the font baker you can add Truetype(.ttf) fonts from
3771  different sources like memory or from file by calling one of the `nk_font_atlas_add_xxx`.
3772  functions. Adding font will permanently store each font, font config and ttf memory block(!)
3773  inside the font atlas and allows to reuse the font atlas. If you don't want to reuse
3774  the font baker by for example adding additional fonts you can call
3775  `nk_font_atlas_cleanup` after the baking process is over (after calling nk_font_atlas_end).
3776 
3777  As soon as you added all fonts you wanted you can now start the baking process
3778  for every selected glyph to image by calling `nk_font_atlas_bake`.
3779  The baking process returns image memory, width and height which can be used to
3780  either create your own image object or upload it to any graphics library.
3781  No matter which case you finally have to call `nk_font_atlas_end` which
3782  will free all temporary memory including the font atlas image so make sure
3783  you created our texture beforehand. `nk_font_atlas_end` requires a handle
3784  to your font texture or object and optionally fills a `struct nk_draw_null_texture`
3785  which can be used for the optional vertex output. If you don't want it just
3786  set the argument to `NULL`.
3787 
3788  At this point you are done and if you don't want to reuse the font atlas you
3789  can call `nk_font_atlas_cleanup` to free all truetype blobs and configuration
3790  memory. Finally if you don't use the font atlas and any of it's fonts anymore
3791  you need to call `nk_font_atlas_clear` to free all memory still being used.
3792 
3793  struct nk_font_atlas atlas;
3794  nk_font_atlas_init_default(&atlas);
3795  nk_font_atlas_begin(&atlas);
3796  nk_font *font = nk_font_atlas_add_from_file(&atlas, "Path/To/Your/TTF_Font.ttf", 13, 0);
3797  nk_font *font2 = nk_font_atlas_add_from_file(&atlas, "Path/To/Your/TTF_Font2.ttf", 16, 0);
3798  const void* img = nk_font_atlas_bake(&atlas, &img_width, &img_height, NK_FONT_ATLAS_RGBA32);
3799  nk_font_atlas_end(&atlas, nk_handle_id(texture), 0);
3800 
3801  struct nk_context ctx;
3802  nk_init_default(&ctx, &font->handle);
3803  while (1) {
3804 
3805  }
3806  nk_font_atlas_clear(&atlas);
3807 
3808  The font baker API is probably the most complex API inside this library and
3809  I would suggest reading some of my examples `example/` to get a grip on how
3810  to use the font atlas. There are a number of details I left out. For example
3811  how to merge fonts, configure a font with `nk_font_config` to use other languages,
3812  use another texture coordinate format and a lot more:
3813 
3814  struct nk_font_config cfg = nk_font_config(font_pixel_height);
3815  cfg.merge_mode = nk_false or nk_true;
3816  cfg.range = nk_font_korean_glyph_ranges();
3817  cfg.coord_type = NK_COORD_PIXEL;
3818  nk_font *font = nk_font_atlas_add_from_file(&atlas, "Path/To/Your/TTF_Font.ttf", 13, &cfg);
3819 
3820 */
3821 struct nk_user_font_glyph;
3822 typedef float(*nk_text_width_f)(nk_handle, float h, const char*, int len);
3823 typedef void(*nk_query_font_glyph_f)(nk_handle handle, float font_height,
3824  struct nk_user_font_glyph *glyph,
3825  nk_rune codepoint, nk_rune next_codepoint);
3826 
3827 #if defined(NK_INCLUDE_VERTEX_BUFFER_OUTPUT) || defined(NK_INCLUDE_SOFTWARE_FONT)
3828 struct nk_user_font_glyph {
3829  struct nk_vec2 uv[2];
3830  /* texture coordinates */
3831  struct nk_vec2 offset;
3832  /* offset between top left and glyph */
3833  float width, height;
3834  /* size of the glyph */
3835  float xadvance;
3836  /* offset to the next glyph */
3837 };
3838 #endif
3839 
3841  nk_handle userdata;
3842  /* user provided font handle */
3843  float height;
3844  /* max height of the font */
3846  /* font string width in pixel callback */
3847 #ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
3849  /* font glyph callback to query drawing info */
3850  nk_handle texture;
3851  /* texture handle to the used font atlas or texture */
3852 #endif
3853 };
3854 
3855 #ifdef NK_INCLUDE_FONT_BAKING
3856 enum nk_font_coord_type {
3857  NK_COORD_UV, /* texture coordinates inside font glyphs are clamped between 0-1 */
3858  NK_COORD_PIXEL /* texture coordinates inside font glyphs are in absolute pixel */
3859 };
3860 
3861 struct nk_font;
3862 struct nk_baked_font {
3863  float height;
3864  /* height of the font */
3865  float ascent, descent;
3866  /* font glyphs ascent and descent */
3867  nk_rune glyph_offset;
3868  /* glyph array offset inside the font glyph baking output array */
3869  nk_rune glyph_count;
3870  /* number of glyphs of this font inside the glyph baking array output */
3871  const nk_rune *ranges;
3872  /* font codepoint ranges as pairs of (from/to) and 0 as last element */
3873 };
3874 
3875 struct nk_font_config {
3876  struct nk_font_config *next;
3877  /* NOTE: only used internally */
3878  void *ttf_blob;
3879  /* pointer to loaded TTF file memory block.
3880  * NOTE: not needed for nk_font_atlas_add_from_memory and nk_font_atlas_add_from_file. */
3881  nk_size ttf_size;
3882  /* size of the loaded TTF file memory block
3883  * NOTE: not needed for nk_font_atlas_add_from_memory and nk_font_atlas_add_from_file. */
3884 
3885  unsigned char ttf_data_owned_by_atlas;
3886  /* used inside font atlas: default to: 0*/
3887  unsigned char merge_mode;
3888  /* merges this font into the last font */
3889  unsigned char pixel_snap;
3890  /* align every character to pixel boundary (if true set oversample (1,1)) */
3891  unsigned char oversample_v, oversample_h;
3892  /* rasterize at hight quality for sub-pixel position */
3893  unsigned char padding[3];
3894 
3895  float size;
3896  /* baked pixel height of the font */
3897  enum nk_font_coord_type coord_type;
3898  /* texture coordinate format with either pixel or UV coordinates */
3899  struct nk_vec2 spacing;
3900  /* extra pixel spacing between glyphs */
3901  const nk_rune *range;
3902  /* list of unicode ranges (2 values per range, zero terminated) */
3903  struct nk_baked_font *font;
3904  /* font to setup in the baking process: NOTE: not needed for font atlas */
3905  nk_rune fallback_glyph;
3906  /* fallback glyph to use if a given rune is not found */
3907  struct nk_font_config *n;
3908  struct nk_font_config *p;
3909 };
3910 
3911 struct nk_font_glyph {
3912  nk_rune codepoint;
3913  float xadvance;
3914  float x0, y0, x1, y1, w, h;
3915  float u0, v0, u1, v1;
3916 };
3917 
3918 struct nk_font {
3919  struct nk_font *next;
3920  struct nk_user_font handle;
3921  struct nk_baked_font info;
3922  float scale;
3923  struct nk_font_glyph *glyphs;
3924  const struct nk_font_glyph *fallback;
3925  nk_rune fallback_codepoint;
3926  nk_handle texture;
3927  struct nk_font_config *config;
3928 };
3929 
3930 enum nk_font_atlas_format {
3931  NK_FONT_ATLAS_ALPHA8,
3932  NK_FONT_ATLAS_RGBA32
3933 };
3934 
3935 struct nk_font_atlas {
3936  void *pixel;
3937  int tex_width;
3938  int tex_height;
3939 
3940  struct nk_allocator permanent;
3941  struct nk_allocator temporary;
3942 
3943  struct nk_recti custom;
3944  struct nk_cursor cursors[NK_CURSOR_COUNT];
3945 
3946  int glyph_count;
3947  struct nk_font_glyph *glyphs;
3948  struct nk_font *default_font;
3949  struct nk_font *fonts;
3950  struct nk_font_config *config;
3951  int font_num;
3952 };
3953 
3954 /* some language glyph codepoint ranges */
3955 NK_API const nk_rune *nk_font_default_glyph_ranges(void);
3956 NK_API const nk_rune *nk_font_chinese_glyph_ranges(void);
3957 NK_API const nk_rune *nk_font_cyrillic_glyph_ranges(void);
3958 NK_API const nk_rune *nk_font_korean_glyph_ranges(void);
3959 
3960 #ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
3961 NK_API void nk_font_atlas_init_default(struct nk_font_atlas*);
3962 #endif
3963 NK_API void nk_font_atlas_init(struct nk_font_atlas*, struct nk_allocator*);
3964 NK_API void nk_font_atlas_init_custom(struct nk_font_atlas*, struct nk_allocator *persistent, struct nk_allocator *transient);
3965 NK_API void nk_font_atlas_begin(struct nk_font_atlas*);
3966 NK_API struct nk_font_config nk_font_config(float pixel_height);
3967 NK_API struct nk_font *nk_font_atlas_add(struct nk_font_atlas*, const struct nk_font_config*);
3968 #ifdef NK_INCLUDE_DEFAULT_FONT
3969 NK_API struct nk_font* nk_font_atlas_add_default(struct nk_font_atlas*, float height, const struct nk_font_config*);
3970 #endif
3971 NK_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);
3972 #ifdef NK_INCLUDE_STANDARD_IO
3973 NK_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*);
3974 #endif
3975 NK_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*);
3976 NK_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);
3977 NK_API const void* nk_font_atlas_bake(struct nk_font_atlas*, int *width, int *height, enum nk_font_atlas_format);
3978 NK_API void nk_font_atlas_end(struct nk_font_atlas*, nk_handle tex, struct nk_draw_null_texture*);
3979 NK_API const struct nk_font_glyph* nk_font_find_glyph(struct nk_font*, nk_rune unicode);
3980 NK_API void nk_font_atlas_cleanup(struct nk_font_atlas *atlas);
3981 NK_API void nk_font_atlas_clear(struct nk_font_atlas*);
3982 
3983 #endif
3984 
3985 /* ==============================================================
3986  *
3987  * MEMORY BUFFER
3988  *
3989  * ===============================================================*/
3990 /* A basic (double)-buffer with linear allocation and resetting as only
3991  freeing policy. The buffer's main purpose is to control all memory management
3992  inside the GUI toolkit and still leave memory control as much as possible in
3993  the hand of the user while also making sure the library is easy to use if
3994  not as much control is needed.
3995  In general all memory inside this library can be provided from the user in
3996  three different ways.
3997 
3998  The first way and the one providing most control is by just passing a fixed
3999  size memory block. In this case all control lies in the hand of the user
4000  since he can exactly control where the memory comes from and how much memory
4001  the library should consume. Of course using the fixed size API removes the
4002  ability to automatically resize a buffer if not enough memory is provided so
4003  you have to take over the resizing. While being a fixed sized buffer sounds
4004  quite limiting, it is very effective in this library since the actual memory
4005  consumption is quite stable and has a fixed upper bound for a lot of cases.
4006 
4007  If you don't want to think about how much memory the library should allocate
4008  at all time or have a very dynamic UI with unpredictable memory consumption
4009  habits but still want control over memory allocation you can use the dynamic
4010  allocator based API. The allocator consists of two callbacks for allocating
4011  and freeing memory and optional userdata so you can plugin your own allocator.
4012 
4013  The final and easiest way can be used by defining
4014  NK_INCLUDE_DEFAULT_ALLOCATOR which uses the standard library memory
4015  allocation functions malloc and free and takes over complete control over
4016  memory in this library.
4017 */
4019  void *memory;
4020  unsigned int type;
4021  nk_size size;
4022  nk_size allocated;
4023  nk_size needed;
4024  nk_size calls;
4025 };
4026 
4030 };
4031 
4036 };
4037 
4039  int active;
4040  nk_size offset;
4041 };
4042 
4043 struct nk_memory {void *ptr;nk_size size;};
4044 struct nk_buffer {
4046  /* buffer marker to free a buffer to a certain offset */
4047  struct nk_allocator pool;
4048  /* allocator callback for dynamic buffers */
4050  /* memory management type */
4051  struct nk_memory memory;
4052  /* memory and size of the current memory block */
4054  /* growing factor for dynamic memory management */
4055  nk_size allocated;
4056  /* total amount of memory allocated */
4057  nk_size needed;
4058  /* totally consumed memory given that enough memory is present */
4059  nk_size calls;
4060  /* number of allocation calls */
4061  nk_size size;
4062  /* current size of the buffer */
4063 };
4064 
4065 #ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
4066 NK_API void nk_buffer_init_default(struct nk_buffer*);
4067 #endif
4068 NK_API void nk_buffer_init(struct nk_buffer*, const struct nk_allocator*, nk_size size);
4069 NK_API void nk_buffer_init_fixed(struct nk_buffer*, void *memory, nk_size size);
4070 NK_API void nk_buffer_info(struct nk_memory_status*, struct nk_buffer*);
4071 NK_API void nk_buffer_push(struct nk_buffer*, enum nk_buffer_allocation_type type, const void *memory, nk_size size, nk_size align);
4074 NK_API void nk_buffer_clear(struct nk_buffer*);
4075 NK_API void nk_buffer_free(struct nk_buffer*);
4076 NK_API void *nk_buffer_memory(struct nk_buffer*);
4077 NK_API const void *nk_buffer_memory_const(const struct nk_buffer*);
4078 NK_API nk_size nk_buffer_total(struct nk_buffer*);
4079 
4080 /* ==============================================================
4081  *
4082  * STRING
4083  *
4084  * ===============================================================*/
4085 /* Basic string buffer which is only used in context with the text editor
4086  * to manage and manipulate dynamic or fixed size string content. This is _NOT_
4087  * the default string handling method. The only instance you should have any contact
4088  * with this API is if you interact with an `nk_text_edit` object inside one of the
4089  * copy and paste functions and even there only for more advanced cases. */
4090 struct nk_str {
4092  int len; /* in codepoints/runes/glyphs */
4093 };
4094 
4095 #ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
4096 NK_API void nk_str_init_default(struct nk_str*);
4097 #endif
4098 NK_API void nk_str_init(struct nk_str*, const struct nk_allocator*, nk_size size);
4099 NK_API void nk_str_init_fixed(struct nk_str*, void *memory, nk_size size);
4100 NK_API void nk_str_clear(struct nk_str*);
4101 NK_API void nk_str_free(struct nk_str*);
4102 
4103 NK_API int nk_str_append_text_char(struct nk_str*, const char*, int);
4104 NK_API int nk_str_append_str_char(struct nk_str*, const char*);
4105 NK_API int nk_str_append_text_utf8(struct nk_str*, const char*, int);
4106 NK_API int nk_str_append_str_utf8(struct nk_str*, const char*);
4107 NK_API int nk_str_append_text_runes(struct nk_str*, const nk_rune*, int);
4108 NK_API int nk_str_append_str_runes(struct nk_str*, const nk_rune*);
4109 
4110 NK_API int nk_str_insert_at_char(struct nk_str*, int pos, const char*, int);
4111 NK_API int nk_str_insert_at_rune(struct nk_str*, int pos, const char*, int);
4112 
4113 NK_API int nk_str_insert_text_char(struct nk_str*, int pos, const char*, int);
4114 NK_API int nk_str_insert_str_char(struct nk_str*, int pos, const char*);
4115 NK_API int nk_str_insert_text_utf8(struct nk_str*, int pos, const char*, int);
4116 NK_API int nk_str_insert_str_utf8(struct nk_str*, int pos, const char*);
4117 NK_API int nk_str_insert_text_runes(struct nk_str*, int pos, const nk_rune*, int);
4118 NK_API int nk_str_insert_str_runes(struct nk_str*, int pos, const nk_rune*);
4119 
4120 NK_API void nk_str_remove_chars(struct nk_str*, int len);
4121 NK_API void nk_str_remove_runes(struct nk_str *str, int len);
4122 NK_API void nk_str_delete_chars(struct nk_str*, int pos, int len);
4123 NK_API void nk_str_delete_runes(struct nk_str*, int pos, int len);
4124 
4125 NK_API char *nk_str_at_char(struct nk_str*, int pos);
4126 NK_API char *nk_str_at_rune(struct nk_str*, int pos, nk_rune *unicode, int *len);
4127 NK_API nk_rune nk_str_rune_at(const struct nk_str*, int pos);
4128 NK_API const char *nk_str_at_char_const(const struct nk_str*, int pos);
4129 NK_API const char *nk_str_at_const(const struct nk_str*, int pos, nk_rune *unicode, int *len);
4130 
4131 NK_API char *nk_str_get(struct nk_str*);
4132 NK_API const char *nk_str_get_const(const struct nk_str*);
4133 NK_API int nk_str_len(struct nk_str*);
4134 NK_API int nk_str_len_char(struct nk_str*);
4135 
4136 /*===============================================================
4137  *
4138  * TEXT EDITOR
4139  *
4140  * ===============================================================*/
4141 /* Editing text in this library is handled by either `nk_edit_string` or
4142  * `nk_edit_buffer`. But like almost everything in this library there are multiple
4143  * ways of doing it and a balance between control and ease of use with memory
4144  * as well as functionality controlled by flags.
4145  *
4146  * This library generally allows three different levels of memory control:
4147  * First of is the most basic way of just providing a simple char array with
4148  * string length. This method is probably the easiest way of handling simple
4149  * user text input. Main upside is complete control over memory while the biggest
4150  * downside in comparison with the other two approaches is missing undo/redo.
4151  *
4152  * For UIs that require undo/redo the second way was created. It is based on
4153  * a fixed size nk_text_edit struct, which has an internal undo/redo stack.
4154  * This is mainly useful if you want something more like a text editor but don't want
4155  * to have a dynamically growing buffer.
4156  *
4157  * The final way is using a dynamically growing nk_text_edit struct, which
4158  * has both a default version if you don't care where memory comes from and an
4159  * allocator version if you do. While the text editor is quite powerful for its
4160  * complexity I would not recommend editing gigabytes of data with it.
4161  * It is rather designed for uses cases which make sense for a GUI library not for
4162  * an full blown text editor.
4163  */
4164 #ifndef NK_TEXTEDIT_UNDOSTATECOUNT
4165 #define NK_TEXTEDIT_UNDOSTATECOUNT 99
4166 #endif
4167 
4168 #ifndef NK_TEXTEDIT_UNDOCHARCOUNT
4169 #define NK_TEXTEDIT_UNDOCHARCOUNT 999
4170 #endif
4171 
4172 struct nk_text_edit;
4174  nk_handle userdata;
4177 };
4178 
4180  int where;
4184 };
4185 
4188  nk_rune undo_char[NK_TEXTEDIT_UNDOCHARCOUNT];
4189  short undo_point;
4190  short redo_point;
4193 };
4194 
4198 };
4199 
4204 };
4205 
4207  struct nk_clipboard clip;
4208  struct nk_str string;
4210  struct nk_vec2 scrollbar;
4211 
4212  int cursor;
4215  unsigned char mode;
4216  unsigned char cursor_at_end_of_line;
4217  unsigned char initialized;
4218  unsigned char has_preferred_x;
4219  unsigned char single_line;
4220  unsigned char active;
4221  unsigned char padding1;
4223  struct nk_text_undo_state undo;
4224 };
4225 
4226 /* filter function */
4227 NK_API int nk_filter_default(const struct nk_text_edit*, nk_rune unicode);
4228 NK_API int nk_filter_ascii(const struct nk_text_edit*, nk_rune unicode);
4229 NK_API int nk_filter_float(const struct nk_text_edit*, nk_rune unicode);
4230 NK_API int nk_filter_decimal(const struct nk_text_edit*, nk_rune unicode);
4231 NK_API int nk_filter_hex(const struct nk_text_edit*, nk_rune unicode);
4232 NK_API int nk_filter_oct(const struct nk_text_edit*, nk_rune unicode);
4233 NK_API int nk_filter_binary(const struct nk_text_edit*, nk_rune unicode);
4234 
4235 /* text editor */
4236 #ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
4237 NK_API void nk_textedit_init_default(struct nk_text_edit*);
4238 #endif
4239 NK_API void nk_textedit_init(struct nk_text_edit*, struct nk_allocator*, nk_size size);
4240 NK_API void nk_textedit_init_fixed(struct nk_text_edit*, void *memory, nk_size size);
4241 NK_API void nk_textedit_free(struct nk_text_edit*);
4242 NK_API void nk_textedit_text(struct nk_text_edit*, const char*, int total_len);
4243 NK_API void nk_textedit_delete(struct nk_text_edit*, int where, int len);
4246 NK_API int nk_textedit_cut(struct nk_text_edit*);
4247 NK_API int nk_textedit_paste(struct nk_text_edit*, char const*, int len);
4248 NK_API void nk_textedit_undo(struct nk_text_edit*);
4249 NK_API void nk_textedit_redo(struct nk_text_edit*);
4250 
4251 /* ===============================================================
4252  *
4253  * DRAWING
4254  *
4255  * ===============================================================*/
4256 /* This library was designed to be render backend agnostic so it does
4257  not draw anything to screen. Instead all drawn shapes, widgets
4258  are made of, are buffered into memory and make up a command queue.
4259  Each frame therefore fills the command buffer with draw commands
4260  that then need to be executed by the user and his own render backend.
4261  After that the command buffer needs to be cleared and a new frame can be
4262  started. It is probably important to note that the command buffer is the main
4263  drawing API and the optional vertex buffer API only takes this format and
4264  converts it into a hardware accessible format.
4265 
4266  To use the command queue to draw your own widgets you can access the
4267  command buffer of each window by calling `nk_window_get_canvas` after
4268  previously having called `nk_begin`:
4269 
4270  void draw_red_rectangle_widget(struct nk_context *ctx)
4271  {
4272  struct nk_command_buffer *canvas;
4273  struct nk_input *input = &ctx->input;
4274  canvas = nk_window_get_canvas(ctx);
4275 
4276  struct nk_rect space;
4277  enum nk_widget_layout_states state;
4278  state = nk_widget(&space, ctx);
4279  if (!state) return;
4280 
4281  if (state != NK_WIDGET_ROM)
4282  update_your_widget_by_user_input(...);
4283  nk_fill_rect(canvas, space, 0, nk_rgb(255,0,0));
4284  }
4285 
4286  if (nk_begin(...)) {
4287  nk_layout_row_dynamic(ctx, 25, 1);
4288  draw_red_rectangle_widget(ctx);
4289  }
4290  nk_end(..)
4291 
4292  Important to know if you want to create your own widgets is the `nk_widget`
4293  call. It allocates space on the panel reserved for this widget to be used,
4294  but also returns the state of the widget space. If your widget is not seen and does
4295  not have to be updated it is '0' and you can just return. If it only has
4296  to be drawn the state will be `NK_WIDGET_ROM` otherwise you can do both
4297  update and draw your widget. The reason for separating is to only draw and
4298  update what is actually necessary which is crucial for performance.
4299 */
4320 };
4321 
4322 /* command base and header of every command inside the buffer */
4323 struct nk_command {
4325  nk_size next;
4326 #ifdef NK_INCLUDE_COMMAND_USERDATA
4327  nk_handle userdata;
4328 #endif
4329 };
4330 
4333  short x, y;
4334  unsigned short w, h;
4335 };
4336 
4339  unsigned short line_thickness;
4340  struct nk_vec2i begin;
4341  struct nk_vec2i end;
4342  struct nk_color color;
4343 };
4344 
4347  unsigned short line_thickness;
4348  struct nk_vec2i begin;
4349  struct nk_vec2i end;
4350  struct nk_vec2i ctrl[2];
4351  struct nk_color color;
4352 };
4353 
4356  unsigned short rounding;
4357  unsigned short line_thickness;
4358  short x, y;
4359  unsigned short w, h;
4360  struct nk_color color;
4361 };
4362 
4365  unsigned short rounding;
4366  short x, y;
4367  unsigned short w, h;
4368  struct nk_color color;
4369 };
4370 
4373  short x, y;
4374  unsigned short w, h;
4375  struct nk_color left;
4376  struct nk_color top;
4377  struct nk_color bottom;
4378  struct nk_color right;
4379 };
4380 
4383  unsigned short line_thickness;
4384  struct nk_vec2i a;
4385  struct nk_vec2i b;
4386  struct nk_vec2i c;
4387  struct nk_color color;
4388 };
4389 
4392  struct nk_vec2i a;
4393  struct nk_vec2i b;
4394  struct nk_vec2i c;
4395  struct nk_color color;
4396 };
4397 
4400  short x, y;
4401  unsigned short line_thickness;
4402  unsigned short w, h;
4403  struct nk_color color;
4404 };
4405 
4408  short x, y;
4409  unsigned short w, h;
4410  struct nk_color color;
4411 };
4412 
4415  short cx, cy;
4416  unsigned short r;
4417  unsigned short line_thickness;
4418  float a[2];
4419  struct nk_color color;
4420 };
4421 
4424  short cx, cy;
4425  unsigned short r;
4426  float a[2];
4427  struct nk_color color;
4428 };
4429 
4432  struct nk_color color;
4433  unsigned short line_thickness;
4434  unsigned short point_count;
4435  struct nk_vec2i points[1];
4436 };
4437 
4440  struct nk_color color;
4441  unsigned short point_count;
4442  struct nk_vec2i points[1];
4443 };
4444 
4447  struct nk_color color;
4448  unsigned short line_thickness;
4449  unsigned short point_count;
4450  struct nk_vec2i points[1];
4451 };
4452 
4455  short x, y;
4456  unsigned short w, h;
4457  struct nk_image img;
4458  struct nk_color col;
4459 };
4460 
4461 typedef void (*nk_command_custom_callback)(void *canvas, short x,short y,
4462  unsigned short w, unsigned short h, nk_handle callback_data);
4465  short x, y;
4466  unsigned short w, h;
4467  nk_handle callback_data;
4469 };
4470 
4473  const struct nk_user_font *font;
4474  struct nk_color background;
4475  struct nk_color foreground;
4476  short x, y;
4477  unsigned short w, h;
4478  float height;
4479  int length;
4480  char string[1];
4481 };
4482 
4485  NK_CLIPPING_ON = nk_true
4486 };
4487 
4489  struct nk_buffer *base;
4490  struct nk_rect clip;
4492  nk_handle userdata;
4493  nk_size begin, end, last;
4494 };
4495 
4496 /* shape outlines */
4497 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);
4498 NK_API void nk_stroke_curve(struct nk_command_buffer*, float, float, float, float, float, float, float, float, float line_thickness, struct nk_color);
4499 NK_API void nk_stroke_rect(struct nk_command_buffer*, struct nk_rect, float rounding, float line_thickness, struct nk_color);
4500 NK_API void nk_stroke_circle(struct nk_command_buffer*, struct nk_rect, float line_thickness, struct nk_color);
4501 NK_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);
4502 NK_API void nk_stroke_triangle(struct nk_command_buffer*, float, float, float, float, float, float, float line_thichness, struct nk_color);
4503 NK_API void nk_stroke_polyline(struct nk_command_buffer*, float *points, int point_count, float line_thickness, struct nk_color col);
4504 NK_API void nk_stroke_polygon(struct nk_command_buffer*, float*, int point_count, float line_thickness, struct nk_color);
4505 
4506 /* filled shades */
4507 NK_API void nk_fill_rect(struct nk_command_buffer*, struct nk_rect, float rounding, struct nk_color);
4508 NK_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);
4509 NK_API void nk_fill_circle(struct nk_command_buffer*, struct nk_rect, struct nk_color);
4510 NK_API void nk_fill_arc(struct nk_command_buffer*, float cx, float cy, float radius, float a_min, float a_max, struct nk_color);
4511 NK_API void nk_fill_triangle(struct nk_command_buffer*, float x0, float y0, float x1, float y1, float x2, float y2, struct nk_color);
4512 NK_API void nk_fill_polygon(struct nk_command_buffer*, float*, int point_count, struct nk_color);
4513 
4514 /* misc */
4515 NK_API void nk_draw_image(struct nk_command_buffer*, struct nk_rect, const struct nk_image*, struct nk_color);
4516 NK_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);
4517 NK_API void nk_push_scissor(struct nk_command_buffer*, struct nk_rect);
4518 NK_API void nk_push_custom(struct nk_command_buffer*, struct nk_rect, nk_command_custom_callback, nk_handle usr);
4519 
4520 /* ===============================================================
4521  *
4522  * INPUT
4523  *
4524  * ===============================================================*/
4526  int down;
4527  unsigned int clicked;
4528  struct nk_vec2 clicked_pos;
4529 };
4530 struct nk_mouse {
4532  struct nk_vec2 pos;
4533  struct nk_vec2 prev;
4534  struct nk_vec2 delta;
4535  struct nk_vec2 scroll_delta;
4536  unsigned char grab;
4537  unsigned char grabbed;
4538  unsigned char ungrab;
4539 };
4540 
4541 struct nk_key {
4542  int down;
4543  unsigned int clicked;
4544 };
4545 struct nk_keyboard {
4547  char text[NK_INPUT_MAX];
4549 };
4550 
4551 struct nk_input {
4552  struct nk_keyboard keyboard;
4553  struct nk_mouse mouse;
4554 };
4555 
4556 NK_API int nk_input_has_mouse_click(const struct nk_input*, enum nk_buttons);
4557 NK_API int nk_input_has_mouse_click_in_rect(const struct nk_input*, enum nk_buttons, struct nk_rect);
4558 NK_API int nk_input_has_mouse_click_down_in_rect(const struct nk_input*, enum nk_buttons, struct nk_rect, int down);
4559 NK_API int nk_input_is_mouse_click_in_rect(const struct nk_input*, enum nk_buttons, struct nk_rect);
4560 NK_API int nk_input_is_mouse_click_down_in_rect(const struct nk_input *i, enum nk_buttons id, struct nk_rect b, int down);
4561 NK_API int nk_input_any_mouse_click_in_rect(const struct nk_input*, struct nk_rect);
4562 NK_API int nk_input_is_mouse_prev_hovering_rect(const struct nk_input*, struct nk_rect);
4563 NK_API int nk_input_is_mouse_hovering_rect(const struct nk_input*, struct nk_rect);
4564 NK_API int nk_input_mouse_clicked(const struct nk_input*, enum nk_buttons, struct nk_rect);
4565 NK_API int nk_input_is_mouse_down(const struct nk_input*, enum nk_buttons);
4566 NK_API int nk_input_is_mouse_pressed(const struct nk_input*, enum nk_buttons);
4567 NK_API int nk_input_is_mouse_released(const struct nk_input*, enum nk_buttons);
4568 NK_API int nk_input_is_key_pressed(const struct nk_input*, enum nk_keys);
4569 NK_API int nk_input_is_key_released(const struct nk_input*, enum nk_keys);
4570 NK_API int nk_input_is_key_down(const struct nk_input*, enum nk_keys);
4571 
4572 /* ===============================================================
4573  *
4574  * DRAW LIST
4575  *
4576  * ===============================================================*/
4577 #ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
4578 /* The optional vertex buffer draw list provides a 2D drawing context
4579  with antialiasing functionality which takes basic filled or outlined shapes
4580  or a path and outputs vertexes, elements and draw commands.
4581  The actual draw list API is not required to be used directly while using this
4582  library since converting the default library draw command output is done by
4583  just calling `nk_convert` but I decided to still make this library accessible
4584  since it can be useful.
4585 
4586  The draw list is based on a path buffering and polygon and polyline
4587  rendering API which allows a lot of ways to draw 2D content to screen.
4588  In fact it is probably more powerful than needed but allows even more crazy
4589  things than this library provides by default.
4590 */
4591 typedef nk_ushort nk_draw_index;
4592 enum nk_draw_list_stroke {
4593  NK_STROKE_OPEN = nk_false,
4594  /* build up path has no connection back to the beginning */
4595  NK_STROKE_CLOSED = nk_true
4596  /* build up path has a connection back to the beginning */
4597 };
4598 
4599 enum nk_draw_vertex_layout_attribute {
4600  NK_VERTEX_POSITION,
4601  NK_VERTEX_COLOR,
4602  NK_VERTEX_TEXCOORD,
4603  NK_VERTEX_ATTRIBUTE_COUNT
4604 };
4605 
4606 enum nk_draw_vertex_layout_format {
4607  NK_FORMAT_SCHAR,
4608  NK_FORMAT_SSHORT,
4609  NK_FORMAT_SINT,
4610  NK_FORMAT_UCHAR,
4611  NK_FORMAT_USHORT,
4612  NK_FORMAT_UINT,
4613  NK_FORMAT_FLOAT,
4614  NK_FORMAT_DOUBLE,
4615 
4616 NK_FORMAT_COLOR_BEGIN,
4617  NK_FORMAT_R8G8B8 = NK_FORMAT_COLOR_BEGIN,
4618  NK_FORMAT_R16G15B16,
4619  NK_FORMAT_R32G32B32,
4620 
4621  NK_FORMAT_R8G8B8A8,
4622  NK_FORMAT_B8G8R8A8,
4623  NK_FORMAT_R16G15B16A16,
4624  NK_FORMAT_R32G32B32A32,
4625  NK_FORMAT_R32G32B32A32_FLOAT,
4626  NK_FORMAT_R32G32B32A32_DOUBLE,
4627 
4628  NK_FORMAT_RGB32,
4629  NK_FORMAT_RGBA32,
4630 NK_FORMAT_COLOR_END = NK_FORMAT_RGBA32,
4631  NK_FORMAT_COUNT
4632 };
4633 
4634 #define NK_VERTEX_LAYOUT_END NK_VERTEX_ATTRIBUTE_COUNT,NK_FORMAT_COUNT,0
4635 struct nk_draw_vertex_layout_element {
4636  enum nk_draw_vertex_layout_attribute attribute;
4637  enum nk_draw_vertex_layout_format format;
4638  nk_size offset;
4639 };
4640 
4641 struct nk_draw_command {
4642  unsigned int elem_count;
4643  /* number of elements in the current draw batch */
4644  struct nk_rect clip_rect;
4645  /* current screen clipping rectangle */
4646  nk_handle texture;
4647  /* current texture to set */
4648 #ifdef NK_INCLUDE_COMMAND_USERDATA
4649  nk_handle userdata;
4650 #endif
4651 };
4652 
4653 struct nk_draw_list {
4654  struct nk_rect clip_rect;
4655  struct nk_vec2 circle_vtx[12];
4656  struct nk_convert_config config;
4657 
4658  struct nk_buffer *buffer;
4659  struct nk_buffer *vertices;
4660  struct nk_buffer *elements;
4661 
4662  unsigned int element_count;
4663  unsigned int vertex_count;
4664  unsigned int cmd_count;
4665  nk_size cmd_offset;
4666 
4667  unsigned int path_count;
4668  unsigned int path_offset;
4669 
4670  enum nk_anti_aliasing line_AA;
4671  enum nk_anti_aliasing shape_AA;
4672 
4673 #ifdef NK_INCLUDE_COMMAND_USERDATA
4674  nk_handle userdata;
4675 #endif
4676 };
4677 
4678 /* draw list */
4679 NK_API void nk_draw_list_init(struct nk_draw_list*);
4680 NK_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);
4681 
4682 /* drawing */
4683 #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))
4684 NK_API const struct nk_draw_command* nk__draw_list_begin(const struct nk_draw_list*, const struct nk_buffer*);
4685 NK_API const struct nk_draw_command* nk__draw_list_next(const struct nk_draw_command*, const struct nk_buffer*, const struct nk_draw_list*);
4686 NK_API const struct nk_draw_command* nk__draw_list_end(const struct nk_draw_list*, const struct nk_buffer*);
4687 
4688 /* path */
4689 NK_API void nk_draw_list_path_clear(struct nk_draw_list*);
4690 NK_API void nk_draw_list_path_line_to(struct nk_draw_list*, struct nk_vec2 pos);
4691 NK_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);
4692 NK_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);
4693 NK_API void nk_draw_list_path_rect_to(struct nk_draw_list*, struct nk_vec2 a, struct nk_vec2 b, float rounding);
4694 NK_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);
4695 NK_API void nk_draw_list_path_fill(struct nk_draw_list*, struct nk_color);
4696 NK_API void nk_draw_list_path_stroke(struct nk_draw_list*, struct nk_color, enum nk_draw_list_stroke closed, float thickness);
4697 
4698 /* stroke */
4699 NK_API void nk_draw_list_stroke_line(struct nk_draw_list*, struct nk_vec2 a, struct nk_vec2 b, struct nk_color, float thickness);
4700 NK_API void nk_draw_list_stroke_rect(struct nk_draw_list*, struct nk_rect rect, struct nk_color, float rounding, float thickness);
4701 NK_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);
4702 NK_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);
4703 NK_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);
4704 NK_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);
4705 
4706 /* fill */
4707 NK_API void nk_draw_list_fill_rect(struct nk_draw_list*, struct nk_rect rect, struct nk_color, float rounding);
4708 NK_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);
4709 NK_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);
4710 NK_API void nk_draw_list_fill_circle(struct nk_draw_list*, struct nk_vec2 center, float radius, struct nk_color col, unsigned int segs);
4711 NK_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);
4712 
4713 /* misc */
4714 NK_API void nk_draw_list_add_image(struct nk_draw_list*, struct nk_image texture, struct nk_rect rect, struct nk_color);
4715 NK_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);
4716 #ifdef NK_INCLUDE_COMMAND_USERDATA
4717 NK_API void nk_draw_list_push_userdata(struct nk_draw_list*, nk_handle userdata);
4718 #endif
4719 
4720 #endif
4721 
4722 /* ===============================================================
4723  *
4724  * GUI
4725  *
4726  * ===============================================================*/
4730 };
4731 
4733  struct nk_image image;
4734  struct nk_color color;
4735 };
4736 
4740 };
4741 
4743  struct nk_color color;
4744  struct nk_vec2 padding;
4745 };
4746 
4748  /* background */
4750  struct nk_style_item hover;
4751  struct nk_style_item active;
4752  struct nk_color border_color;
4753 
4754  /* text */
4755  struct nk_color text_background;
4756  struct nk_color text_normal;
4757  struct nk_color text_hover;
4758  struct nk_color text_active;
4759  nk_flags text_alignment;
4760 
4761  /* properties */
4762  float border;
4763  float rounding;
4764  struct nk_vec2 padding;
4765  struct nk_vec2 image_padding;
4766  struct nk_vec2 touch_padding;
4767 
4768  /* optional user callbacks */
4769  nk_handle userdata;
4770  void(*draw_begin)(struct nk_command_buffer*, nk_handle userdata);
4771  void(*draw_end)(struct nk_command_buffer*, nk_handle userdata);
4772 };
4773 
4775  /* background */
4777  struct nk_style_item hover;
4778  struct nk_style_item active;
4779  struct nk_color border_color;
4780 
4781  /* cursor */
4782  struct nk_style_item cursor_normal;
4783  struct nk_style_item cursor_hover;
4784 
4785  /* text */
4786  struct nk_color text_normal;
4787  struct nk_color text_hover;
4788  struct nk_color text_active;
4789  struct nk_color text_background;
4790  nk_flags text_alignment;
4791 
4792  /* properties */
4793  struct nk_vec2 padding;
4794  struct nk_vec2 touch_padding;
4795  float spacing;
4796  float border;
4797 
4798  /* optional user callbacks */
4799  nk_handle userdata;
4800  void(*draw_begin)(struct nk_command_buffer*, nk_handle);
4801  void(*draw_end)(struct nk_command_buffer*, nk_handle);
4802 };
4803 
4805  /* background (inactive) */
4807  struct nk_style_item hover;
4808  struct nk_style_item pressed;
4809 
4810  /* background (active) */
4811  struct nk_style_item normal_active;
4812  struct nk_style_item hover_active;
4813  struct nk_style_item pressed_active;
4814 
4815  /* text color (inactive) */
4816  struct nk_color text_normal;
4817  struct nk_color text_hover;
4818  struct nk_color text_pressed;
4819 
4820  /* text color (active) */
4821  struct nk_color text_normal_active;
4822  struct nk_color text_hover_active;
4823  struct nk_color text_pressed_active;
4824  struct nk_color text_background;
4825  nk_flags text_alignment;
4826 
4827  /* properties */
4828  float rounding;
4829  struct nk_vec2 padding;
4830  struct nk_vec2 touch_padding;
4831  struct nk_vec2 image_padding;
4832 
4833  /* optional user callbacks */
4834  nk_handle userdata;
4835  void(*draw_begin)(struct nk_command_buffer*, nk_handle);
4836  void(*draw_end)(struct nk_command_buffer*, nk_handle);
4837 };
4838 
4840  /* background */
4842  struct nk_style_item hover;
4843  struct nk_style_item active;
4844  struct nk_color border_color;
4845 
4846  /* background bar */
4847  struct nk_color bar_normal;
4848  struct nk_color bar_hover;
4849  struct nk_color bar_active;
4850  struct nk_color bar_filled;
4851 
4852  /* cursor */
4853  struct nk_style_item cursor_normal;
4854  struct nk_style_item cursor_hover;
4855  struct nk_style_item cursor_active;
4856 
4857  /* properties */
4858  float border;
4859  float rounding;
4860  float bar_height;
4861  struct nk_vec2 padding;
4862  struct nk_vec2 spacing;
4863  struct nk_vec2 cursor_size;
4864 
4865  /* optional buttons */
4867  struct nk_style_button inc_button;
4868  struct nk_style_button dec_button;
4869  enum nk_symbol_type inc_symbol;
4870  enum nk_symbol_type dec_symbol;
4871 
4872  /* optional user callbacks */
4873  nk_handle userdata;
4874  void(*draw_begin)(struct nk_command_buffer*, nk_handle);
4875  void(*draw_end)(struct nk_command_buffer*, nk_handle);
4876 };
4877 
4879  /* background */
4881  struct nk_style_item hover;
4882  struct nk_style_item active;
4883  struct nk_color border_color;
4884 
4885  /* cursor */
4886  struct nk_style_item cursor_normal;
4887  struct nk_style_item cursor_hover;
4888  struct nk_style_item cursor_active;
4889  struct nk_color cursor_border_color;
4890 
4891  /* properties */
4892  float rounding;
4893  float border;
4896  struct nk_vec2 padding;
4897 
4898  /* optional user callbacks */
4899  nk_handle userdata;
4900  void(*draw_begin)(struct nk_command_buffer*, nk_handle);
4901  void(*draw_end)(struct nk_command_buffer*, nk_handle);
4902 };
4903 
4905  /* background */
4907  struct nk_style_item hover;
4908  struct nk_style_item active;
4909  struct nk_color border_color;
4910 
4911  /* cursor */
4912  struct nk_style_item cursor_normal;
4913  struct nk_style_item cursor_hover;
4914  struct nk_style_item cursor_active;
4915  struct nk_color cursor_border_color;
4916 
4917  /* properties */
4918  float border;
4919  float rounding;
4922  struct nk_vec2 padding;
4923 
4924  /* optional buttons */
4926  struct nk_style_button inc_button;
4927  struct nk_style_button dec_button;
4928  enum nk_symbol_type inc_symbol;
4929  enum nk_symbol_type dec_symbol;
4930 
4931  /* optional user callbacks */
4932  nk_handle userdata;
4933  void(*draw_begin)(struct nk_command_buffer*, nk_handle);
4934  void(*draw_end)(struct nk_command_buffer*, nk_handle);
4935 };
4936 
4938  /* background */
4940  struct nk_style_item hover;
4941  struct nk_style_item active;
4942  struct nk_color border_color;
4943  struct nk_style_scrollbar scrollbar;
4944 
4945  /* cursor */
4946  struct nk_color cursor_normal;
4947  struct nk_color cursor_hover;
4948  struct nk_color cursor_text_normal;
4949  struct nk_color cursor_text_hover;
4950 
4951  /* text (unselected) */
4952  struct nk_color text_normal;
4953  struct nk_color text_hover;
4954  struct nk_color text_active;
4955 
4956  /* text (selected) */
4957  struct nk_color selected_normal;
4958  struct nk_color selected_hover;
4959  struct nk_color selected_text_normal;
4960  struct nk_color selected_text_hover;
4961 
4962  /* properties */
4963  float border;
4964  float rounding;
4966  struct nk_vec2 scrollbar_size;
4967  struct nk_vec2 padding;
4969 };
4970 
4972  /* background */
4974  struct nk_style_item hover;
4975  struct nk_style_item active;
4976  struct nk_color border_color;
4977 
4978  /* text */
4979  struct nk_color label_normal;
4980  struct nk_color label_hover;
4981  struct nk_color label_active;
4982 
4983  /* symbols */
4984  enum nk_symbol_type sym_left;
4985  enum nk_symbol_type sym_right;
4986 
4987  /* properties */
4988  float border;
4989  float rounding;
4990  struct nk_vec2 padding;
4991 
4993  struct nk_style_button inc_button;
4994  struct nk_style_button dec_button;
4995 
4996  /* optional user callbacks */
4997  nk_handle userdata;
4998  void(*draw_begin)(struct nk_command_buffer*, nk_handle);
4999  void(*draw_end)(struct nk_command_buffer*, nk_handle);
5000 };
5001 
5003  /* colors */
5004  struct nk_style_item background;
5005  struct nk_color border_color;
5006  struct nk_color selected_color;
5007  struct nk_color color;
5008 
5009  /* properties */
5010  float border;
5011  float rounding;
5012  struct nk_vec2 padding;
5013 };
5014 
5016  /* background */
5018  struct nk_style_item hover;
5019  struct nk_style_item active;
5020  struct nk_color border_color;
5021 
5022  /* label */
5023  struct nk_color label_normal;
5024  struct nk_color label_hover;
5025  struct nk_color label_active;
5026 
5027  /* symbol */
5028  struct nk_color symbol_normal;
5029  struct nk_color symbol_hover;
5030  struct nk_color symbol_active;
5031 
5032  /* button */
5033  struct nk_style_button button;
5034  enum nk_symbol_type sym_normal;
5035  enum nk_symbol_type sym_hover;
5036  enum nk_symbol_type sym_active;
5037 
5038  /* properties */
5039  float border;
5040  float rounding;
5041  struct nk_vec2 content_padding;
5042  struct nk_vec2 button_padding;
5043  struct nk_vec2 spacing;
5044 };
5045 
5047  /* background */
5048  struct nk_style_item background;
5049  struct nk_color border_color;
5050  struct nk_color text;
5051 
5052  /* button */
5053  struct nk_style_button tab_maximize_button;
5054  struct nk_style_button tab_minimize_button;
5055  struct nk_style_button node_maximize_button;
5056  struct nk_style_button node_minimize_button;
5057  enum nk_symbol_type sym_minimize;
5058  enum nk_symbol_type sym_maximize;
5059 
5060  /* properties */
5061  float border;
5062  float rounding;
5063  float indent;
5064  struct nk_vec2 padding;
5065  struct nk_vec2 spacing;
5066 };
5067 
5071 };
5073  /* background */
5075  struct nk_style_item hover;
5076  struct nk_style_item active;
5077 
5078  /* button */
5079  struct nk_style_button close_button;
5080  struct nk_style_button minimize_button;
5081  enum nk_symbol_type close_symbol;
5082  enum nk_symbol_type minimize_symbol;
5083  enum nk_symbol_type maximize_symbol;
5084 
5085  /* title */
5086  struct nk_color label_normal;
5087  struct nk_color label_hover;
5088  struct nk_color label_active;
5089 
5090  /* properties */
5092  struct nk_vec2 padding;
5093  struct nk_vec2 label_padding;
5094  struct nk_vec2 spacing;
5095 };
5096 
5099  struct nk_style_item fixed_background;
5100  struct nk_color background;
5101 
5102  struct nk_color border_color;
5103  struct nk_color popup_border_color;
5104  struct nk_color combo_border_color;
5105  struct nk_color contextual_border_color;
5106  struct nk_color menu_border_color;
5107  struct nk_color group_border_color;
5108  struct nk_color tooltip_border_color;
5109  struct nk_style_item scaler;
5110 
5111  float border;
5119 
5120  float rounding;
5121  struct nk_vec2 spacing;
5122  struct nk_vec2 scrollbar_size;
5123  struct nk_vec2 min_size;
5124 
5125  struct nk_vec2 padding;
5126  struct nk_vec2 group_padding;
5127  struct nk_vec2 popup_padding;
5128  struct nk_vec2 combo_padding;
5129  struct nk_vec2 contextual_padding;
5130  struct nk_vec2 menu_padding;
5131  struct nk_vec2 tooltip_padding;
5132 };
5133 
5134 struct nk_style {
5135  const struct nk_user_font *font;
5136  const struct nk_cursor *cursors[NK_CURSOR_COUNT];
5137  const struct nk_cursor *cursor_active;
5140 
5141  struct nk_style_text text;
5142  struct nk_style_button button;
5143  struct nk_style_button contextual_button;
5144  struct nk_style_button menu_button;
5147  struct nk_style_selectable selectable;
5150  struct nk_style_property property;
5152  struct nk_style_chart chart;
5153  struct nk_style_scrollbar scrollh;
5154  struct nk_style_scrollbar scrollv;
5155  struct nk_style_tab tab;
5156  struct nk_style_combo combo;
5158 };
5159 
5161 NK_API struct nk_style_item nk_style_item_color(struct nk_color);
5163 
5164 /*==============================================================
5165  * PANEL
5166  * =============================================================*/
5167 #ifndef NK_MAX_LAYOUT_ROW_TEMPLATE_COLUMNS
5168 #define NK_MAX_LAYOUT_ROW_TEMPLATE_COLUMNS 16
5169 #endif
5170 #ifndef NK_CHART_MAX_SLOT
5171 #define NK_CHART_MAX_SLOT 4
5172 #endif
5173 
5183 };
5188 };
5189 
5192  struct nk_color color;
5193  struct nk_color highlight;
5194  float min, max, range;
5195  int count;
5196  struct nk_vec2 last;
5197  int index;
5198 };
5199 
5200 struct nk_chart {
5201  int slot;
5202  float x, y, w, h;
5204 };
5205 
5217 };
5220  int index;
5221  float height;
5222  float min_height;
5223  int columns;
5224  const float *ratio;
5225  float item_width;
5228  float filled;
5229  struct nk_rect item;
5232 };
5233 
5235  nk_size begin;
5236  nk_size parent;
5237  nk_size last;
5238  nk_size end;
5239  int active;
5240 };
5241 
5243  float x, y, w, h;
5244  struct nk_scroll offset;
5245 };
5246 
5247 struct nk_panel {
5249  nk_flags flags;
5250  struct nk_rect bounds;
5251  nk_uint *offset_x;
5252  nk_uint *offset_y;
5253  float at_x, at_y, max_x;
5256  float border;
5257  unsigned int has_scrolling;
5258  struct nk_rect clip;
5259  struct nk_menu_state menu;
5261  struct nk_chart chart;
5263  struct nk_panel *parent;
5264 };
5265 
5266 /*==============================================================
5267  * WINDOW
5268  * =============================================================*/
5269 #ifndef NK_WINDOW_MAX_NAME
5270 #define NK_WINDOW_MAX_NAME 64
5271 #endif
5272 
5273 struct nk_table;
5277  /* special window type growing up in height while being filled to a certain maximum height */
5279  /* sets window widgets into a read only mode and does not allow input changes */
5281  /* prevents all interaction caused by input to either window or widgets inside */
5283  /* Hides window and stops any window interaction and drawing */
5285  /* Directly closes and frees the window at the end of the frame */
5287  /* marks the window as minimized */
5289  /* Removes read only mode at the end of the window */
5290 };
5291 
5293  struct nk_window *win;
5296  nk_hash name;
5297  int active;
5298  unsigned combo_count;
5299  unsigned con_count, con_old;
5300  unsigned active_con;
5301  struct nk_rect header;
5302 };
5303 
5305  nk_hash name;
5306  unsigned int seq;
5307  unsigned int old;
5308  int active, prev;
5309  int cursor;
5311  int sel_end;
5312  struct nk_scroll scrollbar;
5313  unsigned char mode;
5314  unsigned char single_line;
5315 };
5316 
5318  int active, prev;
5320  int length;
5321  int cursor;
5324  nk_hash name;
5325  unsigned int seq;
5326  unsigned int old;
5327  int state;
5328 };
5329 
5330 struct nk_window {
5331  unsigned int seq;
5332  nk_hash name;
5333  char name_string[NK_WINDOW_MAX_NAME];
5334  nk_flags flags;
5335 
5336  struct nk_rect bounds;
5337  struct nk_scroll scrollbar;
5339  struct nk_panel *layout;
5341 
5342  /* persistent widget state */
5343  struct nk_property_state property;
5344  struct nk_popup_state popup;
5346  unsigned int scrolled;
5347 
5348  struct nk_table *tables;
5349  unsigned int table_count;
5350 
5351  /* window list hooks */
5352  struct nk_window *next;
5353  struct nk_window *prev;
5355 };
5356 
5357 /*==============================================================
5358  * STACK
5359  * =============================================================*/
5360 /* The style modifier stack can be used to temporarily change a
5361  * property inside `nk_style`. For example if you want a special
5362  * red button you can temporarily push the old button color onto a stack
5363  * draw the button with a red color and then you just pop the old color
5364  * back from the stack:
5365  *
5366  * nk_style_push_style_item(ctx, &ctx->style.button.normal, nk_style_item_color(nk_rgb(255,0,0)));
5367  * nk_style_push_style_item(ctx, &ctx->style.button.hover, nk_style_item_color(nk_rgb(255,0,0)));
5368  * nk_style_push_style_item(ctx, &ctx->style.button.active, nk_style_item_color(nk_rgb(255,0,0)));
5369  * nk_style_push_vec2(ctx, &cx->style.button.padding, nk_vec2(2,2));
5370  *
5371  * nk_button(...);
5372  *
5373  * nk_style_pop_style_item(ctx);
5374  * nk_style_pop_style_item(ctx);
5375  * nk_style_pop_style_item(ctx);
5376  * nk_style_pop_vec2(ctx);
5377  *
5378  * Nuklear has a stack for style_items, float properties, vector properties,
5379  * flags, colors, fonts and for button_behavior. Each has it's own fixed size stack
5380  * which can be changed at compile time.
5381  */
5382 #ifndef NK_BUTTON_BEHAVIOR_STACK_SIZE
5383 #define NK_BUTTON_BEHAVIOR_STACK_SIZE 8
5384 #endif
5385 
5386 #ifndef NK_FONT_STACK_SIZE
5387 #define NK_FONT_STACK_SIZE 8
5388 #endif
5389 
5390 #ifndef NK_STYLE_ITEM_STACK_SIZE
5391 #define NK_STYLE_ITEM_STACK_SIZE 16
5392 #endif
5393 
5394 #ifndef NK_FLOAT_STACK_SIZE
5395 #define NK_FLOAT_STACK_SIZE 32
5396 #endif
5397 
5398 #ifndef NK_VECTOR_STACK_SIZE
5399 #define NK_VECTOR_STACK_SIZE 16
5400 #endif
5401 
5402 #ifndef NK_FLAGS_STACK_SIZE
5403 #define NK_FLAGS_STACK_SIZE 32
5404 #endif
5405 
5406 #ifndef NK_COLOR_STACK_SIZE
5407 #define NK_COLOR_STACK_SIZE 32
5408 #endif
5409 
5410 #define NK_CONFIGURATION_STACK_TYPE(prefix, name, type)\
5411  struct nk_config_stack_##name##_element {\
5412  prefix##_##type *address;\
5413  prefix##_##type old_value;\
5414  }
5415 #define NK_CONFIG_STACK(type,size)\
5416  struct nk_config_stack_##type {\
5417  int head;\
5418  struct nk_config_stack_##type##_element elements[size];\
5419  }
5420 
5421 #define nk_float float
5422 NK_CONFIGURATION_STACK_TYPE(struct nk, style_item, style_item);
5423 NK_CONFIGURATION_STACK_TYPE(nk ,float, float);
5424 NK_CONFIGURATION_STACK_TYPE(struct nk, vec2, vec2);
5426 NK_CONFIGURATION_STACK_TYPE(struct nk, color, color);
5427 NK_CONFIGURATION_STACK_TYPE(const struct nk, user_font, user_font*);
5428 NK_CONFIGURATION_STACK_TYPE(enum nk, button_behavior, button_behavior);
5429 
5437 
5439  struct nk_config_stack_style_item style_items;
5440  struct nk_config_stack_float floats;
5441  struct nk_config_stack_vec2 vectors;
5442  struct nk_config_stack_flags flags;
5443  struct nk_config_stack_color colors;
5444  struct nk_config_stack_user_font fonts;
5445  struct nk_config_stack_button_behavior button_behaviors;
5446 };
5447 
5448 /*==============================================================
5449  * CONTEXT
5450  * =============================================================*/
5451 #define NK_VALUE_PAGE_CAPACITY \
5452  (((NK_MAX(sizeof(struct nk_window),sizeof(struct nk_panel)) / sizeof(nk_uint))) / 2)
5453 
5454 struct nk_table {
5455  unsigned int seq;
5456  unsigned int size;
5459  struct nk_table *next, *prev;
5460 };
5461 
5463  struct nk_table tbl;
5464  struct nk_panel pan;
5465  struct nk_window win;
5466 };
5467 
5469  union nk_page_data data;
5472 };
5473 
5474 struct nk_page {
5475  unsigned int size;
5476  struct nk_page *next;
5477  struct nk_page_element win[1];
5478 };
5479 
5480 struct nk_pool {
5483  unsigned int page_count;
5484  struct nk_page *pages;
5486  unsigned capacity;
5487  nk_size size;
5488  nk_size cap;
5489 };
5490 
5491 struct nk_context {
5492 /* public: can be accessed freely */
5493  struct nk_input input;
5494  struct nk_style style;
5495  struct nk_buffer memory;
5496  struct nk_clipboard clip;
5498  enum nk_button_behavior button_behavior;
5501 
5502 /* private:
5503  should only be accessed if you
5504  know what you are doing */
5505 #ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
5506  struct nk_draw_list draw_list;
5507 #endif
5508 #ifdef NK_INCLUDE_COMMAND_USERDATA
5509  nk_handle userdata;
5510 #endif
5511  /* text editor objects are quite big because of an internal
5512  * undo/redo stack. Therefore it does not make sense to have one for
5513  * each window for temporary use cases, so I only provide *one* instance
5514  * for all windows. This works because the content is cleared anyway */
5515  struct nk_text_edit text_edit;
5516  /* draw buffer used for overlay drawing operation like cursor */
5517  struct nk_command_buffer overlay;
5518 
5519  /* windows */
5520  int build;
5522  struct nk_pool pool;
5523  struct nk_window *begin;
5524  struct nk_window *end;
5528  unsigned int count;
5529  unsigned int seq;
5530 };
5531 
5532 /* ==============================================================
5533  * MATH
5534  * =============================================================== */
5535 #define NK_PI 3.141592654f
5536 #define NK_UTF_INVALID 0xFFFD
5537 #define NK_MAX_FLOAT_PRECISION 2
5538 
5539 #define NK_UNUSED(x) ((void)(x))
5540 #define NK_SATURATE(x) (NK_MAX(0, NK_MIN(1.0f, x)))
5541 #define NK_LEN(a) (sizeof(a)/sizeof(a)[0])
5542 #define NK_ABS(a) (((a) < 0) ? -(a) : (a))
5543 #define NK_BETWEEN(x, a, b) ((a) <= (x) && (x) < (b))
5544 #define NK_INBOX(px, py, x, y, w, h)\
5545  (NK_BETWEEN(px,x,x+w) && NK_BETWEEN(py,y,y+h))
5546 #define NK_INTERSECT(x0, y0, w0, h0, x1, y1, w1, h1) \
5547  (!(((x1 > (x0 + w0)) || ((x1 + w1) < x0) || (y1 > (y0 + h0)) || (y1 + h1) < y0)))
5548 #define NK_CONTAINS(x, y, w, h, bx, by, bw, bh)\
5549  (NK_INBOX(x,y, bx, by, bw, bh) && NK_INBOX(x+w,y+h, bx, by, bw, bh))
5550 
5551 #define nk_vec2_sub(a, b) nk_vec2((a).x - (b).x, (a).y - (b).y)
5552 #define nk_vec2_add(a, b) nk_vec2((a).x + (b).x, (a).y + (b).y)
5553 #define nk_vec2_len_sqr(a) ((a).x*(a).x+(a).y*(a).y)
5554 #define nk_vec2_muls(a, t) nk_vec2((a).x * (t), (a).y * (t))
5555 
5556 #define nk_ptr_add(t, p, i) ((t*)((void*)((nk_byte*)(p) + (i))))
5557 #define nk_ptr_add_const(t, p, i) ((const t*)((const void*)((const nk_byte*)(p) + (i))))
5558 #define nk_zero_struct(s) nk_zero(&s, sizeof(s))
5559 
5560 /* ==============================================================
5561  * ALIGNMENT
5562  * =============================================================== */
5563 /* Pointer to Integer type conversion for pointer alignment */
5564 #if defined(__PTRDIFF_TYPE__) /* This case should work for GCC*/
5565 # define NK_UINT_TO_PTR(x) ((void*)(__PTRDIFF_TYPE__)(x))
5566 # define NK_PTR_TO_UINT(x) ((nk_size)(__PTRDIFF_TYPE__)(x))
5567 #elif !defined(__GNUC__) /* works for compilers other than LLVM */
5568 # define NK_UINT_TO_PTR(x) ((void*)&((char*)0)[x])
5569 # define NK_PTR_TO_UINT(x) ((nk_size)(((char*)x)-(char*)0))
5570 #elif defined(NK_USE_FIXED_TYPES) /* used if we have <stdint.h> */
5571 # define NK_UINT_TO_PTR(x) ((void*)(uintptr_t)(x))
5572 # define NK_PTR_TO_UINT(x) ((uintptr_t)(x))
5573 #else /* generates warning but works */
5574 # define NK_UINT_TO_PTR(x) ((void*)(x))
5575 # define NK_PTR_TO_UINT(x) ((nk_size)(x))
5576 #endif
5577 
5578 #define NK_ALIGN_PTR(x, mask)\
5579  (NK_UINT_TO_PTR((NK_PTR_TO_UINT((nk_byte*)(x) + (mask-1)) & ~(mask-1))))
5580 #define NK_ALIGN_PTR_BACK(x, mask)\
5581  (NK_UINT_TO_PTR((NK_PTR_TO_UINT((nk_byte*)(x)) & ~(mask-1))))
5582 
5583 #define NK_OFFSETOF(st,m) ((nk_ptr)&(((st*)0)->m))
5584 #define NK_CONTAINER_OF(ptr,type,member)\
5585  (type*)((void*)((char*)(1 ? (ptr): &((type*)0)->member) - NK_OFFSETOF(type, member)))
5586 
5587 #ifdef __cplusplus
5588 }
5589 #endif
5590 
5591 #ifdef __cplusplus
5592 template<typename T> struct nk_alignof;
5593 template<typename T, int size_diff> struct nk_helper{enum {value = size_diff};};
5594 template<typename T> struct nk_helper<T,0>{enum {value = nk_alignof<T>::value};};
5595 template<typename T> struct nk_alignof{struct Big {T x; char c;}; enum {
5596  diff = sizeof(Big) - sizeof(T), value = nk_helper<Big, diff>::value};};
5597 #define NK_ALIGNOF(t) (nk_alignof<t>::value)
5598 #elif defined(_MSC_VER)
5599 #define NK_ALIGNOF(t) (__alignof(t))
5600 #else
5601 #define NK_ALIGNOF(t) ((char*)(&((struct {char c; t _h;}*)0)->_h) - (char*)0)
5602 #endif
5603 
5604 #endif /* NK_NUKLEAR_H_ */
5605 
5606 
5607 #ifdef NK_IMPLEMENTATION
5608 
5609 #ifndef NK_INTERNAL_H
5610 #define NK_INTERNAL_H
5611 
5612 #ifndef NK_POOL_DEFAULT_CAPACITY
5613 #define NK_POOL_DEFAULT_CAPACITY 16
5614 #endif
5615 
5616 #ifndef NK_DEFAULT_COMMAND_BUFFER_SIZE
5617 #define NK_DEFAULT_COMMAND_BUFFER_SIZE (4*1024)
5618 #endif
5619 
5620 #ifndef NK_BUFFER_DEFAULT_INITIAL_SIZE
5621 #define NK_BUFFER_DEFAULT_INITIAL_SIZE (4*1024)
5622 #endif
5623 
5624 /* standard library headers */
5625 #ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
5626 #include <stdlib.h> /* malloc, free */
5627 #endif
5628 #ifdef NK_INCLUDE_STANDARD_IO
5629 #include <stdio.h> /* fopen, fclose,... */
5630 #endif
5631 #ifndef NK_ASSERT
5632 #include <assert.h>
5633 #define NK_ASSERT(expr) assert(expr)
5634 #endif
5635 
5636 #ifndef NK_MEMSET
5637 #define NK_MEMSET nk_memset
5638 #endif
5639 #ifndef NK_MEMCPY
5640 #define NK_MEMCPY nk_memcopy
5641 #endif
5642 #ifndef NK_SQRT
5643 #define NK_SQRT nk_sqrt
5644 #endif
5645 #ifndef NK_SIN
5646 #define NK_SIN nk_sin
5647 #endif
5648 #ifndef NK_COS
5649 #define NK_COS nk_cos
5650 #endif
5651 #ifndef NK_STRTOD
5652 #define NK_STRTOD nk_strtod
5653 #endif
5654 #ifndef NK_DTOA
5655 #define NK_DTOA nk_dtoa
5656 #endif
5657 
5658 #define NK_DEFAULT (-1)
5659 
5660 #ifndef NK_VSNPRINTF
5661 /* If your compiler does support `vsnprintf` I would highly recommend
5662  * defining this to vsnprintf instead since `vsprintf` is basically
5663  * unbelievable unsafe and should *NEVER* be used. But I have to support
5664  * it since C89 only provides this unsafe version. */
5665  #if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) ||\
5666  (defined(__cplusplus) && (__cplusplus >= 201103L)) || \
5667  (defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200112L)) ||\
5668  (defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)) ||\
5669  defined(_ISOC99_SOURCE) || defined(_BSD_SOURCE)
5670  #define NK_VSNPRINTF(s,n,f,a) vsnprintf(s,n,f,a)
5671  #else
5672  #define NK_VSNPRINTF(s,n,f,a) vsprintf(s,f,a)
5673  #endif
5674 #endif
5675 
5676 #define NK_SCHAR_MIN (-127)
5677 #define NK_SCHAR_MAX 127
5678 #define NK_UCHAR_MIN 0
5679 #define NK_UCHAR_MAX 256
5680 #define NK_SSHORT_MIN (-32767)
5681 #define NK_SSHORT_MAX 32767
5682 #define NK_USHORT_MIN 0
5683 #define NK_USHORT_MAX 65535
5684 #define NK_SINT_MIN (-2147483647)
5685 #define NK_SINT_MAX 2147483647
5686 #define NK_UINT_MIN 0
5687 #define NK_UINT_MAX 4294967295u
5688 
5689 /* Make sure correct type size:
5690  * This will fire with a negative subscript error if the type sizes
5691  * are set incorrectly by the compiler, and compile out if not */
5692 NK_STATIC_ASSERT(sizeof(nk_size) >= sizeof(void*));
5693 NK_STATIC_ASSERT(sizeof(nk_ptr) == sizeof(void*));
5694 NK_STATIC_ASSERT(sizeof(nk_flags) >= 4);
5695 NK_STATIC_ASSERT(sizeof(nk_rune) >= 4);
5696 NK_STATIC_ASSERT(sizeof(nk_ushort) == 2);
5697 NK_STATIC_ASSERT(sizeof(nk_short) == 2);
5698 NK_STATIC_ASSERT(sizeof(nk_uint) == 4);
5699 NK_STATIC_ASSERT(sizeof(nk_int) == 4);
5700 NK_STATIC_ASSERT(sizeof(nk_byte) == 1);
5701 
5702 NK_GLOBAL const struct nk_rect nk_null_rect = {-8192.0f, -8192.0f, 16384, 16384};
5703 #define NK_FLOAT_PRECISION 0.00000000000001
5704 
5705 NK_GLOBAL const struct nk_color nk_red = {255,0,0,255};
5706 NK_GLOBAL const struct nk_color nk_green = {0,255,0,255};
5707 NK_GLOBAL const struct nk_color nk_blue = {0,0,255,255};
5708 NK_GLOBAL const struct nk_color nk_white = {255,255,255,255};
5709 NK_GLOBAL const struct nk_color nk_black = {0,0,0,255};
5710 NK_GLOBAL const struct nk_color nk_yellow = {255,255,0,255};
5711 
5712 /* widget */
5713 #define nk_widget_state_reset(s)\
5714  if ((*(s)) & NK_WIDGET_STATE_MODIFIED)\
5715  (*(s)) = NK_WIDGET_STATE_INACTIVE|NK_WIDGET_STATE_MODIFIED;\
5716  else (*(s)) = NK_WIDGET_STATE_INACTIVE;
5717 
5718 /* math */
5719 NK_LIB float nk_inv_sqrt(float n);
5720 NK_LIB float nk_sqrt(float x);
5721 NK_LIB float nk_sin(float x);
5722 NK_LIB float nk_cos(float x);
5723 NK_LIB nk_uint nk_round_up_pow2(nk_uint v);
5724 NK_LIB struct nk_rect nk_shrink_rect(struct nk_rect r, float amount);
5725 NK_LIB struct nk_rect nk_pad_rect(struct nk_rect r, struct nk_vec2 pad);
5726 NK_LIB void nk_unify(struct nk_rect *clip, const struct nk_rect *a, float x0, float y0, float x1, float y1);
5727 NK_LIB double nk_pow(double x, int n);
5728 NK_LIB int nk_ifloord(double x);
5729 NK_LIB int nk_ifloorf(float x);
5730 NK_LIB int nk_iceilf(float x);
5731 NK_LIB int nk_log10(double n);
5732 
5733 /* util */
5734 enum {NK_DO_NOT_STOP_ON_NEW_LINE, NK_STOP_ON_NEW_LINE};
5735 NK_LIB int nk_is_lower(int c);
5736 NK_LIB int nk_is_upper(int c);
5737 NK_LIB int nk_to_upper(int c);
5738 NK_LIB int nk_to_lower(int c);
5739 NK_LIB void* nk_memcopy(void *dst, const void *src, nk_size n);
5740 NK_LIB void nk_memset(void *ptr, int c0, nk_size size);
5741 NK_LIB void nk_zero(void *ptr, nk_size size);
5742 NK_LIB char *nk_itoa(char *s, long n);
5743 NK_LIB int nk_string_float_limit(char *string, int prec);
5744 NK_LIB char *nk_dtoa(char *s, double n);
5745 NK_LIB int nk_text_clamp(const struct nk_user_font *font, const char *text, int text_len, float space, int *glyphs, float *text_width, nk_rune *sep_list, int sep_count);
5746 NK_LIB struct nk_vec2 nk_text_calculate_text_bounds(const struct nk_user_font *font, const char *begin, int byte_len, float row_height, const char **remaining, struct nk_vec2 *out_offset, int *glyphs, int op);
5747 #ifdef NK_INCLUDE_STANDARD_VARARGS
5748 NK_LIB int nk_strfmt(char *buf, int buf_size, const char *fmt, va_list args);
5749 #endif
5750 #ifdef NK_INCLUDE_STANDARD_IO
5751 NK_LIB char *nk_file_load(const char* path, nk_size* siz, struct nk_allocator *alloc);
5752 #endif
5753 
5754 /* buffer */
5755 #ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
5756 NK_LIB void* nk_malloc(nk_handle unused, void *old,nk_size size);
5757 NK_LIB void nk_mfree(nk_handle unused, void *ptr);
5758 #endif
5759 NK_LIB void* nk_buffer_align(void *unaligned, nk_size align, nk_size *alignment, enum nk_buffer_allocation_type type);
5760 NK_LIB void* nk_buffer_alloc(struct nk_buffer *b, enum nk_buffer_allocation_type type, nk_size size, nk_size align);
5761 NK_LIB void* nk_buffer_realloc(struct nk_buffer *b, nk_size capacity, nk_size *size);
5762 
5763 /* draw */
5764 NK_LIB void nk_command_buffer_init(struct nk_command_buffer *cb, struct nk_buffer *b, enum nk_command_clipping clip);
5765 NK_LIB void nk_command_buffer_reset(struct nk_command_buffer *b);
5766 NK_LIB void* nk_command_buffer_push(struct nk_command_buffer* b, enum nk_command_type t, nk_size size);
5767 NK_LIB void nk_draw_symbol(struct nk_command_buffer *out, enum nk_symbol_type type, struct nk_rect content, struct nk_color background, struct nk_color foreground, float border_width, const struct nk_user_font *font);
5768 
5769 /* buffering */
5770 NK_LIB void nk_start_buffer(struct nk_context *ctx, struct nk_command_buffer *b);
5771 NK_LIB void nk_start(struct nk_context *ctx, struct nk_window *win);
5772 NK_LIB void nk_start_popup(struct nk_context *ctx, struct nk_window *win);
5773 NK_LIB void nk_finish_popup(struct nk_context *ctx, struct nk_window*);
5774 NK_LIB void nk_finish_buffer(struct nk_context *ctx, struct nk_command_buffer *b);
5775 NK_LIB void nk_finish(struct nk_context *ctx, struct nk_window *w);
5776 NK_LIB void nk_build(struct nk_context *ctx);
5777 
5778 /* text editor */
5779 NK_LIB void nk_textedit_clear_state(struct nk_text_edit *state, enum nk_text_edit_type type, nk_plugin_filter filter);
5780 NK_LIB void nk_textedit_click(struct nk_text_edit *state, float x, float y, const struct nk_user_font *font, float row_height);
5781 NK_LIB void nk_textedit_drag(struct nk_text_edit *state, float x, float y, const struct nk_user_font *font, float row_height);
5782 NK_LIB void nk_textedit_key(struct nk_text_edit *state, enum nk_keys key, int shift_mod, const struct nk_user_font *font, float row_height);
5783 
5784 /* window */
5785 enum nk_window_insert_location {
5786  NK_INSERT_BACK, /* inserts window into the back of list (front of screen) */
5787  NK_INSERT_FRONT /* inserts window into the front of list (back of screen) */
5788 };
5789 NK_LIB void *nk_create_window(struct nk_context *ctx);
5790 NK_LIB void nk_remove_window(struct nk_context*, struct nk_window*);
5791 NK_LIB void nk_free_window(struct nk_context *ctx, struct nk_window *win);
5792 NK_LIB struct nk_window *nk_find_window(struct nk_context *ctx, nk_hash hash, const char *name);
5793 NK_LIB void nk_insert_window(struct nk_context *ctx, struct nk_window *win, enum nk_window_insert_location loc);
5794 
5795 /* pool */
5796 NK_LIB void nk_pool_init(struct nk_pool *pool, struct nk_allocator *alloc, unsigned int capacity);
5797 NK_LIB void nk_pool_free(struct nk_pool *pool);
5798 NK_LIB void nk_pool_init_fixed(struct nk_pool *pool, void *memory, nk_size size);
5799 NK_LIB struct nk_page_element *nk_pool_alloc(struct nk_pool *pool);
5800 
5801 /* page-element */
5802 NK_LIB struct nk_page_element* nk_create_page_element(struct nk_context *ctx);
5803 NK_LIB void nk_link_page_element_into_freelist(struct nk_context *ctx, struct nk_page_element *elem);
5804 NK_LIB void nk_free_page_element(struct nk_context *ctx, struct nk_page_element *elem);
5805 
5806 /* table */
5807 NK_LIB struct nk_table* nk_create_table(struct nk_context *ctx);
5808 NK_LIB void nk_remove_table(struct nk_window *win, struct nk_table *tbl);
5809 NK_LIB void nk_free_table(struct nk_context *ctx, struct nk_table *tbl);
5810 NK_LIB void nk_push_table(struct nk_window *win, struct nk_table *tbl);
5811 NK_LIB nk_uint *nk_add_value(struct nk_context *ctx, struct nk_window *win, nk_hash name, nk_uint value);
5812 NK_LIB nk_uint *nk_find_value(struct nk_window *win, nk_hash name);
5813 
5814 /* panel */
5815 NK_LIB void *nk_create_panel(struct nk_context *ctx);
5816 NK_LIB void nk_free_panel(struct nk_context*, struct nk_panel *pan);
5817 NK_LIB int nk_panel_has_header(nk_flags flags, const char *title);
5818 NK_LIB struct nk_vec2 nk_panel_get_padding(const struct nk_style *style, enum nk_panel_type type);
5819 NK_LIB float nk_panel_get_border(const struct nk_style *style, nk_flags flags, enum nk_panel_type type);
5820 NK_LIB struct nk_color nk_panel_get_border_color(const struct nk_style *style, enum nk_panel_type type);
5821 NK_LIB int nk_panel_is_sub(enum nk_panel_type type);
5822 NK_LIB int nk_panel_is_nonblock(enum nk_panel_type type);
5823 NK_LIB int nk_panel_begin(struct nk_context *ctx, const char *title, enum nk_panel_type panel_type);
5824 NK_LIB void nk_panel_end(struct nk_context *ctx);
5825 
5826 /* layout */
5827 NK_LIB float nk_layout_row_calculate_usable_space(const struct nk_style *style, enum nk_panel_type type, float total_space, int columns);
5828 NK_LIB void nk_panel_layout(const struct nk_context *ctx, struct nk_window *win, float height, int cols);
5829 NK_LIB void nk_row_layout(struct nk_context *ctx, enum nk_layout_format fmt, float height, int cols, int width);
5830 NK_LIB void nk_panel_alloc_row(const struct nk_context *ctx, struct nk_window *win);
5831 NK_LIB void nk_layout_widget_space(struct nk_rect *bounds, const struct nk_context *ctx, struct nk_window *win, int modify);
5832 NK_LIB void nk_panel_alloc_space(struct nk_rect *bounds, const struct nk_context *ctx);
5833 NK_LIB void nk_layout_peek(struct nk_rect *bounds, struct nk_context *ctx);
5834 
5835 /* popup */
5836 NK_LIB int nk_nonblock_begin(struct nk_context *ctx, nk_flags flags, struct nk_rect body, struct nk_rect header, enum nk_panel_type panel_type);
5837 
5838 /* text */
5839 struct nk_text {
5840  struct nk_vec2 padding;
5841  struct nk_color background;
5842  struct nk_color text;
5843 };
5844 NK_LIB void nk_widget_text(struct nk_command_buffer *o, struct nk_rect b, const char *string, int len, const struct nk_text *t, nk_flags a, const struct nk_user_font *f);
5845 NK_LIB void nk_widget_text_wrap(struct nk_command_buffer *o, struct nk_rect b, const char *string, int len, const struct nk_text *t, const struct nk_user_font *f);
5846 
5847 /* button */
5848 NK_LIB int nk_button_behavior(nk_flags *state, struct nk_rect r, const struct nk_input *i, enum nk_button_behavior behavior);
5849 NK_LIB const struct nk_style_item* nk_draw_button(struct nk_command_buffer *out, const struct nk_rect *bounds, nk_flags state, const struct nk_style_button *style);
5850 NK_LIB int nk_do_button(nk_flags *state, struct nk_command_buffer *out, struct nk_rect r, const struct nk_style_button *style, const struct nk_input *in, enum nk_button_behavior behavior, struct nk_rect *content);
5851 NK_LIB void nk_draw_button_text(struct nk_command_buffer *out, const struct nk_rect *bounds, const struct nk_rect *content, nk_flags state, const struct nk_style_button *style, const char *txt, int len, nk_flags text_alignment, const struct nk_user_font *font);
5852 NK_LIB int nk_do_button_text(nk_flags *state, struct nk_command_buffer *out, struct nk_rect bounds, const char *string, int len, nk_flags align, enum nk_button_behavior behavior, const struct nk_style_button *style, const struct nk_input *in, const struct nk_user_font *font);
5853 NK_LIB void nk_draw_button_symbol(struct nk_command_buffer *out, const struct nk_rect *bounds, const struct nk_rect *content, nk_flags state, const struct nk_style_button *style, enum nk_symbol_type type, const struct nk_user_font *font);
5854 NK_LIB int nk_do_button_symbol(nk_flags *state, struct nk_command_buffer *out, struct nk_rect bounds, enum nk_symbol_type symbol, enum nk_button_behavior behavior, const struct nk_style_button *style, const struct nk_input *in, const struct nk_user_font *font);
5855 NK_LIB void nk_draw_button_image(struct nk_command_buffer *out, const struct nk_rect *bounds, const struct nk_rect *content, nk_flags state, const struct nk_style_button *style, const struct nk_image *img);
5856 NK_LIB int nk_do_button_image(nk_flags *state, struct nk_command_buffer *out, struct nk_rect bounds, struct nk_image img, enum nk_button_behavior b, const struct nk_style_button *style, const struct nk_input *in);
5857 NK_LIB void nk_draw_button_text_symbol(struct nk_command_buffer *out, const struct nk_rect *bounds, const struct nk_rect *label, const struct nk_rect *symbol, nk_flags state, const struct nk_style_button *style, const char *str, int len, enum nk_symbol_type type, const struct nk_user_font *font);
5858 NK_LIB int nk_do_button_text_symbol(nk_flags *state, struct nk_command_buffer *out, struct nk_rect bounds, enum nk_symbol_type symbol, const char *str, int len, nk_flags align, enum nk_button_behavior behavior, const struct nk_style_button *style, const struct nk_user_font *font, const struct nk_input *in);
5859 NK_LIB void nk_draw_button_text_image(struct nk_command_buffer *out, const struct nk_rect *bounds, const struct nk_rect *label, const struct nk_rect *image, nk_flags state, const struct nk_style_button *style, const char *str, int len, const struct nk_user_font *font, const struct nk_image *img);
5860 NK_LIB int nk_do_button_text_image(nk_flags *state, struct nk_command_buffer *out, struct nk_rect bounds, struct nk_image img, const char* str, int len, nk_flags align, enum nk_button_behavior behavior, const struct nk_style_button *style, const struct nk_user_font *font, const struct nk_input *in);
5861 
5862 /* toggle */
5863 enum nk_toggle_type {
5864  NK_TOGGLE_CHECK,
5865  NK_TOGGLE_OPTION
5866 };
5867 NK_LIB int nk_toggle_behavior(const struct nk_input *in, struct nk_rect select, nk_flags *state, int active);
5868 NK_LIB void nk_draw_checkbox(struct nk_command_buffer *out, nk_flags state, const struct nk_style_toggle *style, int active, const struct nk_rect *label, const struct nk_rect *selector, const struct nk_rect *cursors, const char *string, int len, const struct nk_user_font *font);
5869 NK_LIB void nk_draw_option(struct nk_command_buffer *out, nk_flags state, const struct nk_style_toggle *style, int active, const struct nk_rect *label, const struct nk_rect *selector, const struct nk_rect *cursors, const char *string, int len, const struct nk_user_font *font);
5870 NK_LIB int nk_do_toggle(nk_flags *state, struct nk_command_buffer *out, struct nk_rect r, int *active, const char *str, int len, enum nk_toggle_type type, const struct nk_style_toggle *style, const struct nk_input *in, const struct nk_user_font *font);
5871 
5872 /* progress */
5873 NK_LIB nk_size nk_progress_behavior(nk_flags *state, struct nk_input *in, struct nk_rect r, struct nk_rect cursor, nk_size max, nk_size value, int modifiable);
5874 NK_LIB void nk_draw_progress(struct nk_command_buffer *out, nk_flags state, const struct nk_style_progress *style, const struct nk_rect *bounds, const struct nk_rect *scursor, nk_size value, nk_size max);
5875 NK_LIB nk_size nk_do_progress(nk_flags *state, struct nk_command_buffer *out, struct nk_rect bounds, nk_size value, nk_size max, int modifiable, const struct nk_style_progress *style, struct nk_input *in);
5876 
5877 /* slider */
5878 NK_LIB float nk_slider_behavior(nk_flags *state, struct nk_rect *logical_cursor, struct nk_rect *visual_cursor, struct nk_input *in, struct nk_rect bounds, float slider_min, float slider_max, float slider_value, float slider_step, float slider_steps);
5879 NK_LIB void nk_draw_slider(struct nk_command_buffer *out, nk_flags state, const struct nk_style_slider *style, const struct nk_rect *bounds, const struct nk_rect *visual_cursor, float min, float value, float max);
5880 NK_LIB float nk_do_slider(nk_flags *state, struct nk_command_buffer *out, struct nk_rect bounds, float min, float val, float max, float step, const struct nk_style_slider *style, struct nk_input *in, const struct nk_user_font *font);
5881 
5882 /* scrollbar */
5883 NK_LIB float nk_scrollbar_behavior(nk_flags *state, struct nk_input *in, int has_scrolling, const struct nk_rect *scroll, const struct nk_rect *cursor, const struct nk_rect *empty0, const struct nk_rect *empty1, float scroll_offset, float target, float scroll_step, enum nk_orientation o);
5884 NK_LIB void nk_draw_scrollbar(struct nk_command_buffer *out, nk_flags state, const struct nk_style_scrollbar *style, const struct nk_rect *bounds, const struct nk_rect *scroll);
5885 NK_LIB float nk_do_scrollbarv(nk_flags *state, struct nk_command_buffer *out, struct nk_rect scroll, int has_scrolling, float offset, float target, float step, float button_pixel_inc, const struct nk_style_scrollbar *style, struct nk_input *in, const struct nk_user_font *font);
5886 NK_LIB float nk_do_scrollbarh(nk_flags *state, struct nk_command_buffer *out, struct nk_rect scroll, int has_scrolling, float offset, float target, float step, float button_pixel_inc, const struct nk_style_scrollbar *style, struct nk_input *in, const struct nk_user_font *font);
5887 
5888 /* selectable */
5889 NK_LIB void nk_draw_selectable(struct nk_command_buffer *out, nk_flags state, const struct nk_style_selectable *style, int active, const struct nk_rect *bounds, const struct nk_rect *icon, const struct nk_image *img, enum nk_symbol_type sym, const char *string, int len, nk_flags align, const struct nk_user_font *font);
5890 NK_LIB int nk_do_selectable(nk_flags *state, struct nk_command_buffer *out, struct nk_rect bounds, const char *str, int len, nk_flags align, int *value, const struct nk_style_selectable *style, const struct nk_input *in, const struct nk_user_font *font);
5891 NK_LIB int nk_do_selectable_image(nk_flags *state, struct nk_command_buffer *out, struct nk_rect bounds, const char *str, int len, nk_flags align, int *value, const struct nk_image *img, const struct nk_style_selectable *style, const struct nk_input *in, const struct nk_user_font *font);
5892 
5893 /* edit */
5894 NK_LIB void nk_edit_draw_text(struct nk_command_buffer *out, const struct nk_style_edit *style, float pos_x, float pos_y, float x_offset, const char *text, int byte_len, float row_height, const struct nk_user_font *font, struct nk_color background, struct nk_color foreground, int is_selected);
5895 NK_LIB nk_flags nk_do_edit(nk_flags *state, struct nk_command_buffer *out, struct nk_rect bounds, nk_flags flags, nk_plugin_filter filter, struct nk_text_edit *edit, const struct nk_style_edit *style, struct nk_input *in, const struct nk_user_font *font);
5896 
5897 /* color-picker */
5898 NK_LIB int nk_color_picker_behavior(nk_flags *state, const struct nk_rect *bounds, const struct nk_rect *matrix, const struct nk_rect *hue_bar, const struct nk_rect *alpha_bar, struct nk_colorf *color, const struct nk_input *in);
5899 NK_LIB void nk_draw_color_picker(struct nk_command_buffer *o, const struct nk_rect *matrix, const struct nk_rect *hue_bar, const struct nk_rect *alpha_bar, struct nk_colorf col);
5900 NK_LIB int nk_do_color_picker(nk_flags *state, struct nk_command_buffer *out, struct nk_colorf *col, enum nk_color_format fmt, struct nk_rect bounds, struct nk_vec2 padding, const struct nk_input *in, const struct nk_user_font *font);
5901 
5902 /* property */
5903 enum nk_property_status {
5904  NK_PROPERTY_DEFAULT,
5905  NK_PROPERTY_EDIT,
5906  NK_PROPERTY_DRAG
5907 };
5908 enum nk_property_filter {
5909  NK_FILTER_INT,
5910  NK_FILTER_FLOAT
5911 };
5912 enum nk_property_kind {
5913  NK_PROPERTY_INT,
5914  NK_PROPERTY_FLOAT,
5915  NK_PROPERTY_DOUBLE
5916 };
5917 union nk_property {
5918  int i;
5919  float f;
5920  double d;
5921 };
5922 struct nk_property_variant {
5923  enum nk_property_kind kind;
5924  union nk_property value;
5925  union nk_property min_value;
5926  union nk_property max_value;
5927  union nk_property step;
5928 };
5929 NK_LIB struct nk_property_variant nk_property_variant_int(int value, int min_value, int max_value, int step);
5930 NK_LIB struct nk_property_variant nk_property_variant_float(float value, float min_value, float max_value, float step);
5931 NK_LIB struct nk_property_variant nk_property_variant_double(double value, double min_value, double max_value, double step);
5932 
5933 NK_LIB void nk_drag_behavior(nk_flags *state, const struct nk_input *in, struct nk_rect drag, struct nk_property_variant *variant, float inc_per_pixel);
5934 NK_LIB void nk_property_behavior(nk_flags *ws, const struct nk_input *in, struct nk_rect property, struct nk_rect label, struct nk_rect edit, struct nk_rect empty, int *state, struct nk_property_variant *variant, float inc_per_pixel);
5935 NK_LIB void nk_draw_property(struct nk_command_buffer *out, const struct nk_style_property *style, const struct nk_rect *bounds, const struct nk_rect *label, nk_flags state, const char *name, int len, const struct nk_user_font *font);
5936 NK_LIB void nk_do_property(nk_flags *ws, struct nk_command_buffer *out, struct nk_rect property, const char *name, struct nk_property_variant *variant, float inc_per_pixel, char *buffer, int *len, int *state, int *cursor, int *select_begin, int *select_end, const struct nk_style_property *style, enum nk_property_filter filter, struct nk_input *in, const struct nk_user_font *font, struct nk_text_edit *text_edit, enum nk_button_behavior behavior);
5937 NK_LIB void nk_property(struct nk_context *ctx, const char *name, struct nk_property_variant *variant, float inc_per_pixel, const enum nk_property_filter filter);
5938 
5939 #endif
5940 
5941 
5942 
5943 
5944 
5945 /* ===============================================================
5946  *
5947  * MATH
5948  *
5949  * ===============================================================*/
5950 /* Since nuklear is supposed to work on all systems providing floating point
5951  math without any dependencies I also had to implement my own math functions
5952  for sqrt, sin and cos. Since the actual highly accurate implementations for
5953  the standard library functions are quite complex and I do not need high
5954  precision for my use cases I use approximations.
5955 
5956  Sqrt
5957  ----
5958  For square root nuklear uses the famous fast inverse square root:
5959  https://en.wikipedia.org/wiki/Fast_inverse_square_root with
5960  slightly tweaked magic constant. While on today's hardware it is
5961  probably not faster it is still fast and accurate enough for
5962  nuklear's use cases. IMPORTANT: this requires float format IEEE 754
5963 
5964  Sine/Cosine
5965  -----------
5966  All constants inside both function are generated Remez's minimax
5967  approximations for value range 0...2*PI. The reason why I decided to
5968  approximate exactly that range is that nuklear only needs sine and
5969  cosine to generate circles which only requires that exact range.
5970  In addition I used Remez instead of Taylor for additional precision:
5971  www.lolengine.net/blog/2011/12/21/better-function-approximations.
5972 
5973  The tool I used to generate constants for both sine and cosine
5974  (it can actually approximate a lot more functions) can be
5975  found here: www.lolengine.net/wiki/oss/lolremez
5976 */
5977 NK_LIB float
5978 nk_inv_sqrt(float n)
5979 {
5980  float x2;
5981  const float threehalfs = 1.5f;
5982  union {nk_uint i; float f;} conv = {0};
5983  conv.f = n;
5984  x2 = n * 0.5f;
5985  conv.i = 0x5f375A84 - (conv.i >> 1);
5986  conv.f = conv.f * (threehalfs - (x2 * conv.f * conv.f));
5987  return conv.f;
5988 }
5989 NK_LIB float
5990 nk_sqrt(float x)
5991 {
5992  return x * nk_inv_sqrt(x);
5993 }
5994 NK_LIB float
5995 nk_sin(float x)
5996 {
5997  NK_STORAGE const float a0 = +1.91059300966915117e-31f;
5998  NK_STORAGE const float a1 = +1.00086760103908896f;
5999  NK_STORAGE const float a2 = -1.21276126894734565e-2f;
6000  NK_STORAGE const float a3 = -1.38078780785773762e-1f;
6001  NK_STORAGE const float a4 = -2.67353392911981221e-2f;
6002  NK_STORAGE const float a5 = +2.08026600266304389e-2f;
6003  NK_STORAGE const float a6 = -3.03996055049204407e-3f;
6004  NK_STORAGE const float a7 = +1.38235642404333740e-4f;
6005  return a0 + x*(a1 + x*(a2 + x*(a3 + x*(a4 + x*(a5 + x*(a6 + x*a7))))));
6006 }
6007 NK_LIB float
6008 nk_cos(float x)
6009 {
6010  NK_STORAGE const float a0 = +1.00238601909309722f;
6011  NK_STORAGE const float a1 = -3.81919947353040024e-2f;
6012  NK_STORAGE const float a2 = -3.94382342128062756e-1f;
6013  NK_STORAGE const float a3 = -1.18134036025221444e-1f;
6014  NK_STORAGE const float a4 = +1.07123798512170878e-1f;
6015  NK_STORAGE const float a5 = -1.86637164165180873e-2f;
6016  NK_STORAGE const float a6 = +9.90140908664079833e-4f;
6017  NK_STORAGE const float a7 = -5.23022132118824778e-14f;
6018  return a0 + x*(a1 + x*(a2 + x*(a3 + x*(a4 + x*(a5 + x*(a6 + x*a7))))));
6019 }
6020 NK_LIB nk_uint
6021 nk_round_up_pow2(nk_uint v)
6022 {
6023  v--;
6024  v |= v >> 1;
6025  v |= v >> 2;
6026  v |= v >> 4;
6027  v |= v >> 8;
6028  v |= v >> 16;
6029  v++;
6030  return v;
6031 }
6032 NK_LIB double
6033 nk_pow(double x, int n)
6034 {
6035  /* check the sign of n */
6036  double r = 1;
6037  int plus = n >= 0;
6038  n = (plus) ? n : -n;
6039  while (n > 0) {
6040  if ((n & 1) == 1)
6041  r *= x;
6042  n /= 2;
6043  x *= x;
6044  }
6045  return plus ? r : 1.0 / r;
6046 }
6047 NK_LIB int
6048 nk_ifloord(double x)
6049 {
6050  x = (double)((int)x - ((x < 0.0) ? 1 : 0));
6051  return (int)x;
6052 }
6053 NK_LIB int
6054 nk_ifloorf(float x)
6055 {
6056  x = (float)((int)x - ((x < 0.0f) ? 1 : 0));
6057  return (int)x;
6058 }
6059 NK_LIB int
6060 nk_iceilf(float x)
6061 {
6062  if (x >= 0) {
6063  int i = (int)x;
6064  return (x > i) ? i+1: i;
6065  } else {
6066  int t = (int)x;
6067  float r = x - (float)t;
6068  return (r > 0.0f) ? t+1: t;
6069  }
6070 }
6071 NK_LIB int
6072 nk_log10(double n)
6073 {
6074  int neg;
6075  int ret;
6076  int exp = 0;
6077 
6078  neg = (n < 0) ? 1 : 0;
6079  ret = (neg) ? (int)-n : (int)n;
6080  while ((ret / 10) > 0) {
6081  ret /= 10;
6082  exp++;
6083  }
6084  if (neg) exp = -exp;
6085  return exp;
6086 }
6087 NK_API struct nk_rect
6089 {
6090  return nk_null_rect;
6091 }
6092 NK_API struct nk_rect
6093 nk_rect(float x, float y, float w, float h)
6094 {
6095  struct nk_rect r;
6096  r.x = x; r.y = y;
6097  r.w = w; r.h = h;
6098  return r;
6099 }
6100 NK_API struct nk_rect
6101 nk_recti(int x, int y, int w, int h)
6102 {
6103  struct nk_rect r;
6104  r.x = (float)x;
6105  r.y = (float)y;
6106  r.w = (float)w;
6107  r.h = (float)h;
6108  return r;
6109 }
6110 NK_API struct nk_rect
6111 nk_recta(struct nk_vec2 pos, struct nk_vec2 size)
6112 {
6113  return nk_rect(pos.x, pos.y, size.x, size.y);
6114 }
6115 NK_API struct nk_rect
6116 nk_rectv(const float *r)
6117 {
6118  return nk_rect(r[0], r[1], r[2], r[3]);
6119 }
6120 NK_API struct nk_rect
6121 nk_rectiv(const int *r)
6122 {
6123  return nk_recti(r[0], r[1], r[2], r[3]);
6124 }
6125 NK_API struct nk_vec2
6126 nk_rect_pos(struct nk_rect r)
6127 {
6128  struct nk_vec2 ret;
6129  ret.x = r.x; ret.y = r.y;
6130  return ret;
6131 }
6132 NK_API struct nk_vec2
6133 nk_rect_size(struct nk_rect r)
6134 {
6135  struct nk_vec2 ret;
6136  ret.x = r.w; ret.y = r.h;
6137  return ret;
6138 }
6139 NK_LIB struct nk_rect
6140 nk_shrink_rect(struct nk_rect r, float amount)
6141 {
6142  struct nk_rect res;
6143  r.w = NK_MAX(r.w, 2 * amount);
6144  r.h = NK_MAX(r.h, 2 * amount);
6145  res.x = r.x + amount;
6146  res.y = r.y + amount;
6147  res.w = r.w - 2 * amount;
6148  res.h = r.h - 2 * amount;
6149  return res;
6150 }
6151 NK_LIB struct nk_rect
6152 nk_pad_rect(struct nk_rect r, struct nk_vec2 pad)
6153 {
6154  r.w = NK_MAX(r.w, 2 * pad.x);
6155  r.h = NK_MAX(r.h, 2 * pad.y);
6156  r.x += pad.x; r.y += pad.y;
6157  r.w -= 2 * pad.x;
6158  r.h -= 2 * pad.y;
6159  return r;
6160 }
6161 NK_API struct nk_vec2
6162 nk_vec2(float x, float y)
6163 {
6164  struct nk_vec2 ret;
6165  ret.x = x; ret.y = y;
6166  return ret;
6167 }
6168 NK_API struct nk_vec2
6169 nk_vec2i(int x, int y)
6170 {
6171  struct nk_vec2 ret;
6172  ret.x = (float)x;
6173  ret.y = (float)y;
6174  return ret;
6175 }
6176 NK_API struct nk_vec2
6177 nk_vec2v(const float *v)
6178 {
6179  return nk_vec2(v[0], v[1]);
6180 }
6181 NK_API struct nk_vec2
6182 nk_vec2iv(const int *v)
6183 {
6184  return nk_vec2i(v[0], v[1]);
6185 }
6186 NK_LIB void
6187 nk_unify(struct nk_rect *clip, const struct nk_rect *a, float x0, float y0,
6188  float x1, float y1)
6189 {
6190  NK_ASSERT(a);
6191  NK_ASSERT(clip);
6192  clip->x = NK_MAX(a->x, x0);
6193  clip->y = NK_MAX(a->y, y0);
6194  clip->w = NK_MIN(a->x + a->w, x1) - clip->x;
6195  clip->h = NK_MIN(a->y + a->h, y1) - clip->y;
6196  clip->w = NK_MAX(0, clip->w);
6197  clip->h = NK_MAX(0, clip->h);
6198 }
6199 
6200 NK_API void
6202  float pad_x, float pad_y, enum nk_heading direction)
6203 {
6204  float w_half, h_half;
6205  NK_ASSERT(result);
6206 
6207  r.w = NK_MAX(2 * pad_x, r.w);
6208  r.h = NK_MAX(2 * pad_y, r.h);
6209  r.w = r.w - 2 * pad_x;
6210  r.h = r.h - 2 * pad_y;
6211 
6212  r.x = r.x + pad_x;
6213  r.y = r.y + pad_y;
6214 
6215  w_half = r.w / 2.0f;
6216  h_half = r.h / 2.0f;
6217 
6218  if (direction == NK_UP) {
6219  result[0] = nk_vec2(r.x + w_half, r.y);
6220  result[1] = nk_vec2(r.x + r.w, r.y + r.h);
6221  result[2] = nk_vec2(r.x, r.y + r.h);
6222  } else if (direction == NK_RIGHT) {
6223  result[0] = nk_vec2(r.x, r.y);
6224  result[1] = nk_vec2(r.x + r.w, r.y + h_half);
6225  result[2] = nk_vec2(r.x, r.y + r.h);
6226  } else if (direction == NK_DOWN) {
6227  result[0] = nk_vec2(r.x, r.y);
6228  result[1] = nk_vec2(r.x + r.w, r.y);
6229  result[2] = nk_vec2(r.x + w_half, r.y + r.h);
6230  } else {
6231  result[0] = nk_vec2(r.x, r.y + h_half);
6232  result[1] = nk_vec2(r.x + r.w, r.y);
6233  result[2] = nk_vec2(r.x + r.w, r.y + r.h);
6234  }
6235 }
6236 
6237 
6238 
6239 
6240