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_internal.h
1#ifndef NK_INTERNAL_H
2#define NK_INTERNAL_H
3
4#ifndef NK_POOL_DEFAULT_CAPACITY
5#define NK_POOL_DEFAULT_CAPACITY 16
6#endif
7
8#ifndef NK_DEFAULT_COMMAND_BUFFER_SIZE
9#define NK_DEFAULT_COMMAND_BUFFER_SIZE (4*1024)
10#endif
11
12#ifndef NK_BUFFER_DEFAULT_INITIAL_SIZE
13#define NK_BUFFER_DEFAULT_INITIAL_SIZE (4*1024)
14#endif
15
16/* standard library headers */
17#ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
18#include <stdlib.h> /* malloc, free */
19#endif
20#ifdef NK_INCLUDE_STANDARD_IO
21#include <stdio.h> /* fopen, fclose,... */
22#endif
23#ifdef NK_INCLUDE_STANDARD_VARARGS
24#include <stdarg.h> /* valist, va_start, va_end, ... */
25#endif
26#ifndef NK_ASSERT
27#include <assert.h>
28#define NK_ASSERT(expr) assert(expr)
29#endif
30
31#define NK_DEFAULT (-1)
32
33#ifndef NK_VSNPRINTF
34/* If your compiler does support `vsnprintf` I would highly recommend
35 * defining this to vsnprintf instead since `vsprintf` is basically
36 * unbelievable unsafe and should *NEVER* be used. But I have to support
37 * it since C89 only provides this unsafe version. */
38 #if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) ||\
39 (defined(__cplusplus) && (__cplusplus >= 201103L)) || \
40 (defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200112L)) ||\
41 (defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)) ||\
42 defined(_ISOC99_SOURCE) || defined(_BSD_SOURCE)
43 #define NK_VSNPRINTF(s,n,f,a) vsnprintf(s,n,f,a)
44 #else
45 #define NK_VSNPRINTF(s,n,f,a) vsprintf(s,f,a)
46 #endif
47#endif
48
49#define NK_SCHAR_MIN (-127)
50#define NK_SCHAR_MAX 127
51#define NK_UCHAR_MIN 0
52#define NK_UCHAR_MAX 256
53#define NK_SSHORT_MIN (-32767)
54#define NK_SSHORT_MAX 32767
55#define NK_USHORT_MIN 0
56#define NK_USHORT_MAX 65535
57#define NK_SINT_MIN (-2147483647)
58#define NK_SINT_MAX 2147483647
59#define NK_UINT_MIN 0
60#define NK_UINT_MAX 4294967295u
61
62/* Make sure correct type size:
63 * This will fire with a negative subscript error if the type sizes
64 * are set incorrectly by the compiler, and compile out if not */
65NK_STATIC_ASSERT(sizeof(nk_size) >= sizeof(void*));
66NK_STATIC_ASSERT(sizeof(nk_ptr) == sizeof(void*));
67NK_STATIC_ASSERT(sizeof(nk_flags) >= 4);
68NK_STATIC_ASSERT(sizeof(nk_rune) >= 4);
69NK_STATIC_ASSERT(sizeof(nk_ushort) == 2);
70NK_STATIC_ASSERT(sizeof(nk_short) == 2);
71NK_STATIC_ASSERT(sizeof(nk_uint) == 4);
72NK_STATIC_ASSERT(sizeof(nk_int) == 4);
73NK_STATIC_ASSERT(sizeof(nk_byte) == 1);
74NK_STATIC_ASSERT(sizeof(nk_bool) <= sizeof(int));
75
76NK_GLOBAL const struct nk_rect nk_null_rect = {-8192.0f, -8192.0f, 16384, 16384};
77#define NK_FLOAT_PRECISION 0.00000000000001
78
79NK_GLOBAL const struct nk_color nk_red = {255,0,0,255};
80NK_GLOBAL const struct nk_color nk_green = {0,255,0,255};
81NK_GLOBAL const struct nk_color nk_blue = {0,0,255,255};
82NK_GLOBAL const struct nk_color nk_white = {255,255,255,255};
83NK_GLOBAL const struct nk_color nk_black = {0,0,0,255};
84NK_GLOBAL const struct nk_color nk_yellow = {255,255,0,255};
85
86/* widget */
87#define nk_widget_state_reset(s)\
88 if ((*(s)) & NK_WIDGET_STATE_MODIFIED)\
89 (*(s)) = NK_WIDGET_STATE_INACTIVE|NK_WIDGET_STATE_MODIFIED;\
90 else (*(s)) = NK_WIDGET_STATE_INACTIVE;
91
92/* math */
93#ifndef NK_INV_SQRT
94#define NK_INV_SQRT nk_inv_sqrt
95#define NK_INV_SQRT_NEEDED
96NK_LIB float nk_inv_sqrt(float n);
97#endif
98#ifndef NK_SIN
99#define NK_SIN nk_sin
100#define NK_SIN_NEEDED
101NK_LIB float nk_sin(float x);
102#endif
103#ifndef NK_COS
104#define NK_COS nk_cos
105#define NK_COS_NEEDED
106NK_LIB float nk_cos(float x);
107#endif
108#ifndef NK_ATAN
109#define NK_ATAN nk_atan
110#define NK_ATAN_NEEDED
111NK_LIB float nk_atan(float x);
112#endif
113#ifndef NK_ATAN2
114#define NK_ATAN2 nk_atan2
115#define NK_ATAN2_NEEDED
116NK_LIB float nk_atan2(float y, float x);
117#endif
118NK_LIB nk_uint nk_round_up_pow2(nk_uint v);
119NK_LIB struct nk_rect nk_shrink_rect(struct nk_rect r, float amount);
120NK_LIB struct nk_rect nk_pad_rect(struct nk_rect r, struct nk_vec2 pad);
121NK_LIB void nk_unify(struct nk_rect *clip, const struct nk_rect *a, float x0, float y0, float x1, float y1);
122NK_LIB int nk_ifloorf(float x);
123NK_LIB int nk_iceilf(float x);
124NK_LIB float nk_roundf(float x);
125
126/* util */
127enum {NK_DO_NOT_STOP_ON_NEW_LINE, NK_STOP_ON_NEW_LINE};
128NK_LIB nk_bool nk_is_lower(int c);
129NK_LIB nk_bool nk_is_upper(int c);
130NK_LIB int nk_to_upper(int c);
131NK_LIB int nk_to_lower(int c);
132
133#ifndef NK_MEMCPY
134#define NK_MEMCPY nk_memcopy
135#define NK_MEMCPY_NEEDED
136NK_LIB void* nk_memcopy(void *dst, const void *src, nk_size n);
137#endif
138#ifndef NK_MEMSET
139#define NK_MEMSET nk_memset
140#define NK_MEMSET_NEEDED
141NK_LIB void nk_memset(void *ptr, int c0, nk_size size);
142#endif
143NK_LIB void nk_zero(void *ptr, nk_size size);
144NK_LIB char *nk_itoa(char *s, long n);
145NK_LIB int nk_string_float_limit(char *string, int prec);
146#ifndef NK_DTOA
147#define NK_DTOA nk_dtoa
148#define NK_DTOA_NEEDED
149NK_LIB char *nk_dtoa(char *s, double n);
150#endif
151NK_LIB int nk_text_clamp(const struct nk_user_font *font, const char *text, int text_len, float space, int *glyphs, float *text_width, nk_rune *sep_list, int sep_count);
152NK_LIB struct nk_vec2 nk_text_calculate_text_bounds(const struct nk_user_font *font, const char *begin, int byte_len, float row_height, const char **remaining, struct nk_vec2 *out_offset, int *glyphs, int op);
153#ifdef NK_INCLUDE_STANDARD_VARARGS
154NK_LIB int nk_strfmt(char *buf, int buf_size, const char *fmt, va_list args);
155#endif
156#ifdef NK_INCLUDE_STANDARD_IO
157NK_LIB char *nk_file_load(const char* path, nk_size* siz, const struct nk_allocator *alloc);
158#endif
159
160/* math helpers that are only used by nk_dtoa */
161#ifdef NK_DTOA_NEEDED
162NK_LIB double nk_pow(double x, int n);
163NK_LIB int nk_ifloord(double x);
164NK_LIB int nk_log10(double n);
165#endif
166
167/* buffer */
168#ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
169NK_LIB void* nk_malloc(nk_handle unused, void *old,nk_size size);
170NK_LIB void nk_mfree(nk_handle unused, void *ptr);
171#endif
172NK_LIB void* nk_buffer_align(void *unaligned, nk_size align, nk_size *alignment, enum nk_buffer_allocation_type type);
173NK_LIB void* nk_buffer_alloc(struct nk_buffer *b, enum nk_buffer_allocation_type type, nk_size size, nk_size align);
174NK_LIB void* nk_buffer_realloc(struct nk_buffer *b, nk_size capacity, nk_size *size);
175
176/* draw */
177NK_LIB void nk_command_buffer_init(struct nk_command_buffer *cb, struct nk_buffer *b, enum nk_command_clipping clip);
178NK_LIB void nk_command_buffer_reset(struct nk_command_buffer *b);
179NK_LIB void* nk_command_buffer_push(struct nk_command_buffer* b, enum nk_command_type t, nk_size size);
180NK_LIB void nk_draw_symbol(struct nk_command_buffer *out, enum nk_symbol_type type, struct nk_rect content, struct nk_color background, struct nk_color foreground, float border_width, const struct nk_user_font *font);
181
182/* buffering */
183NK_LIB void nk_start_buffer(struct nk_context *ctx, struct nk_command_buffer *b);
184NK_LIB void nk_start(struct nk_context *ctx, struct nk_window *win);
185NK_LIB void nk_start_popup(struct nk_context *ctx, struct nk_window *win);
186NK_LIB void nk_finish_popup(struct nk_context *ctx, struct nk_window*);
187NK_LIB void nk_finish_buffer(struct nk_context *ctx, struct nk_command_buffer *b);
188NK_LIB void nk_finish(struct nk_context *ctx, struct nk_window *w);
189NK_LIB void nk_build(struct nk_context *ctx);
190
191/* text editor */
192NK_LIB void nk_textedit_clear_state(struct nk_text_edit *state, enum nk_text_edit_type type, nk_plugin_filter filter);
193NK_LIB void nk_textedit_click(struct nk_text_edit *state, float x, float y, const struct nk_user_font *font, float row_height);
194NK_LIB void nk_textedit_drag(struct nk_text_edit *state, float x, float y, const struct nk_user_font *font, float row_height);
195NK_LIB void nk_textedit_key(struct nk_text_edit *state, enum nk_keys key, int shift_mod, const struct nk_user_font *font, float row_height);
196
197/* window */
198enum nk_window_insert_location {
199 NK_INSERT_BACK, /* inserts window into the back of list (front of screen) */
200 NK_INSERT_FRONT /* inserts window into the front of list (back of screen) */
201};
202NK_LIB void *nk_create_window(struct nk_context *ctx);
203NK_LIB void nk_remove_window(struct nk_context*, struct nk_window*);
204NK_LIB void nk_free_window(struct nk_context *ctx, struct nk_window *win);
205NK_LIB struct nk_window *nk_find_window(const struct nk_context *ctx, nk_hash hash, const char *name);
206NK_LIB void nk_insert_window(struct nk_context *ctx, struct nk_window *win, enum nk_window_insert_location loc);
207
208/* pool */
209NK_LIB void nk_pool_init(struct nk_pool *pool, const struct nk_allocator *alloc, unsigned int capacity);
210NK_LIB void nk_pool_free(struct nk_pool *pool);
211NK_LIB void nk_pool_init_fixed(struct nk_pool *pool, void *memory, nk_size size);
212NK_LIB struct nk_page_element *nk_pool_alloc(struct nk_pool *pool);
213
214/* page-element */
215NK_LIB struct nk_page_element* nk_create_page_element(struct nk_context *ctx);
216NK_LIB void nk_link_page_element_into_freelist(struct nk_context *ctx, struct nk_page_element *elem);
217NK_LIB void nk_free_page_element(struct nk_context *ctx, struct nk_page_element *elem);
218
219/* table */
220NK_LIB struct nk_table* nk_create_table(struct nk_context *ctx);
221NK_LIB void nk_remove_table(struct nk_window *win, struct nk_table *tbl);
222NK_LIB void nk_free_table(struct nk_context *ctx, struct nk_table *tbl);
223NK_LIB void nk_push_table(struct nk_window *win, struct nk_table *tbl);
224NK_LIB nk_uint *nk_add_value(struct nk_context *ctx, struct nk_window *win, nk_hash name, nk_uint value);
225NK_LIB nk_uint *nk_find_value(const struct nk_window *win, nk_hash name);
226
227/* panel */
228NK_LIB void *nk_create_panel(struct nk_context *ctx);
229NK_LIB void nk_free_panel(struct nk_context*, struct nk_panel *pan);
230NK_LIB nk_bool nk_panel_has_header(nk_flags flags, const char *title);
231NK_LIB struct nk_vec2 nk_panel_get_padding(const struct nk_style *style, enum nk_panel_type type);
232NK_LIB float nk_panel_get_border(const struct nk_style *style, nk_flags flags, enum nk_panel_type type);
233NK_LIB struct nk_color nk_panel_get_border_color(const struct nk_style *style, enum nk_panel_type type);
234NK_LIB nk_bool nk_panel_is_sub(enum nk_panel_type type);
235NK_LIB nk_bool nk_panel_is_nonblock(enum nk_panel_type type);
236NK_LIB nk_bool nk_panel_begin(struct nk_context *ctx, const char *title, enum nk_panel_type panel_type);
237NK_LIB void nk_panel_end(struct nk_context *ctx);
238
239/* layout */
240NK_LIB float nk_layout_row_calculate_usable_space(const struct nk_style *style, enum nk_panel_type type, float total_space, int columns);
241NK_LIB void nk_panel_layout(const struct nk_context *ctx, struct nk_window *win, float height, int cols);
242NK_LIB void nk_row_layout(struct nk_context *ctx, enum nk_layout_format fmt, float height, int cols, int width);
243NK_LIB void nk_panel_alloc_row(const struct nk_context *ctx, struct nk_window *win);
244NK_LIB void nk_layout_widget_space(struct nk_rect *bounds, const struct nk_context *ctx, struct nk_window *win, int modify);
245NK_LIB void nk_panel_alloc_space(struct nk_rect *bounds, const struct nk_context *ctx);
246NK_LIB void nk_layout_peek(struct nk_rect *bounds, const struct nk_context *ctx);
247
248/* popup */
249NK_LIB nk_bool nk_nonblock_begin(struct nk_context *ctx, nk_flags flags, struct nk_rect body, struct nk_rect header, enum nk_panel_type panel_type);
250
251/* text */
252struct nk_text {
253 struct nk_vec2 padding;
254 struct nk_color background;
255 struct nk_color text;
256};
257NK_LIB void nk_widget_text(struct nk_command_buffer *o, struct nk_rect b, const char *string, int len, const struct nk_text *t, nk_flags a, const struct nk_user_font *f);
258NK_LIB void nk_widget_text_wrap(struct nk_command_buffer *o, struct nk_rect b, const char *string, int len, const struct nk_text *t, const struct nk_user_font *f);
259
260/* button */
261NK_LIB nk_bool nk_button_behavior(nk_flags *state, struct nk_rect r, const struct nk_input *i, enum nk_button_behavior behavior);
262NK_LIB const struct nk_style_item* nk_draw_button(struct nk_command_buffer *out, const struct nk_rect *bounds, nk_flags state, const struct nk_style_button *style);
263NK_LIB nk_bool nk_do_button(nk_flags *state, struct nk_command_buffer *out, struct nk_rect r, const struct nk_style_button *style, const struct nk_input *in, enum nk_button_behavior behavior, struct nk_rect *content);
264NK_LIB void nk_draw_button_text(struct nk_command_buffer *out, const struct nk_rect *bounds, const struct nk_rect *content, nk_flags state, const struct nk_style_button *style, const char *txt, int len, nk_flags text_alignment, const struct nk_user_font *font);
265NK_LIB nk_bool nk_do_button_text(nk_flags *state, struct nk_command_buffer *out, struct nk_rect bounds, const char *string, int len, nk_flags align, enum nk_button_behavior behavior, const struct nk_style_button *style, const struct nk_input *in, const struct nk_user_font *font);
266NK_LIB void nk_draw_button_symbol(struct nk_command_buffer *out, const struct nk_rect *bounds, const struct nk_rect *content, nk_flags state, const struct nk_style_button *style, enum nk_symbol_type type, const struct nk_user_font *font);
267NK_LIB nk_bool nk_do_button_symbol(nk_flags *state, struct nk_command_buffer *out, struct nk_rect bounds, enum nk_symbol_type symbol, enum nk_button_behavior behavior, const struct nk_style_button *style, const struct nk_input *in, const struct nk_user_font *font);
268NK_LIB void nk_draw_button_image(struct nk_command_buffer *out, const struct nk_rect *bounds, const struct nk_rect *content, nk_flags state, const struct nk_style_button *style, const struct nk_image *img);
269NK_LIB nk_bool nk_do_button_image(nk_flags *state, struct nk_command_buffer *out, struct nk_rect bounds, struct nk_image img, enum nk_button_behavior b, const struct nk_style_button *style, const struct nk_input *in);
270NK_LIB void nk_draw_button_text_symbol(struct nk_command_buffer *out, const struct nk_rect *bounds, const struct nk_rect *label, const struct nk_rect *symbol, nk_flags state, const struct nk_style_button *style, const char *str, int len, enum nk_symbol_type type, const struct nk_user_font *font);
271NK_LIB nk_bool nk_do_button_text_symbol(nk_flags *state, struct nk_command_buffer *out, struct nk_rect bounds, enum nk_symbol_type symbol, const char *str, int len, nk_flags align, enum nk_button_behavior behavior, const struct nk_style_button *style, const struct nk_user_font *font, const struct nk_input *in);
272NK_LIB void nk_draw_button_text_image(struct nk_command_buffer *out, const struct nk_rect *bounds, const struct nk_rect *label, const struct nk_rect *image, nk_flags state, const struct nk_style_button *style, const char *str, int len, const struct nk_user_font *font, const struct nk_image *img);
273NK_LIB nk_bool nk_do_button_text_image(nk_flags *state, struct nk_command_buffer *out, struct nk_rect bounds, struct nk_image img, const char* str, int len, nk_flags align, enum nk_button_behavior behavior, const struct nk_style_button *style, const struct nk_user_font *font, const struct nk_input *in);
274
275/* toggle */
276enum nk_toggle_type {
277 NK_TOGGLE_CHECK,
278 NK_TOGGLE_OPTION
279};
280NK_LIB nk_bool nk_toggle_behavior(const struct nk_input *in, struct nk_rect select, nk_flags *state, nk_bool active);
281NK_LIB void nk_draw_checkbox(struct nk_command_buffer *out, nk_flags state, const struct nk_style_toggle *style, nk_bool active, const struct nk_rect *label, const struct nk_rect *selector, const struct nk_rect *cursors, const char *string, int len, const struct nk_user_font *font, nk_flags text_alignment);
282NK_LIB void nk_draw_option(struct nk_command_buffer *out, nk_flags state, const struct nk_style_toggle *style, nk_bool active, const struct nk_rect *label, const struct nk_rect *selector, const struct nk_rect *cursors, const char *string, int len, const struct nk_user_font *font, nk_flags text_alignment);
283NK_LIB nk_bool nk_do_toggle(nk_flags *state, struct nk_command_buffer *out, struct nk_rect r, nk_bool *active, const char *str, int len, enum nk_toggle_type type, const struct nk_style_toggle *style, const struct nk_input *in, const struct nk_user_font *font, nk_flags widget_alignment, nk_flags text_alignment);
284
285/* progress */
286NK_LIB nk_size nk_progress_behavior(nk_flags *state, struct nk_input *in, struct nk_rect r, struct nk_rect cursor, nk_size max, nk_size value, nk_bool modifiable);
287NK_LIB void nk_draw_progress(struct nk_command_buffer *out, nk_flags state, const struct nk_style_progress *style, const struct nk_rect *bounds, const struct nk_rect *scursor, nk_size value, nk_size max);
288NK_LIB nk_size nk_do_progress(nk_flags *state, struct nk_command_buffer *out, struct nk_rect bounds, nk_size value, nk_size max, nk_bool modifiable, const struct nk_style_progress *style, struct nk_input *in);
289
290/* slider */
291NK_LIB float nk_slider_behavior(nk_flags *state, struct nk_rect *logical_cursor, struct nk_rect *visual_cursor, struct nk_input *in, struct nk_rect bounds, float slider_min, float slider_max, float slider_value, float slider_step, float slider_steps);
292NK_LIB void nk_draw_slider(struct nk_command_buffer *out, nk_flags state, const struct nk_style_slider *style, const struct nk_rect *bounds, const struct nk_rect *visual_cursor, float min, float value, float max);
293NK_LIB float nk_do_slider(nk_flags *state, struct nk_command_buffer *out, struct nk_rect bounds, float min, float val, float max, float step, const struct nk_style_slider *style, struct nk_input *in, const struct nk_user_font *font);
294
295/* scrollbar */
296NK_LIB float nk_scrollbar_behavior(nk_flags *state, struct nk_input *in, int has_scrolling, const struct nk_rect *scroll, const struct nk_rect *cursor, const struct nk_rect *empty0, const struct nk_rect *empty1, float scroll_offset, float target, float scroll_step, enum nk_orientation o);
297NK_LIB void nk_draw_scrollbar(struct nk_command_buffer *out, nk_flags state, const struct nk_style_scrollbar *style, const struct nk_rect *bounds, const struct nk_rect *scroll);
298NK_LIB float nk_do_scrollbarv(nk_flags *state, struct nk_command_buffer *out, struct nk_rect scroll, int has_scrolling, float offset, float target, float step, float button_pixel_inc, const struct nk_style_scrollbar *style, struct nk_input *in, const struct nk_user_font *font);
299NK_LIB float nk_do_scrollbarh(nk_flags *state, struct nk_command_buffer *out, struct nk_rect scroll, int has_scrolling, float offset, float target, float step, float button_pixel_inc, const struct nk_style_scrollbar *style, struct nk_input *in, const struct nk_user_font *font);
300
301/* selectable */
302NK_LIB void nk_draw_selectable(struct nk_command_buffer *out, nk_flags state, const struct nk_style_selectable *style, nk_bool active, const struct nk_rect *bounds, const struct nk_rect *icon, const struct nk_image *img, enum nk_symbol_type sym, const char *string, int len, nk_flags align, const struct nk_user_font *font);
303NK_LIB nk_bool nk_do_selectable(nk_flags *state, struct nk_command_buffer *out, struct nk_rect bounds, const char *str, int len, nk_flags align, nk_bool *value, const struct nk_style_selectable *style, const struct nk_input *in, const struct nk_user_font *font);
304NK_LIB nk_bool nk_do_selectable_image(nk_flags *state, struct nk_command_buffer *out, struct nk_rect bounds, const char *str, int len, nk_flags align, nk_bool *value, const struct nk_image *img, const struct nk_style_selectable *style, const struct nk_input *in, const struct nk_user_font *font);
305
306/* edit */
307NK_LIB void nk_edit_draw_text(struct nk_command_buffer *out, const struct nk_style_edit *style, float pos_x, float pos_y, float x_offset, const char *text, int byte_len, float row_height, const struct nk_user_font *font, struct nk_color background, struct nk_color foreground, nk_bool is_selected);
308NK_LIB nk_flags nk_do_edit(nk_flags *state, struct nk_command_buffer *out, struct nk_rect bounds, nk_flags flags, nk_plugin_filter filter, struct nk_text_edit *edit, const struct nk_style_edit *style, struct nk_input *in, const struct nk_user_font *font);
309
310/* color-picker */
311NK_LIB nk_bool nk_color_picker_behavior(nk_flags *state, const struct nk_rect *bounds, const struct nk_rect *matrix, const struct nk_rect *hue_bar, const struct nk_rect *alpha_bar, struct nk_colorf *color, const struct nk_input *in);
312NK_LIB void nk_draw_color_picker(struct nk_command_buffer *o, const struct nk_rect *matrix, const struct nk_rect *hue_bar, const struct nk_rect *alpha_bar, struct nk_colorf col);
313NK_LIB nk_bool nk_do_color_picker(nk_flags *state, struct nk_command_buffer *out, struct nk_colorf *col, enum nk_color_format fmt, struct nk_rect bounds, struct nk_vec2 padding, const struct nk_input *in, const struct nk_user_font *font);
314
315/* property */
316enum nk_property_status {
317 NK_PROPERTY_DEFAULT,
318 NK_PROPERTY_EDIT,
319 NK_PROPERTY_DRAG
320};
321enum nk_property_filter {
322 NK_FILTER_INT,
323 NK_FILTER_FLOAT
324};
325enum nk_property_kind {
326 NK_PROPERTY_INT,
327 NK_PROPERTY_FLOAT,
328 NK_PROPERTY_DOUBLE
329};
331 int i;
332 float f;
333 double d;
334};
336 enum nk_property_kind kind;
337 union nk_property value;
338 union nk_property min_value;
339 union nk_property max_value;
340 union nk_property step;
341};
342NK_LIB struct nk_property_variant nk_property_variant_int(int value, int min_value, int max_value, int step);
343NK_LIB struct nk_property_variant nk_property_variant_float(float value, float min_value, float max_value, float step);
344NK_LIB struct nk_property_variant nk_property_variant_double(double value, double min_value, double max_value, double step);
345
346NK_LIB void nk_drag_behavior(nk_flags *state, const struct nk_input *in, struct nk_rect drag, struct nk_property_variant *variant, float inc_per_pixel);
347NK_LIB void nk_property_behavior(nk_flags *ws, const struct nk_input *in, struct nk_rect property, struct nk_rect label, struct nk_rect edit, struct nk_rect empty, int *state, struct nk_property_variant *variant, float inc_per_pixel);
348NK_LIB void nk_draw_property(struct nk_command_buffer *out, const struct nk_style_property *style, const struct nk_rect *bounds, const struct nk_rect *label, nk_flags state, const char *name, int len, const struct nk_user_font *font);
349NK_LIB void nk_do_property(nk_flags *ws, struct nk_command_buffer *out, struct nk_rect property, const char *name, struct nk_property_variant *variant, float inc_per_pixel, char *buffer, int *len, int *state, int *cursor, int *select_begin, int *select_end, const struct nk_style_property *style, enum nk_property_filter filter, struct nk_input *in, const struct nk_user_font *font, struct nk_text_edit *text_edit, enum nk_button_behavior behavior);
350NK_LIB void nk_property(struct nk_context *ctx, const char *name, struct nk_property_variant *variant, float inc_per_pixel, const enum nk_property_filter filter);
351
352#ifdef NK_INCLUDE_FONT_BAKING
353
359#ifndef NK_NO_STB_RECT_PACK_IMPLEMENTATION
360#define STB_RECT_PACK_IMPLEMENTATION
361#endif /* NK_NO_STB_RECT_PACK_IMPLEMENTATION */
362
368#ifndef NK_NO_STB_TRUETYPE_IMPLEMENTATION
369#define STB_TRUETYPE_IMPLEMENTATION
370#endif /* NK_NO_STB_TRUETYPE_IMPLEMENTATION */
371
372/* Allow consumer to define own STBTT_malloc/STBTT_free, and use the font atlas' allocator otherwise */
373#ifndef STBTT_malloc
374static void*
375nk_stbtt_malloc(nk_size size, void *user_data) {
376 struct nk_allocator *alloc = (struct nk_allocator *) user_data;
377 return alloc->alloc(alloc->userdata, 0, size);
378}
379
380static void
381nk_stbtt_free(void *ptr, void *user_data) {
382 struct nk_allocator *alloc = (struct nk_allocator *) user_data;
383 alloc->free(alloc->userdata, ptr);
384}
385
386#define STBTT_malloc(x,u) nk_stbtt_malloc(x,u)
387#define STBTT_free(x,u) nk_stbtt_free(x,u)
388
389#endif /* STBTT_malloc */
390
391#endif /* NK_INCLUDE_FONT_BAKING */
392
393#endif