Nuklear
This is a minimal-state, immediate-mode graphical user interface toolkit written in ANSI C and licensed under public domain. It was designed as a simple embeddable user interface for application and does not have any dependencies, a default render backend or OS window/input handling but instead provides a highly modular, library-based approach, with simple input state for input and draw commands describing primitive shapes as output. So instead of providing a layered library that tries to abstract over a number of platform and render backends, it focuses only on the actual UI.
 
Loading...
Searching...
No Matches
nuklear.h
Go to the documentation of this file.
1
6#ifndef NK_NUKLEAR_H_
7#define NK_NUKLEAR_H_
8
9#ifdef __cplusplus
10extern "C" {
11#endif
12/*
13 * ==============================================================
14 *
15 * CONSTANTS
16 *
17 * ===============================================================
18 */
19
20#define NK_UNDEFINED (-1.0f)
21#define NK_UTF_INVALID 0xFFFD
22#define NK_UTF_SIZE 4
23#ifndef NK_INPUT_MAX
24 #define NK_INPUT_MAX 16
25#endif
26#ifndef NK_MAX_NUMBER_BUFFER
27 #define NK_MAX_NUMBER_BUFFER 64
28#endif
29#ifndef NK_SCROLLBAR_HIDING_TIMEOUT
30 #define NK_SCROLLBAR_HIDING_TIMEOUT 4.0f
31#endif
32/*
33 * ==============================================================
34 *
35 * HELPER
36 *
37 * ===============================================================
38 */
39
40#ifndef NK_API
41 #ifdef NK_PRIVATE
42 #if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199409L))
43 #define NK_API static inline
44 #elif defined(__cplusplus)
45 #define NK_API static inline
46 #else
47 #define NK_API static
48 #endif
49 #else
50 #define NK_API extern
51 #endif
52#endif
53#ifndef NK_LIB
54 #ifdef NK_SINGLE_FILE
55 #define NK_LIB static
56 #else
57 #define NK_LIB extern
58 #endif
59#endif
60
61#define NK_INTERN static
62#define NK_STORAGE static
63#define NK_GLOBAL static
64
65#define NK_FLAG(x) (1 << (x))
66#define NK_STRINGIFY(x) #x
67#define NK_MACRO_STRINGIFY(x) NK_STRINGIFY(x)
68#define NK_STRING_JOIN_IMMEDIATE(arg1, arg2) arg1 ## arg2
69#define NK_STRING_JOIN_DELAY(arg1, arg2) NK_STRING_JOIN_IMMEDIATE(arg1, arg2)
70#define NK_STRING_JOIN(arg1, arg2) NK_STRING_JOIN_DELAY(arg1, arg2)
71
72#ifdef _MSC_VER
73 #define NK_UNIQUE_NAME(name) NK_STRING_JOIN(name,__COUNTER__)
74#else
75 #define NK_UNIQUE_NAME(name) NK_STRING_JOIN(name,__LINE__)
76#endif
77
78#ifndef NK_STATIC_ASSERT
79 #define NK_STATIC_ASSERT(exp) typedef char NK_UNIQUE_NAME(_dummy_array)[(exp)?1:-1]
80#endif
81
82#ifndef NK_FILE_LINE
83#ifdef _MSC_VER
84 #define NK_FILE_LINE __FILE__ ":" NK_MACRO_STRINGIFY(__COUNTER__)
85#else
86 #define NK_FILE_LINE __FILE__ ":" NK_MACRO_STRINGIFY(__LINE__)
87#endif
88#endif
89
90#define NK_MIN(a,b) ((a) < (b) ? (a) : (b))
91#define NK_MAX(a,b) ((a) < (b) ? (b) : (a))
92#define NK_CLAMP(i,v,x) (NK_MAX(NK_MIN(v,x), i))
93
94#ifdef NK_INCLUDE_STANDARD_VARARGS
95 #include <stdarg.h>
96 #if defined(_MSC_VER) && (_MSC_VER >= 1600) /* VS 2010 and above */
97 #include <sal.h>
98 #define NK_PRINTF_FORMAT_STRING _Printf_format_string_
99 #else
100 #define NK_PRINTF_FORMAT_STRING
101 #endif
102 #if defined(__GNUC__)
103 #define NK_PRINTF_VARARG_FUNC(fmtargnumber) __attribute__((format(__printf__, fmtargnumber, fmtargnumber+1)))
104 #define NK_PRINTF_VALIST_FUNC(fmtargnumber) __attribute__((format(__printf__, fmtargnumber, 0)))
105 #else
106 #define NK_PRINTF_VARARG_FUNC(fmtargnumber)
107 #define NK_PRINTF_VALIST_FUNC(fmtargnumber)
108 #endif
109#endif
110
111/*
112 * ===============================================================
113 *
114 * BASIC
115 *
116 * ===============================================================
117 */
118 #ifdef NK_INCLUDE_FIXED_TYPES
119 #include <stdint.h>
120 #define NK_INT8 int8_t
121 #define NK_UINT8 uint8_t
122 #define NK_INT16 int16_t
123 #define NK_UINT16 uint16_t
124 #define NK_INT32 int32_t
125 #define NK_UINT32 uint32_t
126 #define NK_SIZE_TYPE uintptr_t
127 #define NK_POINTER_TYPE uintptr_t
128#else
129 #ifndef NK_INT8
130 #define NK_INT8 signed char
131 #endif
132 #ifndef NK_UINT8
133 #define NK_UINT8 unsigned char
134 #endif
135 #ifndef NK_INT16
136 #define NK_INT16 signed short
137 #endif
138 #ifndef NK_UINT16
139 #define NK_UINT16 unsigned short
140 #endif
141 #ifndef NK_INT32
142 #if defined(_MSC_VER)
143 #define NK_INT32 __int32
144 #else
145 #define NK_INT32 signed int
146 #endif
147 #endif
148 #ifndef NK_UINT32
149 #if defined(_MSC_VER)
150 #define NK_UINT32 unsigned __int32
151 #else
152 #define NK_UINT32 unsigned int
153 #endif
154 #endif
155 #ifndef NK_SIZE_TYPE
156 #if defined(_WIN64) && defined(_MSC_VER)
157 #define NK_SIZE_TYPE unsigned __int64
158 #elif (defined(_WIN32) || defined(WIN32)) && defined(_MSC_VER)
159 #define NK_SIZE_TYPE unsigned __int32
160 #elif defined(__GNUC__) || defined(__clang__)
161 #if defined(__x86_64__) || defined(__ppc64__) || defined(__PPC64__) || defined(__aarch64__)
162 #define NK_SIZE_TYPE unsigned long
163 #else
164 #define NK_SIZE_TYPE unsigned int
165 #endif
166 #else
167 #define NK_SIZE_TYPE unsigned long
168 #endif
169 #endif
170 #ifndef NK_POINTER_TYPE
171 #if defined(_WIN64) && defined(_MSC_VER)
172 #define NK_POINTER_TYPE unsigned __int64
173 #elif (defined(_WIN32) || defined(WIN32)) && defined(_MSC_VER)
174 #define NK_POINTER_TYPE unsigned __int32
175 #elif defined(__GNUC__) || defined(__clang__)
176 #if defined(__x86_64__) || defined(__ppc64__) || defined(__PPC64__) || defined(__aarch64__)
177 #define NK_POINTER_TYPE unsigned long
178 #else
179 #define NK_POINTER_TYPE unsigned int
180 #endif
181 #else
182 #define NK_POINTER_TYPE unsigned long
183 #endif
184 #endif
185#endif
186
187#ifndef NK_BOOL
188 #ifdef NK_INCLUDE_STANDARD_BOOL
189 #include <stdbool.h>
190 #define NK_BOOL bool
191 #else
192 #define NK_BOOL int
193 #endif
194#endif
195
196typedef NK_INT8 nk_char;
197typedef NK_UINT8 nk_uchar;
198typedef NK_UINT8 nk_byte;
199typedef NK_INT16 nk_short;
200typedef NK_UINT16 nk_ushort;
201typedef NK_INT32 nk_int;
202typedef NK_UINT32 nk_uint;
203typedef NK_SIZE_TYPE nk_size;
204typedef NK_POINTER_TYPE nk_ptr;
205typedef NK_BOOL nk_bool;
206
207typedef nk_uint nk_hash;
208typedef nk_uint nk_flags;
209typedef nk_uint nk_rune;
210
211/* Make sure correct type size:
212 * This will fire with a negative subscript error if the type sizes
213 * are set incorrectly by the compiler, and compile out if not */
214NK_STATIC_ASSERT(sizeof(nk_short) == 2);
215NK_STATIC_ASSERT(sizeof(nk_ushort) == 2);
216NK_STATIC_ASSERT(sizeof(nk_uint) == 4);
217NK_STATIC_ASSERT(sizeof(nk_int) == 4);
218NK_STATIC_ASSERT(sizeof(nk_byte) == 1);
219NK_STATIC_ASSERT(sizeof(nk_flags) >= 4);
220NK_STATIC_ASSERT(sizeof(nk_rune) >= 4);
221NK_STATIC_ASSERT(sizeof(nk_size) >= sizeof(void*));
222NK_STATIC_ASSERT(sizeof(nk_ptr) >= sizeof(void*));
223#ifdef NK_INCLUDE_STANDARD_BOOL
224NK_STATIC_ASSERT(sizeof(nk_bool) == sizeof(bool));
225#else
226NK_STATIC_ASSERT(sizeof(nk_bool) >= 2);
227#endif
228
229/* ============================================================================
230 *
231 * API
232 *
233 * =========================================================================== */
234struct nk_buffer;
235struct nk_allocator;
236struct nk_command_buffer;
237struct nk_draw_command;
238struct nk_convert_config;
239struct nk_style_item;
240struct nk_text_edit;
241struct nk_draw_list;
242struct nk_user_font;
243struct nk_panel;
244struct nk_context;
245struct nk_draw_vertex_layout_element;
246struct nk_style_button;
247struct nk_style_toggle;
249struct nk_style_slide;
250struct nk_style_progress;
251struct nk_style_scrollbar;
252struct nk_style_edit;
253struct nk_style_property;
254struct nk_style_chart;
255struct nk_style_combo;
256struct nk_style_tab;
258struct nk_style_window;
259
260enum {nk_false, nk_true};
261struct nk_color {nk_byte r,g,b,a;};
262struct nk_colorf {float r,g,b,a;};
263struct nk_vec2 {float x,y;};
264struct nk_vec2i {short x, y;};
265struct nk_rect {float x,y,w,h;};
266struct nk_recti {short x,y,w,h;};
267typedef char nk_glyph[NK_UTF_SIZE];
268typedef union {void *ptr; int id;} nk_handle;
269struct nk_image {nk_handle handle; nk_ushort w, h; nk_ushort region[4];};
270struct nk_nine_slice {struct nk_image img; nk_ushort l, t, r, b;};
271struct nk_cursor {struct nk_image img; struct nk_vec2 size, offset;};
272struct nk_scroll {nk_uint x, y;};
273
274enum nk_heading {NK_UP, NK_RIGHT, NK_DOWN, NK_LEFT};
275enum nk_button_behavior {NK_BUTTON_DEFAULT, NK_BUTTON_REPEATER};
276enum nk_modify {NK_FIXED = nk_false, NK_MODIFIABLE = nk_true};
277enum nk_orientation {NK_VERTICAL, NK_HORIZONTAL};
278enum nk_collapse_states {NK_MINIMIZED = nk_false, NK_MAXIMIZED = nk_true};
279enum nk_show_states {NK_HIDDEN = nk_false, NK_SHOWN = nk_true};
280enum nk_chart_type {NK_CHART_LINES, NK_CHART_COLUMN, NK_CHART_MAX};
281enum nk_chart_event {NK_CHART_HOVERING = 0x01, NK_CHART_CLICKED = 0x02};
282enum nk_color_format {NK_RGB, NK_RGBA};
283enum nk_popup_type {NK_POPUP_STATIC, NK_POPUP_DYNAMIC};
284enum nk_layout_format {NK_DYNAMIC, NK_STATIC};
285enum nk_tree_type {NK_TREE_NODE, NK_TREE_TAB};
286
287typedef void*(*nk_plugin_alloc)(nk_handle, void *old, nk_size);
288typedef void (*nk_plugin_free)(nk_handle, void *old);
289typedef nk_bool(*nk_plugin_filter)(const struct nk_text_edit*, nk_rune unicode);
290typedef void(*nk_plugin_paste)(nk_handle, struct nk_text_edit*);
291typedef void(*nk_plugin_copy)(nk_handle, const char*, int len);
292
294 nk_handle userdata;
295 nk_plugin_alloc alloc;
296 nk_plugin_free free;
297};
298enum nk_symbol_type {
299 NK_SYMBOL_NONE,
300 NK_SYMBOL_X,
301 NK_SYMBOL_UNDERSCORE,
302 NK_SYMBOL_CIRCLE_SOLID,
303 NK_SYMBOL_CIRCLE_OUTLINE,
304 NK_SYMBOL_RECT_SOLID,
305 NK_SYMBOL_RECT_OUTLINE,
306 NK_SYMBOL_TRIANGLE_UP,
307 NK_SYMBOL_TRIANGLE_DOWN,
308 NK_SYMBOL_TRIANGLE_LEFT,
309 NK_SYMBOL_TRIANGLE_RIGHT,
310 NK_SYMBOL_PLUS,
311 NK_SYMBOL_MINUS,
312 NK_SYMBOL_TRIANGLE_UP_OUTLINE,
313 NK_SYMBOL_TRIANGLE_DOWN_OUTLINE,
314 NK_SYMBOL_TRIANGLE_LEFT_OUTLINE,
315 NK_SYMBOL_TRIANGLE_RIGHT_OUTLINE,
316 NK_SYMBOL_MAX
317};
318/* =============================================================================
319 *
320 * CONTEXT
321 *
322 * =============================================================================*/
358#ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
359
376NK_API nk_bool nk_init_default(struct nk_context*, const struct nk_user_font*);
377#endif
402NK_API nk_bool nk_init_fixed(struct nk_context*, void *memory, nk_size size, const struct nk_user_font*);
403
422NK_API nk_bool nk_init(struct nk_context*, const struct nk_allocator*, const struct nk_user_font*);
423
442NK_API nk_bool nk_init_custom(struct nk_context*, struct nk_buffer *cmds, struct nk_buffer *pool, const struct nk_user_font*);
443
457NK_API void nk_clear(struct nk_context*);
458
469NK_API void nk_free(struct nk_context*);
470
471#ifdef NK_INCLUDE_COMMAND_USERDATA
483NK_API void nk_set_user_data(struct nk_context*, nk_handle handle);
484#endif
485/* =============================================================================
486 *
487 * INPUT
488 *
489 * =============================================================================*/
554enum nk_keys {
555 NK_KEY_NONE,
556 NK_KEY_SHIFT,
557 NK_KEY_CTRL,
558 NK_KEY_DEL,
559 NK_KEY_ENTER,
560 NK_KEY_TAB,
561 NK_KEY_BACKSPACE,
562 NK_KEY_COPY,
563 NK_KEY_CUT,
564 NK_KEY_PASTE,
565 NK_KEY_UP,
566 NK_KEY_DOWN,
567 NK_KEY_LEFT,
568 NK_KEY_RIGHT,
569 /* Shortcuts: text field */
570 NK_KEY_TEXT_INSERT_MODE,
571 NK_KEY_TEXT_REPLACE_MODE,
572 NK_KEY_TEXT_RESET_MODE,
573 NK_KEY_TEXT_LINE_START,
574 NK_KEY_TEXT_LINE_END,
575 NK_KEY_TEXT_START,
576 NK_KEY_TEXT_END,
577 NK_KEY_TEXT_UNDO,
578 NK_KEY_TEXT_REDO,
579 NK_KEY_TEXT_SELECT_ALL,
580 NK_KEY_TEXT_WORD_LEFT,
581 NK_KEY_TEXT_WORD_RIGHT,
582 /* Shortcuts: scrollbar */
583 NK_KEY_SCROLL_START,
584 NK_KEY_SCROLL_END,
585 NK_KEY_SCROLL_DOWN,
586 NK_KEY_SCROLL_UP,
587 NK_KEY_MAX
588};
589enum nk_buttons {
590 NK_BUTTON_LEFT,
591 NK_BUTTON_MIDDLE,
592 NK_BUTTON_RIGHT,
593 NK_BUTTON_DOUBLE,
594 NK_BUTTON_MAX
595};
596
608NK_API void nk_input_begin(struct nk_context*);
609
622NK_API void nk_input_motion(struct nk_context*, int x, int y);
623
636NK_API void nk_input_key(struct nk_context*, enum nk_keys, nk_bool down);
637
652NK_API void nk_input_button(struct nk_context*, enum nk_buttons, int x, int y, nk_bool down);
653
668NK_API void nk_input_scroll(struct nk_context*, struct nk_vec2 val);
669
687NK_API void nk_input_char(struct nk_context*, char);
688
703NK_API void nk_input_glyph(struct nk_context*, const nk_glyph);
704
720NK_API void nk_input_unicode(struct nk_context*, nk_rune);
721
733NK_API void nk_input_end(struct nk_context*);
734
966enum nk_anti_aliasing {NK_ANTI_ALIASING_OFF, NK_ANTI_ALIASING_ON};
967enum nk_convert_result {
968 NK_CONVERT_SUCCESS = 0,
969 NK_CONVERT_INVALID_PARAM = 1,
970 NK_CONVERT_COMMAND_BUFFER_FULL = NK_FLAG(1),
971 NK_CONVERT_VERTEX_BUFFER_FULL = NK_FLAG(2),
972 NK_CONVERT_ELEMENT_BUFFER_FULL = NK_FLAG(3)
973};
975 nk_handle texture;
976 struct nk_vec2 uv;
977};
979 float global_alpha;
980 enum nk_anti_aliasing line_AA;
981 enum nk_anti_aliasing shape_AA;
986 const struct nk_draw_vertex_layout_element *vertex_layout;
987 nk_size vertex_size;
989};
990
1004NK_API const struct nk_command* nk__begin(struct nk_context*);
1005
1019NK_API const struct nk_command* nk__next(struct nk_context*, const struct nk_command*);
1020
1031#define nk_foreach(c, ctx) for((c) = nk__begin(ctx); (c) != 0; (c) = nk__next(ctx,c))
1032
1033#ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
1034
1064NK_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*);
1065
1079NK_API const struct nk_draw_command* nk__draw_begin(const struct nk_context*, const struct nk_buffer*);
1080
1098NK_API const struct nk_draw_command* nk__draw_end(const struct nk_context*, const struct nk_buffer*);
1099
1117NK_API const struct nk_draw_command* nk__draw_next(const struct nk_draw_command*, const struct nk_buffer*, const struct nk_context*);
1118
1134#define nk_draw_foreach(cmd,ctx, b) for((cmd)=nk__draw_begin(ctx, b); (cmd)!=0; (cmd)=nk__draw_next(cmd, b, ctx))
1135#endif
1136
1284enum nk_panel_flags {
1285 NK_WINDOW_BORDER = NK_FLAG(0),
1286 NK_WINDOW_MOVABLE = NK_FLAG(1),
1287 NK_WINDOW_SCALABLE = NK_FLAG(2),
1288 NK_WINDOW_CLOSABLE = NK_FLAG(3),
1289 NK_WINDOW_MINIMIZABLE = NK_FLAG(4),
1290 NK_WINDOW_NO_SCROLLBAR = NK_FLAG(5),
1291 NK_WINDOW_TITLE = NK_FLAG(6),
1292 NK_WINDOW_SCROLL_AUTO_HIDE = NK_FLAG(7),
1293 NK_WINDOW_BACKGROUND = NK_FLAG(8),
1294 NK_WINDOW_SCALE_LEFT = NK_FLAG(9),
1295 NK_WINDOW_NO_INPUT = NK_FLAG(10)
1296};
1297
1318NK_API nk_bool nk_begin(struct nk_context *ctx, const char *title, struct nk_rect bounds, nk_flags flags);
1319
1341NK_API nk_bool nk_begin_titled(struct nk_context *ctx, const char *name, const char *title, struct nk_rect bounds, nk_flags flags);
1342
1357NK_API void nk_end(struct nk_context *ctx);
1358
1375NK_API struct nk_window *nk_window_find(const struct nk_context *ctx, const char *name);
1376
1394NK_API struct nk_rect nk_window_get_bounds(const struct nk_context *ctx);
1395
1413NK_API struct nk_vec2 nk_window_get_position(const struct nk_context *ctx);
1414
1432NK_API struct nk_vec2 nk_window_get_size(const struct nk_context *ctx);
1433
1450NK_API float nk_window_get_width(const struct nk_context *ctx);
1451
1469NK_API float nk_window_get_height(const struct nk_context* ctx);
1470
1490NK_API struct nk_panel* nk_window_get_panel(const struct nk_context* ctx);
1491
1512NK_API struct nk_rect nk_window_get_content_region(const struct nk_context* ctx);
1513
1534NK_API struct nk_vec2 nk_window_get_content_region_min(const struct nk_context *ctx);
1535
1556NK_API struct nk_vec2 nk_window_get_content_region_max(const struct nk_context *ctx);
1557
1577NK_API struct nk_vec2 nk_window_get_content_region_size(const struct nk_context *ctx);
1578
1598NK_API struct nk_command_buffer* nk_window_get_canvas(const struct nk_context* ctx);
1599
1617NK_API void nk_window_get_scroll(const struct nk_context *ctx, nk_uint *offset_x, nk_uint *offset_y);
1618
1635NK_API nk_bool nk_window_has_focus(const struct nk_context *ctx);
1636
1653NK_API nk_bool nk_window_is_hovered(const struct nk_context *ctx);
1654
1671NK_API nk_bool nk_window_is_collapsed(const struct nk_context *ctx, const char *name);
1672
1688NK_API nk_bool nk_window_is_closed(const struct nk_context *ctx, const char* name);
1689
1705NK_API nk_bool nk_window_is_hidden(const struct nk_context *ctx, const char* name);
1706
1721NK_API nk_bool nk_window_is_active(const struct nk_context *ctx, const char* name);
1722
1736NK_API nk_bool nk_window_is_any_hovered(const struct nk_context *ctx);
1737
1754NK_API nk_bool nk_item_is_any_active(const struct nk_context *ctx);
1755
1770NK_API void nk_window_set_bounds(struct nk_context *ctx, const char *name, struct nk_rect bounds);
1771
1786NK_API void nk_window_set_position(struct nk_context *ctx, const char *name, struct nk_vec2 pos);
1787
1802NK_API void nk_window_set_size(struct nk_context *ctx, const char *name, struct nk_vec2 size);
1803
1817NK_API void nk_window_set_focus(struct nk_context *ctx, const char *name);
1818
1836NK_API void nk_window_set_scroll(struct nk_context *ctx, nk_uint offset_x, nk_uint offset_y);
1837
1851NK_API void nk_window_close(struct nk_context *ctx, const char *name);
1852
1867NK_API void nk_window_collapse(struct nk_context *ctx, const char *name, enum nk_collapse_states state);
1868
1884NK_API void nk_window_collapse_if(struct nk_context *ctx, const char *name, enum nk_collapse_states state, int cond);
1885
1899NK_API void nk_window_show(struct nk_context *ctx, const char *name, enum nk_show_states state);
1900
1916NK_API void nk_window_show_if(struct nk_context *ctx, const char *name, enum nk_show_states state, int cond);
1917
1931NK_API void nk_rule_horizontal(struct nk_context *ctx, struct nk_color color, nk_bool rounding);
1932
1933/* =============================================================================
1934 *
1935 * LAYOUT
1936 *
1937 * =============================================================================*/
2206enum nk_widget_align {
2207 NK_WIDGET_ALIGN_LEFT = 0x01,
2208 NK_WIDGET_ALIGN_CENTERED = 0x02,
2209 NK_WIDGET_ALIGN_RIGHT = 0x04,
2210 NK_WIDGET_ALIGN_TOP = 0x08,
2211 NK_WIDGET_ALIGN_MIDDLE = 0x10,
2212 NK_WIDGET_ALIGN_BOTTOM = 0x20
2213};
2214enum nk_widget_alignment {
2215 NK_WIDGET_LEFT = NK_WIDGET_ALIGN_MIDDLE|NK_WIDGET_ALIGN_LEFT,
2216 NK_WIDGET_CENTERED = NK_WIDGET_ALIGN_MIDDLE|NK_WIDGET_ALIGN_CENTERED,
2217 NK_WIDGET_RIGHT = NK_WIDGET_ALIGN_MIDDLE|NK_WIDGET_ALIGN_RIGHT
2218};
2219
2233NK_API void nk_layout_set_min_row_height(struct nk_context*, float height);
2234
2243NK_API void nk_layout_reset_min_row_height(struct nk_context*);
2244
2257NK_API struct nk_rect nk_layout_widget_bounds(const struct nk_context *ctx);
2258
2272NK_API float nk_layout_ratio_from_pixel(const struct nk_context *ctx, float pixel_width);
2273
2288NK_API void nk_layout_row_dynamic(struct nk_context *ctx, float height, int cols);
2289
2305NK_API void nk_layout_row_static(struct nk_context *ctx, float height, int item_width, int cols);
2306
2320NK_API void nk_layout_row_begin(struct nk_context *ctx, enum nk_layout_format fmt, float row_height, int cols);
2321
2333NK_API void nk_layout_row_push(struct nk_context*, float value);
2334
2345NK_API void nk_layout_row_end(struct nk_context*);
2346
2360NK_API void nk_layout_row(struct nk_context*, enum nk_layout_format, float height, int cols, const float *ratio);
2361
2374NK_API void nk_layout_row_template_begin(struct nk_context*, float row_height);
2375
2389
2402NK_API void nk_layout_row_template_push_variable(struct nk_context*, float min_width);
2403
2416NK_API void nk_layout_row_template_push_static(struct nk_context*, float width);
2417
2429NK_API void nk_layout_row_template_end(struct nk_context*);
2430
2445NK_API void nk_layout_space_begin(struct nk_context*, enum nk_layout_format, float height, int widget_count);
2446
2459NK_API void nk_layout_space_push(struct nk_context*, struct nk_rect bounds);
2460
2472NK_API void nk_layout_space_end(struct nk_context*);
2473
2487NK_API struct nk_rect nk_layout_space_bounds(const struct nk_context *ctx);
2488
2503NK_API struct nk_vec2 nk_layout_space_to_screen(const struct nk_context* ctx, struct nk_vec2 vec);
2504
2519NK_API struct nk_vec2 nk_layout_space_to_local(const struct nk_context *ctx, struct nk_vec2 vec);
2520
2535NK_API struct nk_rect nk_layout_space_rect_to_screen(const struct nk_context *ctx, struct nk_rect bounds);
2536
2551NK_API struct nk_rect nk_layout_space_rect_to_local(const struct nk_context *ctx, struct nk_rect bounds);
2552
2565NK_API void nk_spacer(struct nk_context *ctx);
2566
2567
2672NK_API nk_bool nk_group_begin(struct nk_context*, const char *title, nk_flags);
2673
2687NK_API nk_bool nk_group_begin_titled(struct nk_context*, const char *name, const char *title, nk_flags);
2688
2700NK_API void nk_group_end(struct nk_context*);
2701
2720NK_API nk_bool nk_group_scrolled_offset_begin(struct nk_context*, nk_uint *x_offset, nk_uint *y_offset, const char *title, nk_flags flags);
2721
2739NK_API nk_bool nk_group_scrolled_begin(struct nk_context*, struct nk_scroll *off, const char *title, nk_flags);
2740
2752NK_API void nk_group_scrolled_end(struct nk_context*);
2753
2768NK_API void nk_group_get_scroll(struct nk_context*, const char *id, nk_uint *x_offset, nk_uint *y_offset);
2769
2784NK_API void nk_group_set_scroll(struct nk_context*, const char *id, nk_uint x_offset, nk_uint y_offset);
2785
2879#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__)
2880
2898#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)
2899
2920NK_API nk_bool nk_tree_push_hashed(struct nk_context*, enum nk_tree_type, const char *title, enum nk_collapse_states initial_state, const char *hash, int len,int seed);
2921
2944#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__)
2945
2966#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)
2967
2989NK_API nk_bool nk_tree_image_push_hashed(struct nk_context*, enum nk_tree_type, struct nk_image, const char *title, enum nk_collapse_states initial_state, const char *hash, int len,int seed);
2990
3002NK_API void nk_tree_pop(struct nk_context*);
3003
3020NK_API nk_bool nk_tree_state_push(struct nk_context*, enum nk_tree_type, const char *title, enum nk_collapse_states *state);
3021
3039NK_API nk_bool nk_tree_state_image_push(struct nk_context*, enum nk_tree_type, struct nk_image, const char *title, enum nk_collapse_states *state);
3040
3052NK_API void nk_tree_state_pop(struct nk_context*);
3053
3054#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__)
3055#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)
3056NK_API nk_bool nk_tree_element_push_hashed(struct nk_context*, enum nk_tree_type, const char *title, enum nk_collapse_states initial_state, nk_bool *selected, const char *hash, int len, int seed);
3057NK_API nk_bool nk_tree_element_image_push_hashed(struct nk_context*, enum nk_tree_type, struct nk_image, const char *title, enum nk_collapse_states initial_state, nk_bool *selected, const char *hash, int len,int seed);
3058NK_API void nk_tree_element_pop(struct nk_context*);
3059
3060/* =============================================================================
3061 *
3062 * LIST VIEW
3063 *
3064 * ============================================================================= */
3066/* public: */
3067 int begin, end, count;
3068/* private: */
3069 int total_height;
3070 struct nk_context *ctx;
3071 nk_uint *scroll_pointer;
3072 nk_uint scroll_value;
3073};
3074NK_API nk_bool nk_list_view_begin(struct nk_context*, struct nk_list_view *out, const char *id, nk_flags, int row_height, int row_count);
3075NK_API void nk_list_view_end(struct nk_list_view*);
3076/* =============================================================================
3077 *
3078 * WIDGET
3079 *
3080 * ============================================================================= */
3088 NK_WIDGET_STATE_MODIFIED = NK_FLAG(1),
3089 NK_WIDGET_STATE_INACTIVE = NK_FLAG(2),
3095 NK_WIDGET_STATE_ACTIVE = NK_WIDGET_STATE_ACTIVED|NK_WIDGET_STATE_MODIFIED
3097NK_API enum nk_widget_layout_states nk_widget(struct nk_rect*, const struct nk_context*);
3098NK_API enum nk_widget_layout_states nk_widget_fitting(struct nk_rect*, const struct nk_context*, struct nk_vec2);
3099NK_API struct nk_rect nk_widget_bounds(const struct nk_context*);
3100NK_API struct nk_vec2 nk_widget_position(const struct nk_context*);
3101NK_API struct nk_vec2 nk_widget_size(const struct nk_context*);
3102NK_API float nk_widget_width(const struct nk_context*);
3103NK_API float nk_widget_height(const struct nk_context*);
3104NK_API nk_bool nk_widget_is_hovered(const struct nk_context*);
3105NK_API nk_bool nk_widget_is_mouse_clicked(const struct nk_context*, enum nk_buttons);
3106NK_API nk_bool nk_widget_has_mouse_click_down(const struct nk_context*, enum nk_buttons, nk_bool down);
3107NK_API void nk_spacing(struct nk_context*, int cols);
3108NK_API void nk_widget_disable_begin(struct nk_context* ctx);
3109NK_API void nk_widget_disable_end(struct nk_context* ctx);
3110/* =============================================================================
3111 *
3112 * TEXT
3113 *
3114 * ============================================================================= */
3115enum nk_text_align {
3116 NK_TEXT_ALIGN_LEFT = 0x01,
3117 NK_TEXT_ALIGN_CENTERED = 0x02,
3118 NK_TEXT_ALIGN_RIGHT = 0x04,
3119 NK_TEXT_ALIGN_TOP = 0x08,
3120 NK_TEXT_ALIGN_MIDDLE = 0x10,
3121 NK_TEXT_ALIGN_BOTTOM = 0x20
3122};
3123enum nk_text_alignment {
3124 NK_TEXT_LEFT = NK_TEXT_ALIGN_MIDDLE|NK_TEXT_ALIGN_LEFT,
3125 NK_TEXT_CENTERED = NK_TEXT_ALIGN_MIDDLE|NK_TEXT_ALIGN_CENTERED,
3126 NK_TEXT_RIGHT = NK_TEXT_ALIGN_MIDDLE|NK_TEXT_ALIGN_RIGHT
3127};
3128NK_API void nk_text(struct nk_context*, const char*, int, nk_flags);
3129NK_API void nk_text_colored(struct nk_context*, const char*, int, nk_flags, struct nk_color);
3130NK_API void nk_text_wrap(struct nk_context*, const char*, int);
3131NK_API void nk_text_wrap_colored(struct nk_context*, const char*, int, struct nk_color);
3132NK_API void nk_label(struct nk_context*, const char*, nk_flags align);
3133NK_API void nk_label_colored(struct nk_context*, const char*, nk_flags align, struct nk_color);
3134NK_API void nk_label_wrap(struct nk_context*, const char*);
3135NK_API void nk_label_colored_wrap(struct nk_context*, const char*, struct nk_color);
3136NK_API void nk_image(struct nk_context*, struct nk_image);
3137NK_API void nk_image_color(struct nk_context*, struct nk_image, struct nk_color);
3138#ifdef NK_INCLUDE_STANDARD_VARARGS
3139NK_API void nk_labelf(struct nk_context*, nk_flags, NK_PRINTF_FORMAT_STRING const char*, ...) NK_PRINTF_VARARG_FUNC(3);
3140NK_API void nk_labelf_colored(struct nk_context*, nk_flags, struct nk_color, NK_PRINTF_FORMAT_STRING const char*,...) NK_PRINTF_VARARG_FUNC(4);
3141NK_API void nk_labelf_wrap(struct nk_context*, NK_PRINTF_FORMAT_STRING const char*,...) NK_PRINTF_VARARG_FUNC(2);
3142NK_API void nk_labelf_colored_wrap(struct nk_context*, struct nk_color, NK_PRINTF_FORMAT_STRING const char*,...) NK_PRINTF_VARARG_FUNC(3);
3143NK_API void nk_labelfv(struct nk_context*, nk_flags, NK_PRINTF_FORMAT_STRING const char*, va_list) NK_PRINTF_VALIST_FUNC(3);
3144NK_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);
3145NK_API void nk_labelfv_wrap(struct nk_context*, NK_PRINTF_FORMAT_STRING const char*, va_list) NK_PRINTF_VALIST_FUNC(2);
3146NK_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);
3147NK_API void nk_value_bool(struct nk_context*, const char *prefix, int);
3148NK_API void nk_value_int(struct nk_context*, const char *prefix, int);
3149NK_API void nk_value_uint(struct nk_context*, const char *prefix, unsigned int);
3150NK_API void nk_value_float(struct nk_context*, const char *prefix, float);
3151NK_API void nk_value_color_byte(struct nk_context*, const char *prefix, struct nk_color);
3152NK_API void nk_value_color_float(struct nk_context*, const char *prefix, struct nk_color);
3153NK_API void nk_value_color_hex(struct nk_context*, const char *prefix, struct nk_color);
3154#endif
3155/* =============================================================================
3156 *
3157 * BUTTON
3158 *
3159 * ============================================================================= */
3160NK_API nk_bool nk_button_text(struct nk_context*, const char *title, int len);
3161NK_API nk_bool nk_button_label(struct nk_context*, const char *title);
3162NK_API nk_bool nk_button_color(struct nk_context*, struct nk_color);
3163NK_API nk_bool nk_button_symbol(struct nk_context*, enum nk_symbol_type);
3164NK_API nk_bool nk_button_image(struct nk_context*, struct nk_image img);
3165NK_API nk_bool nk_button_symbol_label(struct nk_context*, enum nk_symbol_type, const char*, nk_flags text_alignment);
3166NK_API nk_bool nk_button_symbol_text(struct nk_context*, enum nk_symbol_type, const char*, int, nk_flags alignment);
3167NK_API nk_bool nk_button_image_label(struct nk_context*, struct nk_image img, const char*, nk_flags text_alignment);
3168NK_API nk_bool nk_button_image_text(struct nk_context*, struct nk_image img, const char*, int, nk_flags alignment);
3169NK_API nk_bool nk_button_text_styled(struct nk_context*, const struct nk_style_button*, const char *title, int len);
3170NK_API nk_bool nk_button_label_styled(struct nk_context*, const struct nk_style_button*, const char *title);
3171NK_API nk_bool nk_button_symbol_styled(struct nk_context*, const struct nk_style_button*, enum nk_symbol_type);
3172NK_API nk_bool nk_button_image_styled(struct nk_context*, const struct nk_style_button*, struct nk_image img);
3173NK_API nk_bool nk_button_symbol_text_styled(struct nk_context*,const struct nk_style_button*, enum nk_symbol_type, const char*, int, nk_flags alignment);
3174NK_API nk_bool nk_button_symbol_label_styled(struct nk_context *ctx, const struct nk_style_button *style, enum nk_symbol_type symbol, const char *title, nk_flags align);
3175NK_API nk_bool nk_button_image_label_styled(struct nk_context*,const struct nk_style_button*, struct nk_image img, const char*, nk_flags text_alignment);
3176NK_API nk_bool nk_button_image_text_styled(struct nk_context*,const struct nk_style_button*, struct nk_image img, const char*, int, nk_flags alignment);
3177NK_API void nk_button_set_behavior(struct nk_context*, enum nk_button_behavior);
3178NK_API nk_bool nk_button_push_behavior(struct nk_context*, enum nk_button_behavior);
3179NK_API nk_bool nk_button_pop_behavior(struct nk_context*);
3180/* =============================================================================
3181 *
3182 * CHECKBOX
3183 *
3184 * ============================================================================= */
3185NK_API nk_bool nk_check_label(struct nk_context*, const char*, nk_bool active);
3186NK_API nk_bool nk_check_text(struct nk_context*, const char*, int, nk_bool active);
3187NK_API nk_bool nk_check_text_align(struct nk_context*, const char*, int, nk_bool active, nk_flags widget_alignment, nk_flags text_alignment);
3188NK_API unsigned nk_check_flags_label(struct nk_context*, const char*, unsigned int flags, unsigned int value);
3189NK_API unsigned nk_check_flags_text(struct nk_context*, const char*, int, unsigned int flags, unsigned int value);
3190NK_API nk_bool nk_checkbox_label(struct nk_context*, const char*, nk_bool *active);
3191NK_API nk_bool nk_checkbox_label_align(struct nk_context *ctx, const char *label, nk_bool *active, nk_flags widget_alignment, nk_flags text_alignment);
3192NK_API nk_bool nk_checkbox_text(struct nk_context*, const char*, int, nk_bool *active);
3193NK_API nk_bool nk_checkbox_text_align(struct nk_context *ctx, const char *text, int len, nk_bool *active, nk_flags widget_alignment, nk_flags text_alignment);
3194NK_API nk_bool nk_checkbox_flags_label(struct nk_context*, const char*, unsigned int *flags, unsigned int value);
3195NK_API nk_bool nk_checkbox_flags_text(struct nk_context*, const char*, int, unsigned int *flags, unsigned int value);
3196/* =============================================================================
3197 *
3198 * RADIO BUTTON
3199 *
3200 * ============================================================================= */
3201NK_API nk_bool nk_radio_label(struct nk_context*, const char*, nk_bool *active);
3202NK_API nk_bool nk_radio_label_align(struct nk_context *ctx, const char *label, nk_bool *active, nk_flags widget_alignment, nk_flags text_alignment);
3203NK_API nk_bool nk_radio_text(struct nk_context*, const char*, int, nk_bool *active);
3204NK_API nk_bool nk_radio_text_align(struct nk_context *ctx, const char *text, int len, nk_bool *active, nk_flags widget_alignment, nk_flags text_alignment);
3205NK_API nk_bool nk_option_label(struct nk_context*, const char*, nk_bool active);
3206NK_API nk_bool nk_option_label_align(struct nk_context *ctx, const char *label, nk_bool active, nk_flags widget_alignment, nk_flags text_alignment);
3207NK_API nk_bool nk_option_text(struct nk_context*, const char*, int, nk_bool active);
3208NK_API nk_bool nk_option_text_align(struct nk_context *ctx, const char *text, int len, nk_bool is_active, nk_flags widget_alignment, nk_flags text_alignment);
3209/* =============================================================================
3210 *
3211 * SELECTABLE
3212 *
3213 * ============================================================================= */
3214NK_API nk_bool nk_selectable_label(struct nk_context*, const char*, nk_flags align, nk_bool *value);
3215NK_API nk_bool nk_selectable_text(struct nk_context*, const char*, int, nk_flags align, nk_bool *value);
3216NK_API nk_bool nk_selectable_image_label(struct nk_context*,struct nk_image, const char*, nk_flags align, nk_bool *value);
3217NK_API nk_bool nk_selectable_image_text(struct nk_context*,struct nk_image, const char*, int, nk_flags align, nk_bool *value);
3218NK_API nk_bool nk_selectable_symbol_label(struct nk_context*,enum nk_symbol_type, const char*, nk_flags align, nk_bool *value);
3219NK_API nk_bool nk_selectable_symbol_text(struct nk_context*,enum nk_symbol_type, const char*, int, nk_flags align, nk_bool *value);
3220
3221NK_API nk_bool nk_select_label(struct nk_context*, const char*, nk_flags align, nk_bool value);
3222NK_API nk_bool nk_select_text(struct nk_context*, const char*, int, nk_flags align, nk_bool value);
3223NK_API nk_bool nk_select_image_label(struct nk_context*, struct nk_image,const char*, nk_flags align, nk_bool value);
3224NK_API nk_bool nk_select_image_text(struct nk_context*, struct nk_image,const char*, int, nk_flags align, nk_bool value);
3225NK_API nk_bool nk_select_symbol_label(struct nk_context*,enum nk_symbol_type, const char*, nk_flags align, nk_bool value);
3226NK_API nk_bool nk_select_symbol_text(struct nk_context*,enum nk_symbol_type, const char*, int, nk_flags align, nk_bool value);
3227
3228/* =============================================================================
3229 *
3230 * SLIDER
3231 *
3232 * ============================================================================= */
3233NK_API float nk_slide_float(struct nk_context*, float min, float val, float max, float step);
3234NK_API int nk_slide_int(struct nk_context*, int min, int val, int max, int step);
3235NK_API nk_bool nk_slider_float(struct nk_context*, float min, float *val, float max, float step);
3236NK_API nk_bool nk_slider_int(struct nk_context*, int min, int *val, int max, int step);
3237
3238/* =============================================================================
3239 *
3240 * KNOB
3241 *
3242 * ============================================================================= */
3243NK_API nk_bool nk_knob_float(struct nk_context*, float min, float *val, float max, float step, enum nk_heading zero_direction, float dead_zone_degrees);
3244NK_API nk_bool nk_knob_int(struct nk_context*, int min, int *val, int max, int step, enum nk_heading zero_direction, float dead_zone_degrees);
3245
3246/* =============================================================================
3247 *
3248 * PROGRESSBAR
3249 *
3250 * ============================================================================= */
3251NK_API nk_bool nk_progress(struct nk_context*, nk_size *cur, nk_size max, nk_bool modifyable);
3252NK_API nk_size nk_prog(struct nk_context*, nk_size cur, nk_size max, nk_bool modifyable);
3253
3254/* =============================================================================
3255 *
3256 * COLOR PICKER
3257 *
3258 * ============================================================================= */
3259NK_API struct nk_colorf nk_color_picker(struct nk_context*, struct nk_colorf, enum nk_color_format);
3260NK_API nk_bool nk_color_pick(struct nk_context*, struct nk_colorf*, enum nk_color_format);
3261/* =============================================================================
3262 *
3263 * PROPERTIES
3264 *
3265 * =============================================================================*/
3358NK_API void nk_property_int(struct nk_context*, const char *name, int min, int *val, int max, int step, float inc_per_pixel);
3359
3381NK_API void nk_property_float(struct nk_context*, const char *name, float min, float *val, float max, float step, float inc_per_pixel);
3382
3404NK_API void nk_property_double(struct nk_context*, const char *name, double min, double *val, double max, double step, float inc_per_pixel);
3405
3427NK_API int nk_propertyi(struct nk_context*, const char *name, int min, int val, int max, int step, float inc_per_pixel);
3428
3450NK_API float nk_propertyf(struct nk_context*, const char *name, float min, float val, float max, float step, float inc_per_pixel);
3451
3473NK_API double nk_propertyd(struct nk_context*, const char *name, double min, double val, double max, double step, float inc_per_pixel);
3474
3475/* =============================================================================
3476 *
3477 * TEXT EDIT
3478 *
3479 * ============================================================================= */
3480enum nk_edit_flags {
3481 NK_EDIT_DEFAULT = 0,
3482 NK_EDIT_READ_ONLY = NK_FLAG(0),
3483 NK_EDIT_AUTO_SELECT = NK_FLAG(1),
3484 NK_EDIT_SIG_ENTER = NK_FLAG(2),
3485 NK_EDIT_ALLOW_TAB = NK_FLAG(3),
3486 NK_EDIT_NO_CURSOR = NK_FLAG(4),
3487 NK_EDIT_SELECTABLE = NK_FLAG(5),
3488 NK_EDIT_CLIPBOARD = NK_FLAG(6),
3489 NK_EDIT_CTRL_ENTER_NEWLINE = NK_FLAG(7),
3490 NK_EDIT_NO_HORIZONTAL_SCROLL = NK_FLAG(8),
3491 NK_EDIT_ALWAYS_INSERT_MODE = NK_FLAG(9),
3492 NK_EDIT_MULTILINE = NK_FLAG(10),
3493 NK_EDIT_GOTO_END_ON_ACTIVATE = NK_FLAG(11)
3494};
3495enum nk_edit_types {
3496 NK_EDIT_SIMPLE = NK_EDIT_ALWAYS_INSERT_MODE,
3497 NK_EDIT_FIELD = NK_EDIT_SIMPLE|NK_EDIT_SELECTABLE|NK_EDIT_CLIPBOARD,
3498 NK_EDIT_BOX = NK_EDIT_ALWAYS_INSERT_MODE| NK_EDIT_SELECTABLE| NK_EDIT_MULTILINE|NK_EDIT_ALLOW_TAB|NK_EDIT_CLIPBOARD,
3499 NK_EDIT_EDITOR = NK_EDIT_SELECTABLE|NK_EDIT_MULTILINE|NK_EDIT_ALLOW_TAB| NK_EDIT_CLIPBOARD
3500};
3502 NK_EDIT_ACTIVE = NK_FLAG(0),
3503 NK_EDIT_INACTIVE = NK_FLAG(1),
3504 NK_EDIT_ACTIVATED = NK_FLAG(2),
3505 NK_EDIT_DEACTIVATED = NK_FLAG(3),
3506 NK_EDIT_COMMITED = NK_FLAG(4)
3508NK_API nk_flags nk_edit_string(struct nk_context*, nk_flags, char *buffer, int *len, int max, nk_plugin_filter);
3509NK_API nk_flags nk_edit_string_zero_terminated(struct nk_context*, nk_flags, char *buffer, int max, nk_plugin_filter);
3510NK_API nk_flags nk_edit_buffer(struct nk_context*, nk_flags, struct nk_text_edit*, nk_plugin_filter);
3511NK_API void nk_edit_focus(struct nk_context*, nk_flags flags);
3512NK_API void nk_edit_unfocus(struct nk_context*);
3513/* =============================================================================
3514 *
3515 * CHART
3516 *
3517 * ============================================================================= */
3518NK_API nk_bool nk_chart_begin(struct nk_context*, enum nk_chart_type, int num, float min, float max);
3519NK_API nk_bool nk_chart_begin_colored(struct nk_context*, enum nk_chart_type, struct nk_color, struct nk_color active, int num, float min, float max);
3520NK_API void nk_chart_add_slot(struct nk_context *ctx, const enum nk_chart_type, int count, float min_value, float max_value);
3521NK_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);
3522NK_API nk_flags nk_chart_push(struct nk_context*, float);
3523NK_API nk_flags nk_chart_push_slot(struct nk_context*, float, int);
3524NK_API void nk_chart_end(struct nk_context*);
3525NK_API void nk_plot(struct nk_context*, enum nk_chart_type, const float *values, int count, int offset);
3526NK_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);
3527/* =============================================================================
3528 *
3529 * POPUP
3530 *
3531 * ============================================================================= */
3532NK_API nk_bool nk_popup_begin(struct nk_context*, enum nk_popup_type, const char*, nk_flags, struct nk_rect bounds);
3533NK_API void nk_popup_close(struct nk_context*);
3534NK_API void nk_popup_end(struct nk_context*);
3535NK_API void nk_popup_get_scroll(const struct nk_context*, nk_uint *offset_x, nk_uint *offset_y);
3536NK_API void nk_popup_set_scroll(struct nk_context*, nk_uint offset_x, nk_uint offset_y);
3537/* =============================================================================
3538 *
3539 * COMBOBOX
3540 *
3541 * ============================================================================= */
3542NK_API int nk_combo(struct nk_context*, const char *const *items, int count, int selected, int item_height, struct nk_vec2 size);
3543NK_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);
3544NK_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);
3545NK_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);
3546NK_API void nk_combobox(struct nk_context*, const char *const *items, int count, int *selected, int item_height, struct nk_vec2 size);
3547NK_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);
3548NK_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);
3549NK_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);
3550/* =============================================================================
3551 *
3552 * ABSTRACT COMBOBOX
3553 *
3554 * ============================================================================= */
3555NK_API nk_bool nk_combo_begin_text(struct nk_context*, const char *selected, int, struct nk_vec2 size);
3556NK_API nk_bool nk_combo_begin_label(struct nk_context*, const char *selected, struct nk_vec2 size);
3557NK_API nk_bool nk_combo_begin_color(struct nk_context*, struct nk_color color, struct nk_vec2 size);
3558NK_API nk_bool nk_combo_begin_symbol(struct nk_context*, enum nk_symbol_type, struct nk_vec2 size);
3559NK_API nk_bool nk_combo_begin_symbol_label(struct nk_context*, const char *selected, enum nk_symbol_type, struct nk_vec2 size);
3560NK_API nk_bool nk_combo_begin_symbol_text(struct nk_context*, const char *selected, int, enum nk_symbol_type, struct nk_vec2 size);
3561NK_API nk_bool nk_combo_begin_image(struct nk_context*, struct nk_image img, struct nk_vec2 size);
3562NK_API nk_bool nk_combo_begin_image_label(struct nk_context*, const char *selected, struct nk_image, struct nk_vec2 size);
3563NK_API nk_bool nk_combo_begin_image_text(struct nk_context*, const char *selected, int, struct nk_image, struct nk_vec2 size);
3564NK_API nk_bool nk_combo_item_label(struct nk_context*, const char*, nk_flags alignment);
3565NK_API nk_bool nk_combo_item_text(struct nk_context*, const char*,int, nk_flags alignment);
3566NK_API nk_bool nk_combo_item_image_label(struct nk_context*, struct nk_image, const char*, nk_flags alignment);
3567NK_API nk_bool nk_combo_item_image_text(struct nk_context*, struct nk_image, const char*, int,nk_flags alignment);
3568NK_API nk_bool nk_combo_item_symbol_label(struct nk_context*, enum nk_symbol_type, const char*, nk_flags alignment);
3569NK_API nk_bool nk_combo_item_symbol_text(struct nk_context*, enum nk_symbol_type, const char*, int, nk_flags alignment);
3570NK_API void nk_combo_close(struct nk_context*);
3571NK_API void nk_combo_end(struct nk_context*);
3572/* =============================================================================
3573 *
3574 * CONTEXTUAL
3575 *
3576 * ============================================================================= */
3577NK_API nk_bool nk_contextual_begin(struct nk_context*, nk_flags, struct nk_vec2, struct nk_rect trigger_bounds);
3578NK_API nk_bool nk_contextual_item_text(struct nk_context*, const char*, int,nk_flags align);
3579NK_API nk_bool nk_contextual_item_label(struct nk_context*, const char*, nk_flags align);
3580NK_API nk_bool nk_contextual_item_image_label(struct nk_context*, struct nk_image, const char*, nk_flags alignment);
3581NK_API nk_bool nk_contextual_item_image_text(struct nk_context*, struct nk_image, const char*, int len, nk_flags alignment);
3582NK_API nk_bool nk_contextual_item_symbol_label(struct nk_context*, enum nk_symbol_type, const char*, nk_flags alignment);
3583NK_API nk_bool nk_contextual_item_symbol_text(struct nk_context*, enum nk_symbol_type, const char*, int, nk_flags alignment);
3584NK_API void nk_contextual_close(struct nk_context*);
3585NK_API void nk_contextual_end(struct nk_context*);
3586/* =============================================================================
3587 *
3588 * TOOLTIP
3589 *
3590 * ============================================================================= */
3591NK_API void nk_tooltip(struct nk_context*, const char*);
3592#ifdef NK_INCLUDE_STANDARD_VARARGS
3593NK_API void nk_tooltipf(struct nk_context*, NK_PRINTF_FORMAT_STRING const char*, ...) NK_PRINTF_VARARG_FUNC(2);
3594NK_API void nk_tooltipfv(struct nk_context*, NK_PRINTF_FORMAT_STRING const char*, va_list) NK_PRINTF_VALIST_FUNC(2);
3595#endif
3596NK_API nk_bool nk_tooltip_begin(struct nk_context*, float width);
3597NK_API void nk_tooltip_end(struct nk_context*);
3598/* =============================================================================
3599 *
3600 * MENU
3601 *
3602 * ============================================================================= */
3603NK_API void nk_menubar_begin(struct nk_context*);
3604NK_API void nk_menubar_end(struct nk_context*);
3605NK_API nk_bool nk_menu_begin_text(struct nk_context*, const char* title, int title_len, nk_flags align, struct nk_vec2 size);
3606NK_API nk_bool nk_menu_begin_label(struct nk_context*, const char*, nk_flags align, struct nk_vec2 size);
3607NK_API nk_bool nk_menu_begin_image(struct nk_context*, const char*, struct nk_image, struct nk_vec2 size);
3608NK_API nk_bool nk_menu_begin_image_text(struct nk_context*, const char*, int,nk_flags align,struct nk_image, struct nk_vec2 size);
3609NK_API nk_bool nk_menu_begin_image_label(struct nk_context*, const char*, nk_flags align,struct nk_image, struct nk_vec2 size);
3610NK_API nk_bool nk_menu_begin_symbol(struct nk_context*, const char*, enum nk_symbol_type, struct nk_vec2 size);
3611NK_API nk_bool nk_menu_begin_symbol_text(struct nk_context*, const char*, int,nk_flags align,enum nk_symbol_type, struct nk_vec2 size);
3612NK_API nk_bool nk_menu_begin_symbol_label(struct nk_context*, const char*, nk_flags align,enum nk_symbol_type, struct nk_vec2 size);
3613NK_API nk_bool nk_menu_item_text(struct nk_context*, const char*, int,nk_flags align);
3614NK_API nk_bool nk_menu_item_label(struct nk_context*, const char*, nk_flags alignment);
3615NK_API nk_bool nk_menu_item_image_label(struct nk_context*, struct nk_image, const char*, nk_flags alignment);
3616NK_API nk_bool nk_menu_item_image_text(struct nk_context*, struct nk_image, const char*, int len, nk_flags alignment);
3617NK_API nk_bool nk_menu_item_symbol_text(struct nk_context*, enum nk_symbol_type, const char*, int, nk_flags alignment);
3618NK_API nk_bool nk_menu_item_symbol_label(struct nk_context*, enum nk_symbol_type, const char*, nk_flags alignment);
3619NK_API void nk_menu_close(struct nk_context*);
3620NK_API void nk_menu_end(struct nk_context*);
3621/* =============================================================================
3622 *
3623 * STYLE
3624 *
3625 * ============================================================================= */
3626
3627#define NK_WIDGET_DISABLED_FACTOR 0.5f
3628
3629enum nk_style_colors {
3630 NK_COLOR_TEXT,
3631 NK_COLOR_WINDOW,
3632 NK_COLOR_HEADER,
3633 NK_COLOR_BORDER,
3634 NK_COLOR_BUTTON,
3635 NK_COLOR_BUTTON_HOVER,
3636 NK_COLOR_BUTTON_ACTIVE,
3637 NK_COLOR_TOGGLE,
3638 NK_COLOR_TOGGLE_HOVER,
3639 NK_COLOR_TOGGLE_CURSOR,
3640 NK_COLOR_SELECT,
3641 NK_COLOR_SELECT_ACTIVE,
3642 NK_COLOR_SLIDER,
3643 NK_COLOR_SLIDER_CURSOR,
3644 NK_COLOR_SLIDER_CURSOR_HOVER,
3645 NK_COLOR_SLIDER_CURSOR_ACTIVE,
3646 NK_COLOR_PROPERTY,
3647 NK_COLOR_EDIT,
3648 NK_COLOR_EDIT_CURSOR,
3649 NK_COLOR_COMBO,
3650 NK_COLOR_CHART,
3651 NK_COLOR_CHART_COLOR,
3652 NK_COLOR_CHART_COLOR_HIGHLIGHT,
3653 NK_COLOR_SCROLLBAR,
3654 NK_COLOR_SCROLLBAR_CURSOR,
3655 NK_COLOR_SCROLLBAR_CURSOR_HOVER,
3656 NK_COLOR_SCROLLBAR_CURSOR_ACTIVE,
3657 NK_COLOR_TAB_HEADER,
3658 NK_COLOR_KNOB,
3659 NK_COLOR_KNOB_CURSOR,
3660 NK_COLOR_KNOB_CURSOR_HOVER,
3661 NK_COLOR_KNOB_CURSOR_ACTIVE,
3662 NK_COLOR_COUNT
3663};
3664enum nk_style_cursor {
3665 NK_CURSOR_ARROW,
3666 NK_CURSOR_TEXT,
3667 NK_CURSOR_MOVE,
3668 NK_CURSOR_RESIZE_VERTICAL,
3669 NK_CURSOR_RESIZE_HORIZONTAL,
3670 NK_CURSOR_RESIZE_TOP_LEFT_DOWN_RIGHT,
3671 NK_CURSOR_RESIZE_TOP_RIGHT_DOWN_LEFT,
3672 NK_CURSOR_COUNT
3673};
3674NK_API void nk_style_default(struct nk_context*);
3675NK_API void nk_style_from_table(struct nk_context*, const struct nk_color*);
3676NK_API void nk_style_load_cursor(struct nk_context*, enum nk_style_cursor, const struct nk_cursor*);
3677NK_API void nk_style_load_all_cursors(struct nk_context*, const struct nk_cursor*);
3678NK_API const char* nk_style_get_color_by_name(enum nk_style_colors);
3679NK_API void nk_style_set_font(struct nk_context*, const struct nk_user_font*);
3680NK_API nk_bool nk_style_set_cursor(struct nk_context*, enum nk_style_cursor);
3681NK_API void nk_style_show_cursor(struct nk_context*);
3682NK_API void nk_style_hide_cursor(struct nk_context*);
3683
3684NK_API nk_bool nk_style_push_font(struct nk_context*, const struct nk_user_font*);
3685NK_API nk_bool nk_style_push_float(struct nk_context*, float*, float);
3686NK_API nk_bool nk_style_push_vec2(struct nk_context*, struct nk_vec2*, struct nk_vec2);
3687NK_API nk_bool nk_style_push_style_item(struct nk_context*, struct nk_style_item*, struct nk_style_item);
3688NK_API nk_bool nk_style_push_flags(struct nk_context*, nk_flags*, nk_flags);
3689NK_API nk_bool nk_style_push_color(struct nk_context*, struct nk_color*, struct nk_color);
3690
3691NK_API nk_bool nk_style_pop_font(struct nk_context*);
3692NK_API nk_bool nk_style_pop_float(struct nk_context*);
3693NK_API nk_bool nk_style_pop_vec2(struct nk_context*);
3694NK_API nk_bool nk_style_pop_style_item(struct nk_context*);
3695NK_API nk_bool nk_style_pop_flags(struct nk_context*);
3696NK_API nk_bool nk_style_pop_color(struct nk_context*);
3697/* =============================================================================
3698 *
3699 * COLOR
3700 *
3701 * ============================================================================= */
3702NK_API struct nk_color nk_rgb(int r, int g, int b);
3703NK_API struct nk_color nk_rgb_iv(const int *rgb);
3704NK_API struct nk_color nk_rgb_bv(const nk_byte* rgb);
3705NK_API struct nk_color nk_rgb_f(float r, float g, float b);
3706NK_API struct nk_color nk_rgb_fv(const float *rgb);
3707NK_API struct nk_color nk_rgb_cf(struct nk_colorf c);
3708NK_API struct nk_color nk_rgb_hex(const char *rgb);
3709NK_API struct nk_color nk_rgb_factor(struct nk_color col, float factor);
3710
3711NK_API struct nk_color nk_rgba(int r, int g, int b, int a);
3712NK_API struct nk_color nk_rgba_u32(nk_uint);
3713NK_API struct nk_color nk_rgba_iv(const int *rgba);
3714NK_API struct nk_color nk_rgba_bv(const nk_byte *rgba);
3715NK_API struct nk_color nk_rgba_f(float r, float g, float b, float a);
3716NK_API struct nk_color nk_rgba_fv(const float *rgba);
3717NK_API struct nk_color nk_rgba_cf(struct nk_colorf c);
3718NK_API struct nk_color nk_rgba_hex(const char *rgb);
3719
3720NK_API struct nk_colorf nk_hsva_colorf(float h, float s, float v, float a);
3721NK_API struct nk_colorf nk_hsva_colorfv(const float *c);
3722NK_API void nk_colorf_hsva_f(float *out_h, float *out_s, float *out_v, float *out_a, struct nk_colorf in);
3723NK_API void nk_colorf_hsva_fv(float *hsva, struct nk_colorf in);
3724
3725NK_API struct nk_color nk_hsv(int h, int s, int v);
3726NK_API struct nk_color nk_hsv_iv(const int *hsv);
3727NK_API struct nk_color nk_hsv_bv(const nk_byte *hsv);
3728NK_API struct nk_color nk_hsv_f(float h, float s, float v);
3729NK_API struct nk_color nk_hsv_fv(const float *hsv);
3730
3731NK_API struct nk_color nk_hsva(int h, int s, int v, int a);
3732NK_API struct nk_color nk_hsva_iv(const int *hsva);
3733NK_API struct nk_color nk_hsva_bv(const nk_byte *hsva);
3734NK_API struct nk_color nk_hsva_f(float h, float s, float v, float a);
3735NK_API struct nk_color nk_hsva_fv(const float *hsva);
3736
3737/* color (conversion nuklear --> user) */
3738NK_API void nk_color_f(float *r, float *g, float *b, float *a, struct nk_color);
3739NK_API void nk_color_fv(float *rgba_out, struct nk_color);
3740NK_API struct nk_colorf nk_color_cf(struct nk_color);
3741NK_API void nk_color_d(double *r, double *g, double *b, double *a, struct nk_color);
3742NK_API void nk_color_dv(double *rgba_out, struct nk_color);
3743
3744NK_API nk_uint nk_color_u32(struct nk_color);
3745NK_API void nk_color_hex_rgba(char *output, struct nk_color);
3746NK_API void nk_color_hex_rgb(char *output, struct nk_color);
3747
3748NK_API void nk_color_hsv_i(int *out_h, int *out_s, int *out_v, struct nk_color);
3749NK_API void nk_color_hsv_b(nk_byte *out_h, nk_byte *out_s, nk_byte *out_v, struct nk_color);
3750NK_API void nk_color_hsv_iv(int *hsv_out, struct nk_color);
3751NK_API void nk_color_hsv_bv(nk_byte *hsv_out, struct nk_color);
3752NK_API void nk_color_hsv_f(float *out_h, float *out_s, float *out_v, struct nk_color);
3753NK_API void nk_color_hsv_fv(float *hsv_out, struct nk_color);
3754
3755NK_API void nk_color_hsva_i(int *h, int *s, int *v, int *a, struct nk_color);
3756NK_API void nk_color_hsva_b(nk_byte *h, nk_byte *s, nk_byte *v, nk_byte *a, struct nk_color);
3757NK_API void nk_color_hsva_iv(int *hsva_out, struct nk_color);
3758NK_API void nk_color_hsva_bv(nk_byte *hsva_out, struct nk_color);
3759NK_API void nk_color_hsva_f(float *out_h, float *out_s, float *out_v, float *out_a, struct nk_color);
3760NK_API void nk_color_hsva_fv(float *hsva_out, struct nk_color);
3761/* =============================================================================
3762 *
3763 * IMAGE
3764 *
3765 * ============================================================================= */
3766NK_API nk_handle nk_handle_ptr(void*);
3767NK_API nk_handle nk_handle_id(int);
3768NK_API struct nk_image nk_image_handle(nk_handle);
3769NK_API struct nk_image nk_image_ptr(void*);
3770NK_API struct nk_image nk_image_id(int);
3771NK_API nk_bool nk_image_is_subimage(const struct nk_image* img);
3772NK_API struct nk_image nk_subimage_ptr(void*, nk_ushort w, nk_ushort h, struct nk_rect sub_region);
3773NK_API struct nk_image nk_subimage_id(int, nk_ushort w, nk_ushort h, struct nk_rect sub_region);
3774NK_API struct nk_image nk_subimage_handle(nk_handle, nk_ushort w, nk_ushort h, struct nk_rect sub_region);
3775/* =============================================================================
3776 *
3777 * 9-SLICE
3778 *
3779 * ============================================================================= */
3780NK_API struct nk_nine_slice nk_nine_slice_handle(nk_handle, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b);
3781NK_API struct nk_nine_slice nk_nine_slice_ptr(void*, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b);
3782NK_API struct nk_nine_slice nk_nine_slice_id(int, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b);
3783NK_API int nk_nine_slice_is_sub9slice(const struct nk_nine_slice* img);
3784NK_API struct nk_nine_slice nk_sub9slice_ptr(void*, nk_ushort w, nk_ushort h, struct nk_rect sub_region, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b);
3785NK_API struct nk_nine_slice nk_sub9slice_id(int, nk_ushort w, nk_ushort h, struct nk_rect sub_region, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b);
3786NK_API struct nk_nine_slice nk_sub9slice_handle(nk_handle, nk_ushort w, nk_ushort h, struct nk_rect sub_region, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b);
3787/* =============================================================================
3788 *
3789 * MATH
3790 *
3791 * ============================================================================= */
3792NK_API nk_hash nk_murmur_hash(const void *key, int len, nk_hash seed);
3793NK_API void nk_triangle_from_direction(struct nk_vec2 *result, struct nk_rect r, float pad_x, float pad_y, enum nk_heading);
3794
3795NK_API struct nk_vec2 nk_vec2(float x, float y);
3796NK_API struct nk_vec2 nk_vec2i(int x, int y);
3797NK_API struct nk_vec2 nk_vec2v(const float *xy);
3798NK_API struct nk_vec2 nk_vec2iv(const int *xy);
3799
3800NK_API struct nk_rect nk_get_null_rect(void);
3801NK_API struct nk_rect nk_rect(float x, float y, float w, float h);
3802NK_API struct nk_rect nk_recti(int x, int y, int w, int h);
3803NK_API struct nk_rect nk_recta(struct nk_vec2 pos, struct nk_vec2 size);
3804NK_API struct nk_rect nk_rectv(const float *xywh);
3805NK_API struct nk_rect nk_rectiv(const int *xywh);
3806NK_API struct nk_vec2 nk_rect_pos(struct nk_rect);
3807NK_API struct nk_vec2 nk_rect_size(struct nk_rect);
3808/* =============================================================================
3809 *
3810 * STRING
3811 *
3812 * ============================================================================= */
3813NK_API int nk_strlen(const char *str);
3814NK_API int nk_stricmp(const char *s1, const char *s2);
3815NK_API int nk_stricmpn(const char *s1, const char *s2, int n);
3816NK_API int nk_strtoi(const char *str, char **endptr);
3817NK_API float nk_strtof(const char *str, char **endptr);
3818#ifndef NK_STRTOD
3819#define NK_STRTOD nk_strtod
3820NK_API double nk_strtod(const char *str, char **endptr);
3821#endif
3822NK_API int nk_strfilter(const char *text, const char *regexp);
3823NK_API int nk_strmatch_fuzzy_string(char const *str, char const *pattern, int *out_score);
3824NK_API int nk_strmatch_fuzzy_text(const char *txt, int txt_len, const char *pattern, int *out_score);
3825/* =============================================================================
3826 *
3827 * UTF-8
3828 *
3829 * ============================================================================= */
3830NK_API int nk_utf_decode(const char*, nk_rune*, int);
3831NK_API int nk_utf_encode(nk_rune, char*, int);
3832NK_API int nk_utf_len(const char*, int byte_len);
3833NK_API const char* nk_utf_at(const char *buffer, int length, int index, nk_rune *unicode, int *len);
3834/* ===============================================================
3835 *
3836 * FONT
3837 *
3838 * ===============================================================*/
3991struct nk_user_font_glyph;
3992typedef float(*nk_text_width_f)(nk_handle, float h, const char*, int len);
3993typedef void(*nk_query_font_glyph_f)(nk_handle handle, float font_height,
3994 struct nk_user_font_glyph *glyph,
3995 nk_rune codepoint, nk_rune next_codepoint);
3996
3997#if defined(NK_INCLUDE_VERTEX_BUFFER_OUTPUT) || defined(NK_INCLUDE_SOFTWARE_FONT)
3998struct nk_user_font_glyph {
3999 struct nk_vec2 uv[2];
4000 struct nk_vec2 offset;
4001 float width, height;
4002 float xadvance;
4003};
4004#endif
4005
4007 nk_handle userdata;
4008 float height;
4009 nk_text_width_f width;
4010#ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
4011 nk_query_font_glyph_f query;
4012 nk_handle texture;
4013#endif
4014};
4015
4016#ifdef NK_INCLUDE_FONT_BAKING
4017enum nk_font_coord_type {
4018 NK_COORD_UV,
4019 NK_COORD_PIXEL
4020};
4021
4022struct nk_font;
4023struct nk_baked_font {
4024 float height;
4025 float ascent;
4026 float descent;
4027 nk_rune glyph_offset;
4028 nk_rune glyph_count;
4029 const nk_rune *ranges;
4030};
4031
4032struct nk_font_config {
4033 struct nk_font_config *next;
4034 void *ttf_blob;
4035 nk_size ttf_size;
4037 unsigned char ttf_data_owned_by_atlas;
4038 unsigned char merge_mode;
4039 unsigned char pixel_snap;
4040 unsigned char oversample_v, oversample_h;
4041 unsigned char padding[3];
4042
4043 float size;
4044 enum nk_font_coord_type coord_type;
4045 struct nk_vec2 spacing;
4046 const nk_rune *range;
4047 struct nk_baked_font *font;
4048 nk_rune fallback_glyph;
4049 struct nk_font_config *n;
4050 struct nk_font_config *p;
4051};
4052
4053struct nk_font_glyph {
4054 nk_rune codepoint;
4055 float xadvance;
4056 float x0, y0, x1, y1, w, h;
4057 float u0, v0, u1, v1;
4058};
4059
4060struct nk_font {
4061 struct nk_font *next;
4062 struct nk_user_font handle;
4063 struct nk_baked_font info;
4064 float scale;
4065 struct nk_font_glyph *glyphs;
4066 const struct nk_font_glyph *fallback;
4067 nk_rune fallback_codepoint;
4068 nk_handle texture;
4069 struct nk_font_config *config;
4070};
4071
4072enum nk_font_atlas_format {
4073 NK_FONT_ATLAS_ALPHA8,
4074 NK_FONT_ATLAS_RGBA32
4075};
4076
4077struct nk_font_atlas {
4078 void *pixel;
4079 int tex_width;
4080 int tex_height;
4081
4082 struct nk_allocator permanent;
4083 struct nk_allocator temporary;
4084
4085 struct nk_recti custom;
4086 struct nk_cursor cursors[NK_CURSOR_COUNT];
4087
4088 int glyph_count;
4089 struct nk_font_glyph *glyphs;
4090 struct nk_font *default_font;
4091 struct nk_font *fonts;
4092 struct nk_font_config *config;
4093 int font_num;
4094};
4095
4097NK_API const nk_rune *nk_font_default_glyph_ranges(void);
4098NK_API const nk_rune *nk_font_chinese_glyph_ranges(void);
4099NK_API const nk_rune *nk_font_cyrillic_glyph_ranges(void);
4100NK_API const nk_rune *nk_font_korean_glyph_ranges(void);
4101
4102#ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
4103NK_API void nk_font_atlas_init_default(struct nk_font_atlas*);
4104#endif
4105NK_API void nk_font_atlas_init(struct nk_font_atlas*, const struct nk_allocator*);
4106NK_API void nk_font_atlas_init_custom(struct nk_font_atlas*, const struct nk_allocator *persistent, const struct nk_allocator *transient);
4107NK_API void nk_font_atlas_begin(struct nk_font_atlas*);
4108NK_API struct nk_font_config nk_font_config(float pixel_height);
4109NK_API struct nk_font *nk_font_atlas_add(struct nk_font_atlas*, const struct nk_font_config*);
4110#ifdef NK_INCLUDE_DEFAULT_FONT
4111NK_API struct nk_font* nk_font_atlas_add_default(struct nk_font_atlas*, float height, const struct nk_font_config*);
4112#endif
4113NK_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);
4114#ifdef NK_INCLUDE_STANDARD_IO
4115NK_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*);
4116#endif
4117NK_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*);
4118NK_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);
4119NK_API const void* nk_font_atlas_bake(struct nk_font_atlas*, int *width, int *height, enum nk_font_atlas_format);
4120NK_API void nk_font_atlas_end(struct nk_font_atlas*, nk_handle tex, struct nk_draw_null_texture*);
4121NK_API const struct nk_font_glyph* nk_font_find_glyph(const struct nk_font*, nk_rune unicode);
4122NK_API void nk_font_atlas_cleanup(struct nk_font_atlas *atlas);
4123NK_API void nk_font_atlas_clear(struct nk_font_atlas*);
4124
4125#endif
4126
4164 void *memory;
4165 unsigned int type;
4166 nk_size size;
4167 nk_size allocated;
4168 nk_size needed;
4169 nk_size calls;
4170};
4171
4172enum nk_allocation_type {
4173 NK_BUFFER_FIXED,
4174 NK_BUFFER_DYNAMIC
4175};
4176
4177enum nk_buffer_allocation_type {
4178 NK_BUFFER_FRONT,
4179 NK_BUFFER_BACK,
4180 NK_BUFFER_MAX
4181};
4182
4184 nk_bool active;
4185 nk_size offset;
4186};
4187
4188struct nk_memory {void *ptr;nk_size size;};
4190 struct nk_buffer_marker marker[NK_BUFFER_MAX];
4192 enum nk_allocation_type type;
4195 nk_size allocated;
4196 nk_size needed;
4197 nk_size calls;
4198 nk_size size;
4199};
4200
4201#ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
4202NK_API void nk_buffer_init_default(struct nk_buffer*);
4203#endif
4204NK_API void nk_buffer_init(struct nk_buffer*, const struct nk_allocator*, nk_size size);
4205NK_API void nk_buffer_init_fixed(struct nk_buffer*, void *memory, nk_size size);
4206NK_API void nk_buffer_info(struct nk_memory_status*, const struct nk_buffer*);
4207NK_API void nk_buffer_push(struct nk_buffer*, enum nk_buffer_allocation_type type, const void *memory, nk_size size, nk_size align);
4208NK_API void nk_buffer_mark(struct nk_buffer*, enum nk_buffer_allocation_type type);
4209NK_API void nk_buffer_reset(struct nk_buffer*, enum nk_buffer_allocation_type type);
4210NK_API void nk_buffer_clear(struct nk_buffer*);
4211NK_API void nk_buffer_free(struct nk_buffer*);
4212NK_API void *nk_buffer_memory(struct nk_buffer*);
4213NK_API const void *nk_buffer_memory_const(const struct nk_buffer*);
4214NK_API nk_size nk_buffer_total(const struct nk_buffer*);
4215
4226struct nk_str {
4227 struct nk_buffer buffer;
4228 int len;
4229};
4230
4231#ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
4232NK_API void nk_str_init_default(struct nk_str*);
4233#endif
4234NK_API void nk_str_init(struct nk_str*, const struct nk_allocator*, nk_size size);
4235NK_API void nk_str_init_fixed(struct nk_str*, void *memory, nk_size size);
4236NK_API void nk_str_clear(struct nk_str*);
4237NK_API void nk_str_free(struct nk_str*);
4238
4239NK_API int nk_str_append_text_char(struct nk_str*, const char*, int);
4240NK_API int nk_str_append_str_char(struct nk_str*, const char*);
4241NK_API int nk_str_append_text_utf8(struct nk_str*, const char*, int);
4242NK_API int nk_str_append_str_utf8(struct nk_str*, const char*);
4243NK_API int nk_str_append_text_runes(struct nk_str*, const nk_rune*, int);
4244NK_API int nk_str_append_str_runes(struct nk_str*, const nk_rune*);
4245
4246NK_API int nk_str_insert_at_char(struct nk_str*, int pos, const char*, int);
4247NK_API int nk_str_insert_at_rune(struct nk_str*, int pos, const char*, int);
4248
4249NK_API int nk_str_insert_text_char(struct nk_str*, int pos, const char*, int);
4250NK_API int nk_str_insert_str_char(struct nk_str*, int pos, const char*);
4251NK_API int nk_str_insert_text_utf8(struct nk_str*, int pos, const char*, int);
4252NK_API int nk_str_insert_str_utf8(struct nk_str*, int pos, const char*);
4253NK_API int nk_str_insert_text_runes(struct nk_str*, int pos, const nk_rune*, int);
4254NK_API int nk_str_insert_str_runes(struct nk_str*, int pos, const nk_rune*);
4255
4256NK_API void nk_str_remove_chars(struct nk_str*, int len);
4257NK_API void nk_str_remove_runes(struct nk_str *str, int len);
4258NK_API void nk_str_delete_chars(struct nk_str*, int pos, int len);
4259NK_API void nk_str_delete_runes(struct nk_str*, int pos, int len);
4260
4261NK_API char *nk_str_at_char(struct nk_str*, int pos);
4262NK_API char *nk_str_at_rune(struct nk_str*, int pos, nk_rune *unicode, int *len);
4263NK_API nk_rune nk_str_rune_at(const struct nk_str*, int pos);
4264NK_API const char *nk_str_at_char_const(const struct nk_str*, int pos);
4265NK_API const char *nk_str_at_const(const struct nk_str*, int pos, nk_rune *unicode, int *len);
4266
4267NK_API char *nk_str_get(struct nk_str*);
4268NK_API const char *nk_str_get_const(const struct nk_str*);
4269NK_API int nk_str_len(const struct nk_str*);
4270NK_API int nk_str_len_char(const struct nk_str*);
4271
4303#ifndef NK_TEXTEDIT_UNDOSTATECOUNT
4304#define NK_TEXTEDIT_UNDOSTATECOUNT 99
4305#endif
4306
4307#ifndef NK_TEXTEDIT_UNDOCHARCOUNT
4308#define NK_TEXTEDIT_UNDOCHARCOUNT 999
4309#endif
4310
4311struct nk_text_edit;
4313 nk_handle userdata;
4314 nk_plugin_paste paste;
4315 nk_plugin_copy copy;
4316};
4317
4319 int where;
4320 short insert_length;
4321 short delete_length;
4322 short char_storage;
4323};
4324
4326 struct nk_text_undo_record undo_rec[NK_TEXTEDIT_UNDOSTATECOUNT];
4327 nk_rune undo_char[NK_TEXTEDIT_UNDOCHARCOUNT];
4328 short undo_point;
4329 short redo_point;
4330 short undo_char_point;
4331 short redo_char_point;
4332};
4333
4334enum nk_text_edit_type {
4335 NK_TEXT_EDIT_SINGLE_LINE,
4336 NK_TEXT_EDIT_MULTI_LINE
4337};
4338
4339enum nk_text_edit_mode {
4340 NK_TEXT_EDIT_MODE_VIEW,
4341 NK_TEXT_EDIT_MODE_INSERT,
4342 NK_TEXT_EDIT_MODE_REPLACE
4343};
4344
4346 struct nk_clipboard clip;
4347 struct nk_str string;
4348 nk_plugin_filter filter;
4349 struct nk_vec2 scrollbar;
4350
4351 int cursor;
4352 int select_start;
4353 int select_end;
4354 unsigned char mode;
4355 unsigned char cursor_at_end_of_line;
4356 unsigned char initialized;
4357 unsigned char has_preferred_x;
4358 unsigned char single_line;
4359 unsigned char active;
4360 unsigned char padding1;
4361 float preferred_x;
4362 struct nk_text_undo_state undo;
4363};
4364
4366NK_API nk_bool nk_filter_default(const struct nk_text_edit*, nk_rune unicode);
4367NK_API nk_bool nk_filter_ascii(const struct nk_text_edit*, nk_rune unicode);
4368NK_API nk_bool nk_filter_float(const struct nk_text_edit*, nk_rune unicode);
4369NK_API nk_bool nk_filter_decimal(const struct nk_text_edit*, nk_rune unicode);
4370NK_API nk_bool nk_filter_hex(const struct nk_text_edit*, nk_rune unicode);
4371NK_API nk_bool nk_filter_oct(const struct nk_text_edit*, nk_rune unicode);
4372NK_API nk_bool nk_filter_binary(const struct nk_text_edit*, nk_rune unicode);
4373
4375#ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
4376NK_API void nk_textedit_init_default(struct nk_text_edit*);
4377#endif
4378NK_API void nk_textedit_init(struct nk_text_edit*, const struct nk_allocator*, nk_size size);
4379NK_API void nk_textedit_init_fixed(struct nk_text_edit*, void *memory, nk_size size);
4380NK_API void nk_textedit_free(struct nk_text_edit*);
4381NK_API void nk_textedit_text(struct nk_text_edit*, const char*, int total_len);
4382NK_API void nk_textedit_delete(struct nk_text_edit*, int where, int len);
4383NK_API void nk_textedit_delete_selection(struct nk_text_edit*);
4384NK_API void nk_textedit_select_all(struct nk_text_edit*);
4385NK_API nk_bool nk_textedit_cut(struct nk_text_edit*);
4386NK_API nk_bool nk_textedit_paste(struct nk_text_edit*, char const*, int len);
4387NK_API void nk_textedit_undo(struct nk_text_edit*);
4388NK_API void nk_textedit_redo(struct nk_text_edit*);
4389
4390/* ===============================================================
4391 *
4392 * DRAWING
4393 *
4394 * ===============================================================*/
4444enum nk_command_type {
4445 NK_COMMAND_NOP,
4446 NK_COMMAND_SCISSOR,
4447 NK_COMMAND_LINE,
4448 NK_COMMAND_CURVE,
4449 NK_COMMAND_RECT,
4450 NK_COMMAND_RECT_FILLED,
4451 NK_COMMAND_RECT_MULTI_COLOR,
4452 NK_COMMAND_CIRCLE,
4453 NK_COMMAND_CIRCLE_FILLED,
4454 NK_COMMAND_ARC,
4455 NK_COMMAND_ARC_FILLED,
4456 NK_COMMAND_TRIANGLE,
4457 NK_COMMAND_TRIANGLE_FILLED,
4458 NK_COMMAND_POLYGON,
4459 NK_COMMAND_POLYGON_FILLED,
4460 NK_COMMAND_POLYLINE,
4461 NK_COMMAND_TEXT,
4462 NK_COMMAND_IMAGE,
4463 NK_COMMAND_CUSTOM
4464};
4465
4468 enum nk_command_type type;
4469 nk_size next;
4470#ifdef NK_INCLUDE_COMMAND_USERDATA
4471 nk_handle userdata;
4472#endif
4473};
4474
4476 struct nk_command header;
4477 short x, y;
4478 unsigned short w, h;
4479};
4480
4482 struct nk_command header;
4483 unsigned short line_thickness;
4484 struct nk_vec2i begin;
4485 struct nk_vec2i end;
4486 struct nk_color color;
4487};
4488
4490 struct nk_command header;
4491 unsigned short line_thickness;
4492 struct nk_vec2i begin;
4493 struct nk_vec2i end;
4494 struct nk_vec2i ctrl[2];
4495 struct nk_color color;
4496};
4497
4499 struct nk_command header;
4500 unsigned short rounding;
4501 unsigned short line_thickness;
4502 short x, y;
4503 unsigned short w, h;
4504 struct nk_color color;
4505};
4506
4508 struct nk_command header;
4509 unsigned short rounding;
4510 short x, y;
4511 unsigned short w, h;
4512 struct nk_color color;
4513};
4514
4516 struct nk_command header;
4517 short x, y;
4518 unsigned short w, h;
4519 struct nk_color left;
4520 struct nk_color top;
4521 struct nk_color bottom;
4522 struct nk_color right;
4523};
4524
4526 struct nk_command header;
4527 unsigned short line_thickness;
4528 struct nk_vec2i a;
4529 struct nk_vec2i b;
4530 struct nk_vec2i c;
4531 struct nk_color color;
4532};
4533
4535 struct nk_command header;
4536 struct nk_vec2i a;
4537 struct nk_vec2i b;
4538 struct nk_vec2i c;
4539 struct nk_color color;
4540};
4541
4543 struct nk_command header;
4544 short x, y;
4545 unsigned short line_thickness;
4546 unsigned short w, h;
4547 struct nk_color color;
4548};
4549
4551 struct nk_command header;
4552 short x, y;
4553 unsigned short w, h;
4554 struct nk_color color;
4555};
4556
4558 struct nk_command header;
4559 short cx, cy;
4560 unsigned short r;
4561 unsigned short line_thickness;
4562 float a[2];
4563 struct nk_color color;
4564};
4565
4567 struct nk_command header;
4568 short cx, cy;
4569 unsigned short r;
4570 float a[2];
4571 struct nk_color color;
4572};
4573
4575 struct nk_command header;
4576 struct nk_color color;
4577 unsigned short line_thickness;
4578 unsigned short point_count;
4579 struct nk_vec2i points[1];
4580};
4581
4583 struct nk_command header;
4584 struct nk_color color;
4585 unsigned short point_count;
4586 struct nk_vec2i points[1];
4587};
4588
4590 struct nk_command header;
4591 struct nk_color color;
4592 unsigned short line_thickness;
4593 unsigned short point_count;
4594 struct nk_vec2i points[1];
4595};
4596
4598 struct nk_command header;
4599 short x, y;
4600 unsigned short w, h;
4601 struct nk_image img;
4602 struct nk_color col;
4603};
4604
4605typedef void (*nk_command_custom_callback)(void *canvas, short x,short y,
4606 unsigned short w, unsigned short h, nk_handle callback_data);
4608 struct nk_command header;
4609 short x, y;
4610 unsigned short w, h;
4611 nk_handle callback_data;
4612 nk_command_custom_callback callback;
4613};
4614
4616 struct nk_command header;
4617 const struct nk_user_font *font;
4618 struct nk_color background;
4619 struct nk_color foreground;
4620 short x, y;
4621 unsigned short w, h;
4622 float height;
4623 int length;
4624 char string[2];
4625};
4626
4627enum nk_command_clipping {
4628 NK_CLIPPING_OFF = nk_false,
4629 NK_CLIPPING_ON = nk_true
4630};
4631
4633 struct nk_buffer *base;
4634 struct nk_rect clip;
4635 int use_clipping;
4636 nk_handle userdata;
4637 nk_size begin, end, last;
4638};
4639
4641NK_API void nk_stroke_line(struct nk_command_buffer *b, float x0, float y0, float x1, float y1, float line_thickness, struct nk_color);
4642NK_API void nk_stroke_curve(struct nk_command_buffer*, float, float, float, float, float, float, float, float, float line_thickness, struct nk_color);
4643NK_API void nk_stroke_rect(struct nk_command_buffer*, struct nk_rect, float rounding, float line_thickness, struct nk_color);
4644NK_API void nk_stroke_circle(struct nk_command_buffer*, struct nk_rect, float line_thickness, struct nk_color);
4645NK_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);
4646NK_API void nk_stroke_triangle(struct nk_command_buffer*, float, float, float, float, float, float, float line_thichness, struct nk_color);
4647NK_API void nk_stroke_polyline(struct nk_command_buffer*, const float *points, int point_count, float line_thickness, struct nk_color col);
4648NK_API void nk_stroke_polygon(struct nk_command_buffer*, const float *points, int point_count, float line_thickness, struct nk_color);
4649
4651NK_API void nk_fill_rect(struct nk_command_buffer*, struct nk_rect, float rounding, struct nk_color);
4652NK_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);
4653NK_API void nk_fill_circle(struct nk_command_buffer*, struct nk_rect, struct nk_color);
4654NK_API void nk_fill_arc(struct nk_command_buffer*, float cx, float cy, float radius, float a_min, float a_max, struct nk_color);
4655NK_API void nk_fill_triangle(struct nk_command_buffer*, float x0, float y0, float x1, float y1, float x2, float y2, struct nk_color);
4656NK_API void nk_fill_polygon(struct nk_command_buffer*, const float *points, int point_count, struct nk_color);
4657
4659NK_API void nk_draw_image(struct nk_command_buffer*, struct nk_rect, const struct nk_image*, struct nk_color);
4660NK_API void nk_draw_nine_slice(struct nk_command_buffer*, struct nk_rect, const struct nk_nine_slice*, struct nk_color);
4661NK_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);
4662NK_API void nk_push_scissor(struct nk_command_buffer*, struct nk_rect);
4663NK_API void nk_push_custom(struct nk_command_buffer*, struct nk_rect, nk_command_custom_callback, nk_handle usr);
4664
4665/* ===============================================================
4666 *
4667 * INPUT
4668 *
4669 * ===============================================================*/
4671 nk_bool down;
4672 unsigned int clicked;
4673 struct nk_vec2 clicked_pos;
4674};
4675struct nk_mouse {
4676 struct nk_mouse_button buttons[NK_BUTTON_MAX];
4677 struct nk_vec2 pos;
4678#ifdef NK_BUTTON_TRIGGER_ON_RELEASE
4679 struct nk_vec2 down_pos;
4680#endif
4681 struct nk_vec2 prev;
4682 struct nk_vec2 delta;
4683 struct nk_vec2 scroll_delta;
4684 unsigned char grab;
4685 unsigned char grabbed;
4686 unsigned char ungrab;
4687};
4688
4689struct nk_key {
4690 nk_bool down;
4691 unsigned int clicked;
4692};
4694 struct nk_key keys[NK_KEY_MAX];
4695 char text[NK_INPUT_MAX];
4696 int text_len;
4697};
4698
4699struct nk_input {
4700 struct nk_keyboard keyboard;
4701 struct nk_mouse mouse;
4702};
4703
4704NK_API nk_bool nk_input_has_mouse_click(const struct nk_input*, enum nk_buttons);
4705NK_API nk_bool nk_input_has_mouse_click_in_rect(const struct nk_input*, enum nk_buttons, struct nk_rect);
4706NK_API nk_bool nk_input_has_mouse_click_in_button_rect(const struct nk_input*, enum nk_buttons, struct nk_rect);
4707NK_API nk_bool nk_input_has_mouse_click_down_in_rect(const struct nk_input*, enum nk_buttons, struct nk_rect, nk_bool down);
4708NK_API nk_bool nk_input_is_mouse_click_in_rect(const struct nk_input*, enum nk_buttons, struct nk_rect);
4709NK_API nk_bool nk_input_is_mouse_click_down_in_rect(const struct nk_input *i, enum nk_buttons id, struct nk_rect b, nk_bool down);
4710NK_API nk_bool nk_input_any_mouse_click_in_rect(const struct nk_input*, struct nk_rect);
4711NK_API nk_bool nk_input_is_mouse_prev_hovering_rect(const struct nk_input*, struct nk_rect);
4712NK_API nk_bool nk_input_is_mouse_hovering_rect(const struct nk_input*, struct nk_rect);
4713NK_API nk_bool nk_input_mouse_clicked(const struct nk_input*, enum nk_buttons, struct nk_rect);
4714NK_API nk_bool nk_input_is_mouse_down(const struct nk_input*, enum nk_buttons);
4715NK_API nk_bool nk_input_is_mouse_pressed(const struct nk_input*, enum nk_buttons);
4716NK_API nk_bool nk_input_is_mouse_released(const struct nk_input*, enum nk_buttons);
4717NK_API nk_bool nk_input_is_key_pressed(const struct nk_input*, enum nk_keys);
4718NK_API nk_bool nk_input_is_key_released(const struct nk_input*, enum nk_keys);
4719NK_API nk_bool nk_input_is_key_down(const struct nk_input*, enum nk_keys);
4720
4721/* ===============================================================
4722 *
4723 * DRAW LIST
4724 *
4725 * ===============================================================*/
4726#ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
4743#ifdef NK_UINT_DRAW_INDEX
4744typedef nk_uint nk_draw_index;
4745#else
4746typedef nk_ushort nk_draw_index;
4747#endif
4748enum nk_draw_list_stroke {
4749 NK_STROKE_OPEN = nk_false, /***< build up path has no connection back to the beginning */
4750 NK_STROKE_CLOSED = nk_true /***< build up path has a connection back to the beginning */
4751};
4752
4753enum nk_draw_vertex_layout_attribute {
4754 NK_VERTEX_POSITION,
4755 NK_VERTEX_COLOR,
4756 NK_VERTEX_TEXCOORD,
4757 NK_VERTEX_ATTRIBUTE_COUNT
4758};
4759
4760enum nk_draw_vertex_layout_format {
4761 NK_FORMAT_SCHAR,
4762 NK_FORMAT_SSHORT,
4763 NK_FORMAT_SINT,
4764 NK_FORMAT_UCHAR,
4765 NK_FORMAT_USHORT,
4766 NK_FORMAT_UINT,
4767 NK_FORMAT_FLOAT,
4768 NK_FORMAT_DOUBLE,
4769
4770NK_FORMAT_COLOR_BEGIN,
4771 NK_FORMAT_R8G8B8 = NK_FORMAT_COLOR_BEGIN,
4772 NK_FORMAT_R16G15B16,
4773 NK_FORMAT_R32G32B32,
4774
4775 NK_FORMAT_R8G8B8A8,
4776 NK_FORMAT_B8G8R8A8,
4777 NK_FORMAT_R16G15B16A16,
4778 NK_FORMAT_R32G32B32A32,
4779 NK_FORMAT_R32G32B32A32_FLOAT,
4780 NK_FORMAT_R32G32B32A32_DOUBLE,
4781
4782 NK_FORMAT_RGB32,
4783 NK_FORMAT_RGBA32,
4784NK_FORMAT_COLOR_END = NK_FORMAT_RGBA32,
4785 NK_FORMAT_COUNT
4786};
4787
4788#define NK_VERTEX_LAYOUT_END NK_VERTEX_ATTRIBUTE_COUNT,NK_FORMAT_COUNT,0
4789struct nk_draw_vertex_layout_element {
4790 enum nk_draw_vertex_layout_attribute attribute;
4791 enum nk_draw_vertex_layout_format format;
4792 nk_size offset;
4793};
4794
4795struct nk_draw_command {
4796 unsigned int elem_count;
4797 struct nk_rect clip_rect;
4798 nk_handle texture;
4799#ifdef NK_INCLUDE_COMMAND_USERDATA
4800 nk_handle userdata;
4801#endif
4802};
4803
4804struct nk_draw_list {
4805 struct nk_rect clip_rect;
4806 struct nk_vec2 circle_vtx[12];
4807 struct nk_convert_config config;
4808
4809 struct nk_buffer *buffer;
4810 struct nk_buffer *vertices;
4811 struct nk_buffer *elements;
4812
4813 unsigned int element_count;
4814 unsigned int vertex_count;
4815 unsigned int cmd_count;
4816 nk_size cmd_offset;
4817
4818 unsigned int path_count;
4819 unsigned int path_offset;
4820
4821 enum nk_anti_aliasing line_AA;
4822 enum nk_anti_aliasing shape_AA;
4823
4824#ifdef NK_INCLUDE_COMMAND_USERDATA
4825 nk_handle userdata;
4826#endif
4827};
4828
4829/* draw list */
4830NK_API void nk_draw_list_init(struct nk_draw_list*);
4831NK_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);
4832
4833/* drawing */
4834#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))
4835NK_API const struct nk_draw_command* nk__draw_list_begin(const struct nk_draw_list*, const struct nk_buffer*);
4836NK_API const struct nk_draw_command* nk__draw_list_next(const struct nk_draw_command*, const struct nk_buffer*, const struct nk_draw_list*);
4837NK_API const struct nk_draw_command* nk__draw_list_end(const struct nk_draw_list*, const struct nk_buffer*);
4838
4839/* path */
4840NK_API void nk_draw_list_path_clear(struct nk_draw_list*);
4841NK_API void nk_draw_list_path_line_to(struct nk_draw_list*, struct nk_vec2 pos);
4842NK_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);
4843NK_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);
4844NK_API void nk_draw_list_path_rect_to(struct nk_draw_list*, struct nk_vec2 a, struct nk_vec2 b, float rounding);
4845NK_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);
4846NK_API void nk_draw_list_path_fill(struct nk_draw_list*, struct nk_color);
4847NK_API void nk_draw_list_path_stroke(struct nk_draw_list*, struct nk_color, enum nk_draw_list_stroke closed, float thickness);
4848
4849/* stroke */
4850NK_API void nk_draw_list_stroke_line(struct nk_draw_list*, struct nk_vec2 a, struct nk_vec2 b, struct nk_color, float thickness);
4851NK_API void nk_draw_list_stroke_rect(struct nk_draw_list*, struct nk_rect rect, struct nk_color, float rounding, float thickness);
4852NK_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);
4853NK_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);
4854NK_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);
4855NK_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);
4856
4857/* fill */
4858NK_API void nk_draw_list_fill_rect(struct nk_draw_list*, struct nk_rect rect, struct nk_color, float rounding);
4859NK_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);
4860NK_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);
4861NK_API void nk_draw_list_fill_circle(struct nk_draw_list*, struct nk_vec2 center, float radius, struct nk_color col, unsigned int segs);
4862NK_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);
4863
4864/* misc */
4865NK_API void nk_draw_list_add_image(struct nk_draw_list*, struct nk_image texture, struct nk_rect rect, struct nk_color);
4866NK_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);
4867#ifdef NK_INCLUDE_COMMAND_USERDATA
4868NK_API void nk_draw_list_push_userdata(struct nk_draw_list*, nk_handle userdata);
4869#endif
4870
4871#endif
4872
4873/* ===============================================================
4874 *
4875 * GUI
4876 *
4877 * ===============================================================*/
4878enum nk_style_item_type {
4879 NK_STYLE_ITEM_COLOR,
4880 NK_STYLE_ITEM_IMAGE,
4881 NK_STYLE_ITEM_NINE_SLICE
4882};
4883
4885 struct nk_color color;
4886 struct nk_image image;
4887 struct nk_nine_slice slice;
4888};
4889
4891 enum nk_style_item_type type;
4892 union nk_style_item_data data;
4893};
4894
4896 struct nk_color color;
4897 struct nk_vec2 padding;
4898 float color_factor;
4899 float disabled_factor;
4900};
4901
4903 /* background */
4904 struct nk_style_item normal;
4905 struct nk_style_item hover;
4906 struct nk_style_item active;
4907 struct nk_color border_color;
4908 float color_factor_background;
4909
4910 /* text */
4911 struct nk_color text_background;
4912 struct nk_color text_normal;
4913 struct nk_color text_hover;
4914 struct nk_color text_active;
4915 nk_flags text_alignment;
4916 float color_factor_text;
4917
4918 /* properties */
4919 float border;
4920 float rounding;
4921 struct nk_vec2 padding;
4922 struct nk_vec2 image_padding;
4923 struct nk_vec2 touch_padding;
4924 float disabled_factor;
4925
4926 /* optional user callbacks */
4927 nk_handle userdata;
4928 void(*draw_begin)(struct nk_command_buffer*, nk_handle userdata);
4929 void(*draw_end)(struct nk_command_buffer*, nk_handle userdata);
4930};
4931
4933 /* background */
4934 struct nk_style_item normal;
4935 struct nk_style_item hover;
4936 struct nk_style_item active;
4937 struct nk_color border_color;
4938
4939 /* cursor */
4940 struct nk_style_item cursor_normal;
4941 struct nk_style_item cursor_hover;
4942
4943 /* text */
4944 struct nk_color text_normal;
4945 struct nk_color text_hover;
4946 struct nk_color text_active;
4947 struct nk_color text_background;
4948 nk_flags text_alignment;
4949
4950 /* properties */
4951 struct nk_vec2 padding;
4952 struct nk_vec2 touch_padding;
4953 float spacing;
4954 float border;
4955 float color_factor;
4956 float disabled_factor;
4957
4958 /* optional user callbacks */
4959 nk_handle userdata;
4960 void(*draw_begin)(struct nk_command_buffer*, nk_handle);
4961 void(*draw_end)(struct nk_command_buffer*, nk_handle);
4962};
4963
4965 /* background (inactive) */
4966 struct nk_style_item normal;
4967 struct nk_style_item hover;
4968 struct nk_style_item pressed;
4969
4970 /* background (active) */
4971 struct nk_style_item normal_active;
4972 struct nk_style_item hover_active;
4973 struct nk_style_item pressed_active;
4974
4975 /* text color (inactive) */
4976 struct nk_color text_normal;
4977 struct nk_color text_hover;
4978 struct nk_color text_pressed;
4979
4980 /* text color (active) */
4981 struct nk_color text_normal_active;
4982 struct nk_color text_hover_active;
4983 struct nk_color text_pressed_active;
4984 struct nk_color text_background;
4985 nk_flags text_alignment;
4986
4987 /* properties */
4988 float rounding;
4989 struct nk_vec2 padding;
4990 struct nk_vec2 touch_padding;
4991 struct nk_vec2 image_padding;
4992 float color_factor;
4993 float disabled_factor;
4994
4995 /* optional user callbacks */
4996 nk_handle userdata;
4997 void(*draw_begin)(struct nk_command_buffer*, nk_handle);
4998 void(*draw_end)(struct nk_command_buffer*, nk_handle);
4999};
5000
5002 /* background */
5003 struct nk_style_item normal;
5004 struct nk_style_item hover;
5005 struct nk_style_item active;
5006 struct nk_color border_color;
5007
5008 /* background bar */
5009 struct nk_color bar_normal;
5010 struct nk_color bar_hover;
5011 struct nk_color bar_active;
5012 struct nk_color bar_filled;
5013
5014 /* cursor */
5015 struct nk_style_item cursor_normal;
5016 struct nk_style_item cursor_hover;
5017 struct nk_style_item cursor_active;
5018
5019 /* properties */
5020 float border;
5021 float rounding;
5022 float bar_height;
5023 struct nk_vec2 padding;
5024 struct nk_vec2 spacing;
5025 struct nk_vec2 cursor_size;
5026 float color_factor;
5027 float disabled_factor;
5028
5029 /* optional buttons */
5030 int show_buttons;
5031 struct nk_style_button inc_button;
5032 struct nk_style_button dec_button;
5033 enum nk_symbol_type inc_symbol;
5034 enum nk_symbol_type dec_symbol;
5035
5036 /* optional user callbacks */
5037 nk_handle userdata;
5038 void(*draw_begin)(struct nk_command_buffer*, nk_handle);
5039 void(*draw_end)(struct nk_command_buffer*, nk_handle);
5040};
5041
5043 /* background */
5044 struct nk_style_item normal;
5045 struct nk_style_item hover;
5046 struct nk_style_item active;
5047 struct nk_color border_color;
5048
5049 /* knob */
5050 struct nk_color knob_normal;
5051 struct nk_color knob_hover;
5052 struct nk_color knob_active;
5053 struct nk_color knob_border_color;
5054
5055 /* cursor */
5056 struct nk_color cursor_normal;
5057 struct nk_color cursor_hover;
5058 struct nk_color cursor_active;
5059
5060 /* properties */
5061 float border;
5062 float knob_border;
5063 struct nk_vec2 padding;
5064 struct nk_vec2 spacing;
5065 float cursor_width;
5066 float color_factor;
5067 float disabled_factor;
5068
5069 /* optional user callbacks */
5070 nk_handle userdata;
5071 void(*draw_begin)(struct nk_command_buffer*, nk_handle);
5072 void(*draw_end)(struct nk_command_buffer*, nk_handle);
5073};
5074
5076 /* background */
5077 struct nk_style_item normal;
5078 struct nk_style_item hover;
5079 struct nk_style_item active;
5080 struct nk_color border_color;
5081
5082 /* cursor */
5083 struct nk_style_item cursor_normal;
5084 struct nk_style_item cursor_hover;
5085 struct nk_style_item cursor_active;
5086 struct nk_color cursor_border_color;
5087
5088 /* properties */
5089 float rounding;
5090 float border;
5091 float cursor_border;
5092 float cursor_rounding;
5093 struct nk_vec2 padding;
5094 float color_factor;
5095 float disabled_factor;
5096
5097 /* optional user callbacks */
5098 nk_handle userdata;
5099 void(*draw_begin)(struct nk_command_buffer*, nk_handle);
5100 void(*draw_end)(struct nk_command_buffer*, nk_handle);
5101};
5102
5104 /* background */
5105 struct nk_style_item normal;
5106 struct nk_style_item hover;
5107 struct nk_style_item active;
5108 struct nk_color border_color;
5109
5110 /* cursor */
5111 struct nk_style_item cursor_normal;
5112 struct nk_style_item cursor_hover;
5113 struct nk_style_item cursor_active;
5114 struct nk_color cursor_border_color;
5115
5116 /* properties */
5117 float border;
5118 float rounding;
5119 float border_cursor;
5120 float rounding_cursor;
5121 struct nk_vec2 padding;
5122 float color_factor;
5123 float disabled_factor;
5124
5125 /* optional buttons */
5126 int show_buttons;
5127 struct nk_style_button inc_button;
5128 struct nk_style_button dec_button;
5129 enum nk_symbol_type inc_symbol;
5130 enum nk_symbol_type dec_symbol;
5131
5132 /* optional user callbacks */
5133 nk_handle userdata;
5134 void(*draw_begin)(struct nk_command_buffer*, nk_handle);
5135 void(*draw_end)(struct nk_command_buffer*, nk_handle);
5136};
5137
5139 /* background */
5140 struct nk_style_item normal;
5141 struct nk_style_item hover;
5142 struct nk_style_item active;
5143 struct nk_color border_color;
5144 struct nk_style_scrollbar scrollbar;
5145
5146 /* cursor */
5147 struct nk_color cursor_normal;
5148 struct nk_color cursor_hover;
5149 struct nk_color cursor_text_normal;
5150 struct nk_color cursor_text_hover;
5151
5152 /* text (unselected) */
5153 struct nk_color text_normal;
5154 struct nk_color text_hover;
5155 struct nk_color text_active;
5156
5157 /* text (selected) */
5158 struct nk_color selected_normal;
5159 struct nk_color selected_hover;
5160 struct nk_color selected_text_normal;
5161 struct nk_color selected_text_hover;
5162
5163 /* properties */
5164 float border;
5165 float rounding;
5166 float cursor_size;
5167 struct nk_vec2 scrollbar_size;
5168 struct nk_vec2 padding;
5169 float row_padding;
5170 float color_factor;
5171 float disabled_factor;
5172};
5173
5175 /* background */
5176 struct nk_style_item normal;
5177 struct nk_style_item hover;
5178 struct nk_style_item active;
5179 struct nk_color border_color;
5180
5181 /* text */
5182 struct nk_color label_normal;
5183 struct nk_color label_hover;
5184 struct nk_color label_active;
5185
5186 /* symbols */
5187 enum nk_symbol_type sym_left;
5188 enum nk_symbol_type sym_right;
5189
5190 /* properties */
5191 float border;
5192 float rounding;
5193 struct nk_vec2 padding;
5194 float color_factor;
5195 float disabled_factor;
5196
5197 struct nk_style_edit edit;
5198 struct nk_style_button inc_button;
5199 struct nk_style_button dec_button;
5200
5201 /* optional user callbacks */
5202 nk_handle userdata;
5203 void(*draw_begin)(struct nk_command_buffer*, nk_handle);
5204 void(*draw_end)(struct nk_command_buffer*, nk_handle);
5205};
5206
5208 /* colors */
5209 struct nk_style_item background;
5210 struct nk_color border_color;
5211 struct nk_color selected_color;
5212 struct nk_color color;
5213
5214 /* properties */
5215 float border;
5216 float rounding;
5217 struct nk_vec2 padding;
5218 float color_factor;
5219 float disabled_factor;
5220 nk_bool show_markers;
5221};
5222
5224 /* background */
5225 struct nk_style_item normal;
5226 struct nk_style_item hover;
5227 struct nk_style_item active;
5228 struct nk_color border_color;
5229
5230 /* label */
5231 struct nk_color label_normal;
5232 struct nk_color label_hover;
5233 struct nk_color label_active;
5234
5235 /* symbol */
5236 struct nk_color symbol_normal;
5237 struct nk_color symbol_hover;
5238 struct nk_color symbol_active;
5239
5240 /* button */
5241 struct nk_style_button button;
5242 enum nk_symbol_type sym_normal;
5243 enum nk_symbol_type sym_hover;
5244 enum nk_symbol_type sym_active;
5245
5246 /* properties */
5247 float border;
5248 float rounding;
5249 struct nk_vec2 content_padding;
5250 struct nk_vec2 button_padding;
5251 struct nk_vec2 spacing;
5252 float color_factor;
5253 float disabled_factor;
5254};
5255
5257 /* background */
5258 struct nk_style_item background;
5259 struct nk_color border_color;
5260 struct nk_color text;
5261
5262 /* button */
5263 struct nk_style_button tab_maximize_button;
5264 struct nk_style_button tab_minimize_button;
5265 struct nk_style_button node_maximize_button;
5266 struct nk_style_button node_minimize_button;
5267 enum nk_symbol_type sym_minimize;
5268 enum nk_symbol_type sym_maximize;
5269
5270 /* properties */
5271 float border;
5272 float rounding;
5273 float indent;
5274 struct nk_vec2 padding;
5275 struct nk_vec2 spacing;
5276 float color_factor;
5277 float disabled_factor;
5278};
5279
5280enum nk_style_header_align {
5281 NK_HEADER_LEFT,
5282 NK_HEADER_RIGHT
5283};
5285 /* background */
5286 struct nk_style_item normal;
5287 struct nk_style_item hover;
5288 struct nk_style_item active;
5289
5290 /* button */
5291 struct nk_style_button close_button;
5292 struct nk_style_button minimize_button;
5293 enum nk_symbol_type close_symbol;
5294 enum nk_symbol_type minimize_symbol;
5295 enum nk_symbol_type maximize_symbol;
5296
5297 /* title */
5298 struct nk_color label_normal;
5299 struct nk_color label_hover;
5300 struct nk_color label_active;
5301
5302 /* properties */
5303 enum nk_style_header_align align;
5304 struct nk_vec2 padding;
5305 struct nk_vec2 label_padding;
5306 struct nk_vec2 spacing;
5307};
5308
5310 struct nk_style_window_header header;
5311 struct nk_style_item fixed_background;
5312 struct nk_color background;
5313
5314 struct nk_color border_color;
5315 struct nk_color popup_border_color;
5316 struct nk_color combo_border_color;
5317 struct nk_color contextual_border_color;
5318 struct nk_color menu_border_color;
5319 struct nk_color group_border_color;
5320 struct nk_color tooltip_border_color;
5321 struct nk_style_item scaler;
5322
5323 float border;
5324 float combo_border;
5325 float contextual_border;
5326 float menu_border;
5327 float group_border;
5328 float tooltip_border;
5329 float popup_border;
5330 float min_row_height_padding;
5331
5332 float rounding;
5333 struct nk_vec2 spacing;
5334 struct nk_vec2 scrollbar_size;
5335 struct nk_vec2 min_size;
5336
5337 struct nk_vec2 padding;
5338 struct nk_vec2 group_padding;
5339 struct nk_vec2 popup_padding;
5340 struct nk_vec2 combo_padding;
5341 struct nk_vec2 contextual_padding;
5342 struct nk_vec2 menu_padding;
5343 struct nk_vec2 tooltip_padding;
5344};
5345
5346struct nk_style {
5347 const struct nk_user_font *font;
5348 const struct nk_cursor *cursors[NK_CURSOR_COUNT];
5349 const struct nk_cursor *cursor_active;
5350 struct nk_cursor *cursor_last;
5351 int cursor_visible;
5352
5353 struct nk_style_text text;
5354 struct nk_style_button button;
5355 struct nk_style_button contextual_button;
5356 struct nk_style_button menu_button;
5357 struct nk_style_toggle option;
5358 struct nk_style_toggle checkbox;
5359 struct nk_style_selectable selectable;
5360 struct nk_style_slider slider;
5361 struct nk_style_knob knob;
5362 struct nk_style_progress progress;
5363 struct nk_style_property property;
5364 struct nk_style_edit edit;
5365 struct nk_style_chart chart;
5366 struct nk_style_scrollbar scrollh;
5367 struct nk_style_scrollbar scrollv;
5368 struct nk_style_tab tab;
5369 struct nk_style_combo combo;
5370 struct nk_style_window window;
5371};
5372
5373NK_API struct nk_style_item nk_style_item_color(struct nk_color);
5374NK_API struct nk_style_item nk_style_item_image(struct nk_image img);
5375NK_API struct nk_style_item nk_style_item_nine_slice(struct nk_nine_slice slice);
5376NK_API struct nk_style_item nk_style_item_hide(void);
5377
5378/*==============================================================
5379 * PANEL
5380 * =============================================================*/
5381#ifndef NK_MAX_LAYOUT_ROW_TEMPLATE_COLUMNS
5382#define NK_MAX_LAYOUT_ROW_TEMPLATE_COLUMNS 16
5383#endif
5384#ifndef NK_CHART_MAX_SLOT
5385#define NK_CHART_MAX_SLOT 4
5386#endif
5387
5388enum nk_panel_type {
5389 NK_PANEL_NONE = 0,
5390 NK_PANEL_WINDOW = NK_FLAG(0),
5391 NK_PANEL_GROUP = NK_FLAG(1),
5392 NK_PANEL_POPUP = NK_FLAG(2),
5393 NK_PANEL_CONTEXTUAL = NK_FLAG(4),
5394 NK_PANEL_COMBO = NK_FLAG(5),
5395 NK_PANEL_MENU = NK_FLAG(6),
5396 NK_PANEL_TOOLTIP = NK_FLAG(7)
5397};
5398enum nk_panel_set {
5399 NK_PANEL_SET_NONBLOCK = NK_PANEL_CONTEXTUAL|NK_PANEL_COMBO|NK_PANEL_MENU|NK_PANEL_TOOLTIP,
5400 NK_PANEL_SET_POPUP = NK_PANEL_SET_NONBLOCK|NK_PANEL_POPUP,
5401 NK_PANEL_SET_SUB = NK_PANEL_SET_POPUP|NK_PANEL_GROUP
5402};
5403
5405 enum nk_chart_type type;
5406 struct nk_color color;
5407 struct nk_color highlight;
5408 float min, max, range;
5409 int count;
5410 struct nk_vec2 last;
5411 int index;
5412 nk_bool show_markers;
5413};
5414
5415struct nk_chart {
5416 int slot;
5417 float x, y, w, h;
5418 struct nk_chart_slot slots[NK_CHART_MAX_SLOT];
5419};
5420
5421enum nk_panel_row_layout_type {
5422 NK_LAYOUT_DYNAMIC_FIXED = 0,
5423 NK_LAYOUT_DYNAMIC_ROW,
5424 NK_LAYOUT_DYNAMIC_FREE,
5425 NK_LAYOUT_DYNAMIC,
5426 NK_LAYOUT_STATIC_FIXED,
5427 NK_LAYOUT_STATIC_ROW,
5428 NK_LAYOUT_STATIC_FREE,
5429 NK_LAYOUT_STATIC,
5430 NK_LAYOUT_TEMPLATE,
5431 NK_LAYOUT_COUNT
5432};
5434 enum nk_panel_row_layout_type type;
5435 int index;
5436 float height;
5437 float min_height;
5438 int columns;
5439 const float *ratio;
5440 float item_width;
5441 float item_height;
5442 float item_offset;
5443 float filled;
5444 struct nk_rect item;
5445 int tree_depth;
5446 float templates[NK_MAX_LAYOUT_ROW_TEMPLATE_COLUMNS];
5447};
5448
5450 nk_size begin;
5451 nk_size parent;
5452 nk_size last;
5453 nk_size end;
5454 nk_bool active;
5455};
5456
5458 float x, y, w, h;
5459 struct nk_scroll offset;
5460};
5461
5462struct nk_panel {
5463 enum nk_panel_type type;
5464 nk_flags flags;
5465 struct nk_rect bounds;
5466 nk_uint *offset_x;
5467 nk_uint *offset_y;
5468 float at_x, at_y, max_x;
5469 float footer_height;
5470 float header_height;
5471 float border;
5472 unsigned int has_scrolling;
5473 struct nk_rect clip;
5474 struct nk_menu_state menu;
5475 struct nk_row_layout row;
5476 struct nk_chart chart;
5477 struct nk_command_buffer *buffer;
5478 struct nk_panel *parent;
5479};
5480
5481/*==============================================================
5482 * WINDOW
5483 * =============================================================*/
5484#ifndef NK_WINDOW_MAX_NAME
5485#define NK_WINDOW_MAX_NAME 64
5486#endif
5487
5488struct nk_table;
5490 NK_WINDOW_PRIVATE = NK_FLAG(11),
5491 NK_WINDOW_DYNAMIC = NK_WINDOW_PRIVATE,
5492 NK_WINDOW_ROM = NK_FLAG(12),
5494 NK_WINDOW_HIDDEN = NK_FLAG(13),
5495 NK_WINDOW_CLOSED = NK_FLAG(14),
5496 NK_WINDOW_MINIMIZED = NK_FLAG(15),
5497 NK_WINDOW_REMOVE_ROM = NK_FLAG(16)
5499
5501 struct nk_window *win;
5502 enum nk_panel_type type;
5503 struct nk_popup_buffer buf;
5504 nk_hash name;
5505 nk_bool active;
5506 unsigned combo_count;
5507 unsigned con_count, con_old;
5508 unsigned active_con;
5509 struct nk_rect header;
5510};
5511
5513 nk_hash name;
5514 unsigned int seq;
5515 unsigned int old;
5516 int active, prev;
5517 int cursor;
5518 int sel_start;
5519 int sel_end;
5520 struct nk_scroll scrollbar;
5521 unsigned char mode;
5522 unsigned char single_line;
5523};
5524
5526 int active, prev;
5527 char buffer[NK_MAX_NUMBER_BUFFER];
5528 int length;
5529 int cursor;
5530 int select_start;
5531 int select_end;
5532 nk_hash name;
5533 unsigned int seq;
5534 unsigned int old;
5535 int state;
5536};
5537
5539 unsigned int seq;
5540 nk_hash name;
5541 char name_string[NK_WINDOW_MAX_NAME];
5542 nk_flags flags;
5543
5544 struct nk_rect bounds;
5545 struct nk_scroll scrollbar;
5546 struct nk_command_buffer buffer;
5547 struct nk_panel *layout;
5548 float scrollbar_hiding_timer;
5549
5550 /* persistent widget state */
5551 struct nk_property_state property;
5552 struct nk_popup_state popup;
5553 struct nk_edit_state edit;
5554 unsigned int scrolled;
5555 nk_bool widgets_disabled;
5556
5557 struct nk_table *tables;
5558 unsigned int table_count;
5559
5560 /* window list hooks */
5561 struct nk_window *next;
5562 struct nk_window *prev;
5563 struct nk_window *parent;
5564};
5565
5566/*==============================================================
5567 * STACK
5568 * =============================================================*/
5595#ifndef NK_BUTTON_BEHAVIOR_STACK_SIZE
5596#define NK_BUTTON_BEHAVIOR_STACK_SIZE 8
5597#endif
5598
5599#ifndef NK_FONT_STACK_SIZE
5600#define NK_FONT_STACK_SIZE 8
5601#endif
5602
5603#ifndef NK_STYLE_ITEM_STACK_SIZE
5604#define NK_STYLE_ITEM_STACK_SIZE 16
5605#endif
5606
5607#ifndef NK_FLOAT_STACK_SIZE
5608#define NK_FLOAT_STACK_SIZE 32
5609#endif
5610
5611#ifndef NK_VECTOR_STACK_SIZE
5612#define NK_VECTOR_STACK_SIZE 16
5613#endif
5614
5615#ifndef NK_FLAGS_STACK_SIZE
5616#define NK_FLAGS_STACK_SIZE 32
5617#endif
5618
5619#ifndef NK_COLOR_STACK_SIZE
5620#define NK_COLOR_STACK_SIZE 32
5621#endif
5622
5623#define NK_CONFIGURATION_STACK_TYPE(prefix, name, type)\
5624 struct nk_config_stack_##name##_element {\
5625 prefix##_##type *address;\
5626 prefix##_##type old_value;\
5627 }
5628#define NK_CONFIG_STACK(type,size)\
5629 struct nk_config_stack_##type {\
5630 int head;\
5631 struct nk_config_stack_##type##_element elements[size];\
5632 }
5633
5634#define nk_float float
5635NK_CONFIGURATION_STACK_TYPE(struct nk, style_item, style_item);
5636NK_CONFIGURATION_STACK_TYPE(nk ,float, float);
5637NK_CONFIGURATION_STACK_TYPE(struct nk, vec2, vec2);
5638NK_CONFIGURATION_STACK_TYPE(nk ,flags, flags);
5639NK_CONFIGURATION_STACK_TYPE(struct nk, color, color);
5640NK_CONFIGURATION_STACK_TYPE(const struct nk, user_font, user_font*);
5641NK_CONFIGURATION_STACK_TYPE(enum nk, button_behavior, button_behavior);
5642
5643NK_CONFIG_STACK(style_item, NK_STYLE_ITEM_STACK_SIZE);
5644NK_CONFIG_STACK(float, NK_FLOAT_STACK_SIZE);
5645NK_CONFIG_STACK(vec2, NK_VECTOR_STACK_SIZE);
5646NK_CONFIG_STACK(flags, NK_FLAGS_STACK_SIZE);
5647NK_CONFIG_STACK(color, NK_COLOR_STACK_SIZE);
5648NK_CONFIG_STACK(user_font, NK_FONT_STACK_SIZE);
5649NK_CONFIG_STACK(button_behavior, NK_BUTTON_BEHAVIOR_STACK_SIZE);
5650
5652 struct nk_config_stack_style_item style_items;
5653 struct nk_config_stack_float floats;
5654 struct nk_config_stack_vec2 vectors;
5655 struct nk_config_stack_flags flags;
5656 struct nk_config_stack_color colors;
5657 struct nk_config_stack_user_font fonts;
5658 struct nk_config_stack_button_behavior button_behaviors;
5659};
5660
5661/*==============================================================
5662 * CONTEXT
5663 * =============================================================*/
5664#define NK_VALUE_PAGE_CAPACITY \
5665 (((NK_MAX(sizeof(struct nk_window),sizeof(struct nk_panel)) / sizeof(nk_uint))) / 2)
5666
5667struct nk_table {
5668 unsigned int seq;
5669 unsigned int size;
5670 nk_hash keys[NK_VALUE_PAGE_CAPACITY];
5671 nk_uint values[NK_VALUE_PAGE_CAPACITY];
5672 struct nk_table *next, *prev;
5673};
5674
5676 struct nk_table tbl;
5677 struct nk_panel pan;
5678 struct nk_window win;
5679};
5680
5682 union nk_page_data data;
5683 struct nk_page_element *next;
5684 struct nk_page_element *prev;
5685};
5686
5687struct nk_page {
5688 unsigned int size;
5689 struct nk_page *next;
5690 struct nk_page_element win[1];
5691};
5692
5693struct nk_pool {
5694 struct nk_allocator alloc;
5695 enum nk_allocation_type type;
5696 unsigned int page_count;
5697 struct nk_page *pages;
5698 struct nk_page_element *freelist;
5699 unsigned capacity;
5700 nk_size size;
5701 nk_size cap;
5702};
5703
5705/* public: can be accessed freely */
5706 struct nk_input input;
5707 struct nk_style style;
5708 struct nk_buffer memory;
5709 struct nk_clipboard clip;
5710 nk_flags last_widget_state;
5711 enum nk_button_behavior button_behavior;
5712 struct nk_configuration_stacks stacks;
5713 float delta_time_seconds;
5714
5715/* private:
5716 should only be accessed if you
5717 know what you are doing */
5718#ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
5719 struct nk_draw_list draw_list;
5720#endif
5721#ifdef NK_INCLUDE_COMMAND_USERDATA
5722 nk_handle userdata;
5723#endif
5731
5734 int use_pool;
5735 struct nk_pool pool;
5736 struct nk_window *begin;
5737 struct nk_window *end;
5738 struct nk_window *active;
5739 struct nk_window *current;
5740 struct nk_page_element *freelist;
5741 unsigned int count;
5742 unsigned int seq;
5743};
5744
5745/* ==============================================================
5746 * MATH
5747 * =============================================================== */
5748#define NK_PI 3.141592654f
5749#define NK_PI_HALF 1.570796326f
5750#define NK_UTF_INVALID 0xFFFD
5751#define NK_MAX_FLOAT_PRECISION 2
5752
5753#define NK_UNUSED(x) ((void)(x))
5754#define NK_SATURATE(x) (NK_MAX(0, NK_MIN(1.0f, x)))
5755#define NK_LEN(a) (sizeof(a)/sizeof(a)[0])
5756#define NK_ABS(a) (((a) < 0) ? -(a) : (a))
5757#define NK_BETWEEN(x, a, b) ((a) <= (x) && (x) < (b))
5758#define NK_INBOX(px, py, x, y, w, h)\
5759 (NK_BETWEEN(px,x,x+w) && NK_BETWEEN(py,y,y+h))
5760#define NK_INTERSECT(x0, y0, w0, h0, x1, y1, w1, h1) \
5761 ((x1 < (x0 + w0)) && (x0 < (x1 + w1)) && \
5762 (y1 < (y0 + h0)) && (y0 < (y1 + h1)))
5763#define NK_CONTAINS(x, y, w, h, bx, by, bw, bh)\
5764 (NK_INBOX(x,y, bx, by, bw, bh) && NK_INBOX(x+w,y+h, bx, by, bw, bh))
5765
5766#define nk_vec2_sub(a, b) nk_vec2((a).x - (b).x, (a).y - (b).y)
5767#define nk_vec2_add(a, b) nk_vec2((a).x + (b).x, (a).y + (b).y)
5768#define nk_vec2_len_sqr(a) ((a).x*(a).x+(a).y*(a).y)
5769#define nk_vec2_muls(a, t) nk_vec2((a).x * (t), (a).y * (t))
5770
5771#define nk_ptr_add(t, p, i) ((t*)((void*)((nk_byte*)(p) + (i))))
5772#define nk_ptr_add_const(t, p, i) ((const t*)((const void*)((const nk_byte*)(p) + (i))))
5773#define nk_zero_struct(s) nk_zero(&s, sizeof(s))
5774
5775/* ==============================================================
5776 * ALIGNMENT
5777 * =============================================================== */
5778/* Pointer to Integer type conversion for pointer alignment */
5779#if defined(__PTRDIFF_TYPE__) /* This case should work for GCC*/
5780# define NK_UINT_TO_PTR(x) ((void*)(__PTRDIFF_TYPE__)(x))
5781# define NK_PTR_TO_UINT(x) ((nk_size)(__PTRDIFF_TYPE__)(x))
5782#elif !defined(__GNUC__) /* works for compilers other than LLVM */
5783# define NK_UINT_TO_PTR(x) ((void*)&((char*)0)[x])
5784# define NK_PTR_TO_UINT(x) ((nk_size)(((char*)x)-(char*)0))
5785#elif defined(NK_USE_FIXED_TYPES) /* used if we have <stdint.h> */
5786# define NK_UINT_TO_PTR(x) ((void*)(uintptr_t)(x))
5787# define NK_PTR_TO_UINT(x) ((uintptr_t)(x))
5788#else /* generates warning but works */
5789# define NK_UINT_TO_PTR(x) ((void*)(x))
5790# define NK_PTR_TO_UINT(x) ((nk_size)(x))
5791#endif
5792
5793#define NK_ALIGN_PTR(x, mask)\
5794 (NK_UINT_TO_PTR((NK_PTR_TO_UINT((nk_byte*)(x) + (mask-1)) & ~(mask-1))))
5795#define NK_ALIGN_PTR_BACK(x, mask)\
5796 (NK_UINT_TO_PTR((NK_PTR_TO_UINT((nk_byte*)(x)) & ~(mask-1))))
5797
5798#if ((defined(__GNUC__) && __GNUC__ >= 4) || defined(__clang__)) && !defined(EMSCRIPTEN)
5799#define NK_OFFSETOF(st,m) (__builtin_offsetof(st,m))
5800#else
5801#define NK_OFFSETOF(st,m) ((nk_ptr)&(((st*)0)->m))
5802#endif
5803
5804#ifdef __cplusplus
5805}
5806#endif
5807
5808#ifdef __cplusplus
5809template<typename T> struct nk_alignof;
5810template<typename T, int size_diff> struct nk_helper{enum {value = size_diff};};
5811template<typename T> struct nk_helper<T,0>{enum {value = nk_alignof<T>::value};};
5812template<typename T> struct nk_alignof{struct Big {T x; char c;}; enum {
5813 diff = sizeof(Big) - sizeof(T), value = nk_helper<Big, diff>::value};};
5814#define NK_ALIGNOF(t) (nk_alignof<t>::value)
5815#else
5816#define NK_ALIGNOF(t) NK_OFFSETOF(struct {char c; t _h;}, _h)
5817#endif
5818
5819#define NK_CONTAINER_OF(ptr,type,member)\
5820 (type*)((void*)((char*)(1 ? (ptr): &((type*)0)->member) - NK_OFFSETOF(type, member)))
5821
5822
5823
5824#endif /* NK_NUKLEAR_H_ */
NK_API void nk_tree_pop(struct nk_context *)
NK_API void nk_free(struct nk_context *)
Frees all memory allocated by nuklear; Not needed if context was initialized with nk_init_fixed.
NK_API nk_bool nk_group_begin(struct nk_context *, const char *title, nk_flags)
Starts a new widget group.
NK_API struct nk_vec2 nk_window_get_content_region_max(const struct nk_context *ctx)
NK_API void nk_layout_row_end(struct nk_context *)
Finished previously started row.
NK_API void nk_input_end(struct nk_context *)
End the input mirroring process by resetting mouse grabbing state to ensure the mouse cursor is not g...
NK_API void nk_window_close(struct nk_context *ctx, const char *name)
NK_API void nk_spacer(struct nk_context *ctx)
NK_API void nk_input_begin(struct nk_context *)
Begins the input mirroring process by resetting text, scroll mouse, previous mouse position and movem...
NK_API float nk_propertyf(struct nk_context *, const char *name, float min, float val, float max, float step, float inc_per_pixel)
NK_API void nk_rule_horizontal(struct nk_context *ctx, struct nk_color color, nk_bool rounding)
NK_API void nk_layout_space_end(struct nk_context *)
NK_API nk_bool nk_init_fixed(struct nk_context *, void *memory, nk_size size, const struct nk_user_font *)
NK_API void nk_property_float(struct nk_context *, const char *name, float min, float *val, float max, float step, float inc_per_pixel)
nk_window_flags
Definition nuklear.h:5489
@ NK_WINDOW_CLOSED
Directly closes and frees the window at the end of the frame.
Definition nuklear.h:5495
@ NK_WINDOW_MINIMIZED
marks the window as minimized
Definition nuklear.h:5496
@ NK_WINDOW_HIDDEN
Hides window and stops any window interaction and drawing.
Definition nuklear.h:5494
@ NK_WINDOW_ROM
sets window widgets into a read only mode and does not allow input changes
Definition nuklear.h:5492
@ NK_WINDOW_NOT_INTERACTIVE
prevents all interaction caused by input to either window or widgets inside
Definition nuklear.h:5493
@ NK_WINDOW_DYNAMIC
special window type growing up in height while being filled to a certain maximum height
Definition nuklear.h:5491
@ NK_WINDOW_REMOVE_ROM
Removes read only mode at the end of the window.
Definition nuklear.h:5497
NK_API void nk_layout_row(struct nk_context *, enum nk_layout_format, float height, int cols, const float *ratio)
Specifies row columns in array as either window ratio or size.
NK_API void nk_draw_image(struct nk_command_buffer *, struct nk_rect, const struct nk_image *, struct nk_color)
misc
NK_API nk_bool nk_window_is_hovered(const struct nk_context *ctx)
NK_API void nk_window_collapse_if(struct nk_context *ctx, const char *name, enum nk_collapse_states state, int cond)
NK_API struct nk_vec2 nk_layout_space_to_screen(const struct nk_context *ctx, struct nk_vec2 vec)
#define NK_BOOL
could be char, use int for drop-in replacement backwards compatibility
Definition nuklear.h:192
NK_API struct nk_command_buffer * nk_window_get_canvas(const struct nk_context *ctx)
NK_API nk_bool nk_init_custom(struct nk_context *, struct nk_buffer *cmds, struct nk_buffer *pool, const struct nk_user_font *)
Initializes a nk_context struct from two different either fixed or growing buffers.
NK_API nk_bool nk_tree_image_push_hashed(struct nk_context *, enum nk_tree_type, struct nk_image, const char *title, enum nk_collapse_states initial_state, const char *hash, int len, int seed)
NK_API void nk_window_set_scroll(struct nk_context *ctx, nk_uint offset_x, nk_uint offset_y)
NK_API void nk_group_scrolled_end(struct nk_context *)
NK_API struct nk_vec2 nk_window_get_size(const struct nk_context *ctx)
NK_API void nk_layout_row_template_push_dynamic(struct nk_context *)
NK_API const struct nk_command * nk__begin(struct nk_context *)
Returns a draw command list iterator to iterate all draw commands accumulated over one frame.
NK_API nk_bool nk_window_is_active(const struct nk_context *ctx, const char *name)
NK_API void nk_group_get_scroll(struct nk_context *, const char *id, nk_uint *x_offset, nk_uint *y_offset)
NK_API struct nk_vec2 nk_layout_space_to_local(const struct nk_context *ctx, struct nk_vec2 vec)
NK_API void nk_window_set_focus(struct nk_context *ctx, const char *name)
NK_API nk_bool nk_item_is_any_active(const struct nk_context *ctx)
#define NK_UTF_SIZE
describes the number of bytes a glyph consists of
Definition nuklear.h:22
NK_API void nk_input_unicode(struct nk_context *, nk_rune)
Converts a unicode rune into UTF-8 and copies the result into an internal text buffer.
NK_API nk_bool nk_window_is_any_hovered(const struct nk_context *ctx)
NK_API nk_bool nk_window_is_hidden(const struct nk_context *ctx, const char *name)
NK_API void nk_input_key(struct nk_context *, enum nk_keys, nk_bool down)
Mirrors the state of a specific key to nuklear.
NK_API void nk_stroke_line(struct nk_command_buffer *b, float x0, float y0, float x1, float y1, float line_thickness, struct nk_color)
shape outlines
NK_API void nk_property_double(struct nk_context *, const char *name, double min, double *val, double max, double step, float inc_per_pixel)
NK_API void nk_fill_rect(struct nk_command_buffer *, struct nk_rect, float rounding, struct nk_color)
filled shades
NK_API void nk_layout_row_template_push_static(struct nk_context *, float width)
NK_API struct nk_vec2 nk_window_get_content_region_size(const struct nk_context *ctx)
NK_API struct nk_panel * nk_window_get_panel(const struct nk_context *ctx)
NK_API void nk_window_get_scroll(const struct nk_context *ctx, nk_uint *offset_x, nk_uint *offset_y)
NK_API nk_bool nk_group_scrolled_offset_begin(struct nk_context *, nk_uint *x_offset, nk_uint *y_offset, const char *title, nk_flags flags)
NK_API nk_bool nk_tree_state_image_push(struct nk_context *, enum nk_tree_type, struct nk_image, const char *title, enum nk_collapse_states *state)
NK_API void nk_window_set_position(struct nk_context *ctx, const char *name, struct nk_vec2 pos)
NK_API void nk_window_show(struct nk_context *ctx, const char *name, enum nk_show_states state)
NK_API nk_bool nk_window_is_collapsed(const struct nk_context *ctx, const char *name)
NK_API void nk_layout_row_dynamic(struct nk_context *ctx, float height, int cols)
Sets current row layout to share horizontal space between @cols number of widgets evenly.
NK_API const struct nk_command * nk__next(struct nk_context *, const struct nk_command *)
Returns draw command pointer pointing to the next command inside the draw command list.
NK_API void nk_window_collapse(struct nk_context *ctx, const char *name, enum nk_collapse_states state)
NK_API nk_bool nk_filter_default(const struct nk_text_edit *, nk_rune unicode)
filter function
NK_API void nk_layout_row_template_end(struct nk_context *)
NK_API nk_bool nk_window_has_focus(const struct nk_context *ctx)
NK_API void nk_layout_reset_min_row_height(struct nk_context *)
Reset the currently used minimum row height back to font_height + text_padding + padding
nk_widget_states
Definition nuklear.h:3087
@ NK_WIDGET_STATE_LEFT
!< widget is currently activated
Definition nuklear.h:3093
@ NK_WIDGET_STATE_ACTIVED
!< widget is being hovered
Definition nuklear.h:3092
@ NK_WIDGET_STATE_ENTERED
!< widget is neither active nor hovered
Definition nuklear.h:3090
@ NK_WIDGET_STATE_HOVER
!< widget has been hovered on the current frame
Definition nuklear.h:3091
@ NK_WIDGET_STATE_ACTIVE
!< widget is being hovered
Definition nuklear.h:3095
@ NK_WIDGET_STATE_HOVERED
!< widget is from this frame on not hovered anymore
Definition nuklear.h:3094
NK_API struct nk_window * nk_window_find(const struct nk_context *ctx, const char *name)
NK_API struct nk_rect nk_layout_space_rect_to_local(const struct nk_context *ctx, struct nk_rect bounds)
NK_API void nk_window_set_bounds(struct nk_context *ctx, const char *name, struct nk_rect bounds)
NK_API struct nk_rect nk_window_get_bounds(const struct nk_context *ctx)
NK_API nk_bool nk_tree_state_push(struct nk_context *, enum nk_tree_type, const char *title, enum nk_collapse_states *state)
NK_API nk_bool nk_tree_push_hashed(struct nk_context *, enum nk_tree_type, const char *title, enum nk_collapse_states initial_state, const char *hash, int len, int seed)
NK_API void nk_layout_set_min_row_height(struct nk_context *, float height)
Sets the currently used minimum row height.
NK_API void nk_window_show_if(struct nk_context *ctx, const char *name, enum nk_show_states state, int cond)
NK_API float nk_window_get_height(const struct nk_context *ctx)
NK_API void nk_layout_row_begin(struct nk_context *ctx, enum nk_layout_format fmt, float row_height, int cols)
Starts a new dynamic or fixed row with given height and columns.
NK_API nk_bool nk_group_begin_titled(struct nk_context *, const char *name, const char *title, nk_flags)
Starts a new widget group.
NK_API nk_bool nk_begin_titled(struct nk_context *ctx, const char *name, const char *title, struct nk_rect bounds, nk_flags flags)
NK_API void nk_layout_space_push(struct nk_context *, struct nk_rect bounds)
NK_API nk_bool nk_begin(struct nk_context *ctx, const char *title, struct nk_rect bounds, nk_flags flags)
NK_API void nk_window_set_size(struct nk_context *ctx, const char *name, struct nk_vec2 size)
NK_API void nk_input_button(struct nk_context *, enum nk_buttons, int x, int y, nk_bool down)
Mirrors the state of a specific mouse button to nuklear.
NK_API void nk_group_set_scroll(struct nk_context *, const char *id, nk_uint x_offset, nk_uint y_offset)
NK_API void nk_layout_row_template_begin(struct nk_context *, float row_height)
NK_API nk_bool nk_init(struct nk_context *, const struct nk_allocator *, const struct nk_user_font *)
NK_API float nk_layout_ratio_from_pixel(const struct nk_context *ctx, float pixel_width)
Utility functions to calculate window ratio from pixel size.
NK_API void nk_tree_state_pop(struct nk_context *)
NK_API void nk_layout_row_push(struct nk_context *, float value)
\breif Specifies either window ratio or width of a single column
NK_API struct nk_rect nk_layout_widget_bounds(const struct nk_context *ctx)
Returns the width of the next row allocate by one of the layouting functions.
NK_API struct nk_rect nk_layout_space_rect_to_screen(const struct nk_context *ctx, struct nk_rect bounds)
NK_API struct nk_vec2 nk_window_get_content_region_min(const struct nk_context *ctx)
NK_API void nk_input_char(struct nk_context *, char)
Copies a single ASCII character into an internal text buffer.
NK_API float nk_window_get_width(const struct nk_context *ctx)
nk_window_get_width
NK_API void nk_input_scroll(struct nk_context *, struct nk_vec2 val)
Copies the last mouse scroll value to nuklear.
nk_widget_layout_states
Definition nuklear.h:3081
@ NK_WIDGET_DISABLED
The widget is manually disabled and acts like NK_WIDGET_ROM.
Definition nuklear.h:3085
@ NK_WIDGET_ROM
The widget is partially visible and cannot be updated.
Definition nuklear.h:3084
@ NK_WIDGET_VALID
The widget is completely inside the window and can be updated and drawn.
Definition nuklear.h:3083
@ NK_WIDGET_INVALID
The widget cannot be seen and is completely out of view.
Definition nuklear.h:3082
NK_API double nk_propertyd(struct nk_context *, const char *name, double min, double val, double max, double step, float inc_per_pixel)
NK_API void nk_input_motion(struct nk_context *, int x, int y)
Mirrors current mouse position to nuklear.
NK_API void nk_layout_space_begin(struct nk_context *, enum nk_layout_format, float height, int widget_count)
NK_API struct nk_rect nk_layout_space_bounds(const struct nk_context *ctx)
NK_API struct nk_rect nk_window_get_content_region(const struct nk_context *ctx)
NK_API nk_bool nk_window_is_closed(const struct nk_context *ctx, const char *name)
NK_API void nk_clear(struct nk_context *)
Resets the context state at the end of the frame.
NK_API void nk_end(struct nk_context *ctx)
NK_API void nk_group_end(struct nk_context *)
NK_API void nk_layout_row_template_push_variable(struct nk_context *, float min_width)
NK_API struct nk_vec2 nk_window_get_position(const struct nk_context *ctx)
nk_edit_events
Definition nuklear.h:3501
@ NK_EDIT_INACTIVE
!< edit widget is currently being modified
Definition nuklear.h:3503
@ NK_EDIT_DEACTIVATED
!< edit widget went from state inactive to state active
Definition nuklear.h:3505
@ NK_EDIT_COMMITED
!< edit widget went from state active to state inactive
Definition nuklear.h:3506
@ NK_EDIT_ACTIVATED
!< edit widget is not active and is not being modified
Definition nuklear.h:3504
NK_API int nk_propertyi(struct nk_context *, const char *name, int min, int val, int max, int step, float inc_per_pixel)
NK_API nk_bool nk_group_scrolled_begin(struct nk_context *, struct nk_scroll *off, const char *title, nk_flags)
NK_API void nk_input_glyph(struct nk_context *, const nk_glyph)
Converts an encoded unicode rune into UTF-8 and copies the result into an internal text buffer.
NK_API void nk_layout_row_static(struct nk_context *ctx, float height, int item_width, int cols)
Sets current row layout to fill @cols number of widgets in row with same @item_width horizontal size.
NK_API void nk_textedit_init(struct nk_text_edit *, const struct nk_allocator *, nk_size size)
text editor
struct nk_allocator pool
!< buffer marker to free a buffer to a certain offset
Definition nuklear.h:4191
struct nk_memory memory
!< memory management type
Definition nuklear.h:4193
enum nk_allocation_type type
!< allocator callback for dynamic buffers
Definition nuklear.h:4192
nk_size needed
!< total amount of memory allocated
Definition nuklear.h:4196
nk_size size
!< number of allocation calls
Definition nuklear.h:4198
nk_size allocated
!< growing factor for dynamic memory management
Definition nuklear.h:4195
float grow_factor
!< memory and size of the current memory block
Definition nuklear.h:4194
nk_size calls
!< totally consumed memory given that enough memory is present
Definition nuklear.h:4197
command base and header of every command inside the buffer
Definition nuklear.h:4467
int build
windows
Definition nuklear.h:5733
struct nk_text_edit text_edit
text editor objects are quite big because of an internal undo/redo stack.
Definition nuklear.h:5728
struct nk_command_buffer overlay
draw buffer used for overlay drawing operation like cursor
Definition nuklear.h:5730
enum nk_anti_aliasing shape_AA
!< line anti-aliasing flag can be turned off if you are tight on memory
Definition nuklear.h:981
enum nk_anti_aliasing line_AA
!< global alpha value
Definition nuklear.h:980
nk_size vertex_alignment
!< sizeof one vertex for vertex packing
Definition nuklear.h:988
nk_size vertex_size
!< describes the vertex output format and packing
Definition nuklear.h:987
const struct nk_draw_vertex_layout_element * vertex_layout
!< handle to texture with a white pixel for shape drawing
Definition nuklear.h:986
unsigned arc_segment_count
!< number of segments used for circles: default to 22
Definition nuklear.h:983
unsigned circle_segment_count
!< shape anti-aliasing flag can be turned off if you are tight on memory
Definition nuklear.h:982
unsigned curve_segment_count
!< number of segments used for arcs: default to 22
Definition nuklear.h:984
struct nk_draw_null_texture tex_null
!< number of segments used for curves: default to 22
Definition nuklear.h:985
struct nk_vec2 uv
!< texture handle to a texture with a white pixel
Definition nuklear.h:976
==============================================================
Definition nuklear.h:4226
nk_text_width_f width
!< max height of the font
Definition nuklear.h:4009
float height
!< user provided font handle
Definition nuklear.h:4008