213 #ifndef NK_SINGLE_FILE 214 #define NK_SINGLE_FILE 217 #ifndef NK_NUKLEAR_H_ 218 #define NK_NUKLEAR_H_ 230 #define NK_UNDEFINED (-1.0f) 231 #define NK_UTF_INVALID 0xFFFD 232 #define NK_UTF_SIZE 4 234 #define NK_INPUT_MAX 16 236 #ifndef NK_MAX_NUMBER_BUFFER 237 #define NK_MAX_NUMBER_BUFFER 64 239 #ifndef NK_SCROLLBAR_HIDING_TIMEOUT 240 #define NK_SCROLLBAR_HIDING_TIMEOUT 4.0f 251 #if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199409L)) 252 #define NK_API static inline 253 #elif defined(__cplusplus) 254 #define NK_API static inline 256 #define NK_API static 259 #define NK_API extern 263 #ifdef NK_SINGLE_FILE 264 #define NK_LIB static 266 #define NK_LIB extern 270 #define NK_INTERN static 271 #define NK_STORAGE static 272 #define NK_GLOBAL static 274 #define NK_FLAG(x) (1 << (x)) 275 #define NK_STRINGIFY(x) #x 276 #define NK_MACRO_STRINGIFY(x) NK_STRINGIFY(x) 277 #define NK_STRING_JOIN_IMMEDIATE(arg1, arg2) arg1 ## arg2 278 #define NK_STRING_JOIN_DELAY(arg1, arg2) NK_STRING_JOIN_IMMEDIATE(arg1, arg2) 279 #define NK_STRING_JOIN(arg1, arg2) NK_STRING_JOIN_DELAY(arg1, arg2) 282 #define NK_UNIQUE_NAME(name) NK_STRING_JOIN(name,__COUNTER__) 284 #define NK_UNIQUE_NAME(name) NK_STRING_JOIN(name,__LINE__) 287 #ifndef NK_STATIC_ASSERT 288 #define NK_STATIC_ASSERT(exp) typedef char NK_UNIQUE_NAME(_dummy_array)[(exp)?1:-1] 293 #define NK_FILE_LINE __FILE__ ":" NK_MACRO_STRINGIFY(__COUNTER__) 295 #define NK_FILE_LINE __FILE__ ":" NK_MACRO_STRINGIFY(__LINE__) 299 #define NK_MIN(a,b) ((a) < (b) ? (a) : (b)) 300 #define NK_MAX(a,b) ((a) < (b) ? (b) : (a)) 301 #define NK_CLAMP(i,v,x) (NK_MAX(NK_MIN(v,x), i)) 303 #ifdef NK_INCLUDE_STANDARD_VARARGS 304 #if defined(_MSC_VER) && (_MSC_VER >= 1600) 306 #define NK_PRINTF_FORMAT_STRING _Printf_format_string_ 308 #define NK_PRINTF_FORMAT_STRING 310 #if defined(__GNUC__) 311 #define NK_PRINTF_VARARG_FUNC(fmtargnumber) __attribute__((format(__printf__, fmtargnumber, fmtargnumber+1))) 312 #define NK_PRINTF_VALIST_FUNC(fmtargnumber) __attribute__((format(__printf__, fmtargnumber, 0))) 314 #define NK_PRINTF_VARARG_FUNC(fmtargnumber) 315 #define NK_PRINTF_VALIST_FUNC(fmtargnumber) 327 #ifdef NK_INCLUDE_FIXED_TYPES 329 #define NK_INT8 int8_t 330 #define NK_UINT8 uint8_t 331 #define NK_INT16 int16_t 332 #define NK_UINT16 uint16_t 333 #define NK_INT32 int32_t 334 #define NK_UINT32 uint32_t 335 #define NK_SIZE_TYPE uintptr_t 336 #define NK_POINTER_TYPE uintptr_t 342 #define NK_UINT8 unsigned char 345 #define NK_INT16 signed short 348 #define NK_UINT16 unsigned short 351 #if defined(_MSC_VER) 352 #define NK_INT32 __int32 354 #define NK_INT32 signed int 358 #if defined(_MSC_VER) 359 #define NK_UINT32 unsigned __int32 361 #define NK_UINT32 unsigned int 365 #if defined(_WIN64) && defined(_MSC_VER) 366 #define NK_SIZE_TYPE unsigned __int64 367 #elif (defined(_WIN32) || defined(WIN32)) && defined(_MSC_VER) 368 #define NK_SIZE_TYPE unsigned __int32 369 #elif defined(__GNUC__) || defined(__clang__) 370 #if defined(__x86_64__) || defined(__ppc64__) 371 #define NK_SIZE_TYPE unsigned long 373 #define NK_SIZE_TYPE unsigned int 376 #define NK_SIZE_TYPE unsigned long 379 #ifndef NK_POINTER_TYPE 380 #if defined(_WIN64) && defined(_MSC_VER) 381 #define NK_POINTER_TYPE unsigned __int64 382 #elif (defined(_WIN32) || defined(WIN32)) && defined(_MSC_VER) 383 #define NK_POINTER_TYPE unsigned __int32 384 #elif defined(__GNUC__) || defined(__clang__) 385 #if defined(__x86_64__) || defined(__ppc64__) 386 #define NK_POINTER_TYPE unsigned long 388 #define NK_POINTER_TYPE unsigned int 391 #define NK_POINTER_TYPE unsigned long 431 struct nk_draw_command;
439 struct nk_draw_vertex_layout_element;
443 struct nk_style_slide;
545 #ifdef NK_INCLUDE_DEFAULT_ALLOCATOR 652 #ifdef NK_INCLUDE_COMMAND_USERDATA 1202 #define nk_foreach(c, ctx) for((c) = nk__begin(ctx); (c) != 0; (c) = nk__next(ctx,c)) 1203 #ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT 1279 NK_API const struct nk_draw_command* nk__draw_next(
const struct nk_draw_command*,
const struct nk_buffer*,
const struct nk_context*);
1293 #define nk_draw_foreach(cmd,ctx, b) for((cmd)=nk__draw_begin(ctx, b); (cmd)!=0; (cmd)=nk__draw_next(cmd, b, ctx)) 2784 #define nk_tree_push(ctx, type, title, state) nk_tree_push_hashed(ctx, type, title, state, NK_FILE_LINE,nk_strlen(NK_FILE_LINE),__LINE__) 2801 #define nk_tree_push_id(ctx, type, title, state, id) nk_tree_push_hashed(ctx, type, title, state, NK_FILE_LINE,nk_strlen(NK_FILE_LINE),id) 2844 #define nk_tree_image_push(ctx, type, img, title, state) nk_tree_image_push_hashed(ctx, type, img, title, state, NK_FILE_LINE,nk_strlen(NK_FILE_LINE),__LINE__) 2864 #define nk_tree_image_push_id(ctx, type, img, title, state, id) nk_tree_image_push_hashed(ctx, type, img, title, state, NK_FILE_LINE,nk_strlen(NK_FILE_LINE),id) 2942 #define nk_tree_element_push(ctx, type, title, state, sel) nk_tree_element_push_hashed(ctx, type, title, state, sel, NK_FILE_LINE,nk_strlen(NK_FILE_LINE),__LINE__) 2943 #define nk_tree_element_push_id(ctx, type, title, state, sel, id) nk_tree_element_push_hashed(ctx, type, title, state, sel, NK_FILE_LINE,nk_strlen(NK_FILE_LINE),id) 3023 #ifdef NK_INCLUDE_STANDARD_VARARGS 3024 NK_API void nk_labelf(
struct nk_context*, nk_flags, NK_PRINTF_FORMAT_STRING
const char*, ...) NK_PRINTF_VARARG_FUNC(3);
3025 NK_API void nk_labelf_colored(struct
nk_context*, nk_flags, struct
nk_color, NK_PRINTF_FORMAT_STRING const
char*,...) NK_PRINTF_VARARG_FUNC(4);
3026 NK_API void nk_labelf_wrap(struct nk_context*, NK_PRINTF_FORMAT_STRING const
char*,...) NK_PRINTF_VARARG_FUNC(2);
3027 NK_API void nk_labelf_colored_wrap(struct nk_context*, struct nk_color, NK_PRINTF_FORMAT_STRING const
char*,...) NK_PRINTF_VARARG_FUNC(3);
3028 NK_API void nk_labelfv(struct nk_context*, nk_flags, NK_PRINTF_FORMAT_STRING const
char*, va_list) NK_PRINTF_VALIST_FUNC(3);
3029 NK_API void nk_labelfv_colored(struct nk_context*, nk_flags, struct nk_color, NK_PRINTF_FORMAT_STRING const
char*, va_list) NK_PRINTF_VALIST_FUNC(4);
3030 NK_API void nk_labelfv_wrap(struct nk_context*, NK_PRINTF_FORMAT_STRING const
char*, va_list) NK_PRINTF_VALIST_FUNC(2);
3031 NK_API void nk_labelfv_colored_wrap(struct nk_context*, struct nk_color, NK_PRINTF_FORMAT_STRING const
char*, va_list) NK_PRINTF_VALIST_FUNC(3);
3032 NK_API void nk_value_bool(struct nk_context*, const
char *prefix,
int);
3033 NK_API void nk_value_int(struct nk_context*, const
char *prefix,
int);
3034 NK_API void nk_value_uint(struct nk_context*, const
char *prefix,
unsigned int);
3035 NK_API void nk_value_float(struct nk_context*, const
char *prefix,
float);
3036 NK_API void nk_value_color_byte(struct nk_context*, const
char *prefix, struct nk_color);
3037 NK_API void nk_value_color_float(struct nk_context*, const
char *prefix, struct nk_color);
3038 NK_API void nk_value_color_hex(struct nk_context*, const
char *prefix, struct nk_color);
3120 NK_API int nk_progress(
struct nk_context*, nk_size *cur, nk_size max,
int modifyable);
3121 NK_API nk_size
nk_prog(
struct nk_context*, nk_size cur, nk_size max,
int modifyable);
3337 NK_API double nk_propertyd(
struct nk_context*,
const char *
name,
double min,
double val,
double max,
double step,
float inc_per_pixel);
3453 #ifdef NK_INCLUDE_STANDARD_VARARGS 3454 NK_API void nk_tooltipf(
struct nk_context*, NK_PRINTF_FORMAT_STRING
const char*, ...) NK_PRINTF_VARARG_FUNC(2);
3455 NK_API void nk_tooltipfv(struct nk_context*, NK_PRINTF_FORMAT_STRING const
char*, va_list) NK_PRINTF_VALIST_FUNC(2);
3612 NK_API void nk_color_hsva_f(
float *out_h,
float *out_s,
float *out_v,
float *out_a,
struct nk_color);
3821 struct nk_user_font_glyph;
3824 struct nk_user_font_glyph *glyph,
3825 nk_rune codepoint, nk_rune next_codepoint);
3827 #if defined(NK_INCLUDE_VERTEX_BUFFER_OUTPUT) || defined(NK_INCLUDE_SOFTWARE_FONT) 3828 struct nk_user_font_glyph {
3847 #ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT 3855 #ifdef NK_INCLUDE_FONT_BAKING 3856 enum nk_font_coord_type {
3862 struct nk_baked_font {
3865 float ascent, descent;
3867 nk_rune glyph_offset;
3869 nk_rune glyph_count;
3871 const nk_rune *ranges;
3875 struct nk_font_config {
3876 struct nk_font_config *
next;
3885 unsigned char ttf_data_owned_by_atlas;
3887 unsigned char merge_mode;
3889 unsigned char pixel_snap;
3891 unsigned char oversample_v, oversample_h;
3893 unsigned char padding[3];
3897 enum nk_font_coord_type coord_type;
3901 const nk_rune *
range;
3903 struct nk_baked_font *
font;
3905 nk_rune fallback_glyph;
3907 struct nk_font_config *
n;
3908 struct nk_font_config *
p;
3911 struct nk_font_glyph {
3919 struct nk_font *
next;
3921 struct nk_baked_font info;
3923 struct nk_font_glyph *glyphs;
3924 const struct nk_font_glyph *fallback;
3925 nk_rune fallback_codepoint;
3927 struct nk_font_config *
config;
3930 enum nk_font_atlas_format {
3931 NK_FONT_ATLAS_ALPHA8,
3932 NK_FONT_ATLAS_RGBA32
3935 struct nk_font_atlas {
3944 struct nk_cursor cursors[NK_CURSOR_COUNT];
3947 struct nk_font_glyph *glyphs;
3948 struct nk_font *default_font;
3949 struct nk_font *fonts;
3950 struct nk_font_config *
config;
3955 NK_API const nk_rune *nk_font_default_glyph_ranges(
void);
3956 NK_API const nk_rune *nk_font_chinese_glyph_ranges(
void);
3957 NK_API const nk_rune *nk_font_cyrillic_glyph_ranges(
void);
3958 NK_API const nk_rune *nk_font_korean_glyph_ranges(
void);
3960 #ifdef NK_INCLUDE_DEFAULT_ALLOCATOR 3961 NK_API void nk_font_atlas_init_default(
struct nk_font_atlas*);
3965 NK_API void nk_font_atlas_begin(
struct nk_font_atlas*);
3966 NK_API struct nk_font_config nk_font_config(float pixel_height);
3967 NK_API struct nk_font *nk_font_atlas_add(
struct nk_font_atlas*,
const struct nk_font_config*);
3968 #ifdef NK_INCLUDE_DEFAULT_FONT 3969 NK_API struct nk_font* nk_font_atlas_add_default(
struct nk_font_atlas*,
float height,
const struct nk_font_config*);
3971 NK_API struct nk_font* nk_font_atlas_add_from_memory(
struct nk_font_atlas *atlas,
void *
memory, nk_size
size,
float height,
const struct nk_font_config *
config);
3972 #ifdef NK_INCLUDE_STANDARD_IO 3973 NK_API struct nk_font* nk_font_atlas_add_from_file(
struct nk_font_atlas *atlas,
const char *
file_path,
float height,
const struct nk_font_config*);
3975 NK_API struct nk_font *nk_font_atlas_add_compressed(
struct nk_font_atlas*,
void *memory, nk_size size,
float height,
const struct nk_font_config*);
3976 NK_API struct nk_font* nk_font_atlas_add_compressed_base85(
struct nk_font_atlas*,
const char *
data,
float height,
const struct nk_font_config *config);
3977 NK_API const void* nk_font_atlas_bake(
struct nk_font_atlas*,
int *
width,
int *height,
enum nk_font_atlas_format);
3979 NK_API const struct nk_font_glyph* nk_font_find_glyph(
struct nk_font*, nk_rune unicode);
3980 NK_API void nk_font_atlas_cleanup(
struct nk_font_atlas *atlas);
3981 NK_API void nk_font_atlas_clear(
struct nk_font_atlas*);
4065 #ifdef NK_INCLUDE_DEFAULT_ALLOCATOR 4095 #ifdef NK_INCLUDE_DEFAULT_ALLOCATOR 4164 #ifndef NK_TEXTEDIT_UNDOSTATECOUNT 4165 #define NK_TEXTEDIT_UNDOSTATECOUNT 99 4168 #ifndef NK_TEXTEDIT_UNDOCHARCOUNT 4169 #define NK_TEXTEDIT_UNDOCHARCOUNT 999 4236 #ifdef NK_INCLUDE_DEFAULT_ALLOCATOR 4326 #ifdef NK_INCLUDE_COMMAND_USERDATA 4351 struct nk_color color;
4360 struct nk_color color;
4368 struct nk_color color;
4387 struct nk_color color;
4395 struct nk_color color;
4403 struct nk_color color;
4410 struct nk_color color;
4419 struct nk_color color;
4427 struct nk_color color;
4432 struct nk_color color;
4440 struct nk_color color;
4447 struct nk_color color;
4462 unsigned short w,
unsigned short h, nk_handle callback_data);
4474 struct nk_color background;
4475 struct nk_color foreground;
4498 NK_API void nk_stroke_curve(
struct nk_command_buffer*,
float,
float,
float,
float,
float,
float,
float,
float,
float line_thickness,
struct nk_color);
4577 #ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT 4591 typedef nk_ushort nk_draw_index;
4592 enum nk_draw_list_stroke {
4595 NK_STROKE_CLOSED = nk_true
4599 enum nk_draw_vertex_layout_attribute {
4603 NK_VERTEX_ATTRIBUTE_COUNT
4606 enum nk_draw_vertex_layout_format {
4616 NK_FORMAT_COLOR_BEGIN,
4617 NK_FORMAT_R8G8B8 = NK_FORMAT_COLOR_BEGIN,
4618 NK_FORMAT_R16G15B16,
4619 NK_FORMAT_R32G32B32,
4623 NK_FORMAT_R16G15B16A16,
4624 NK_FORMAT_R32G32B32A32,
4625 NK_FORMAT_R32G32B32A32_FLOAT,
4626 NK_FORMAT_R32G32B32A32_DOUBLE,
4630 NK_FORMAT_COLOR_END = NK_FORMAT_RGBA32,
4634 #define NK_VERTEX_LAYOUT_END NK_VERTEX_ATTRIBUTE_COUNT,NK_FORMAT_COUNT,0 4635 struct nk_draw_vertex_layout_element {
4636 enum nk_draw_vertex_layout_attribute
attribute;
4637 enum nk_draw_vertex_layout_format
format;
4641 struct nk_draw_command {
4642 unsigned int elem_count;
4648 #ifdef NK_INCLUDE_COMMAND_USERDATA 4653 struct nk_draw_list {
4655 struct nk_vec2 circle_vtx[12];
4662 unsigned int element_count;
4663 unsigned int vertex_count;
4664 unsigned int cmd_count;
4667 unsigned int path_count;
4668 unsigned int path_offset;
4673 #ifdef NK_INCLUDE_COMMAND_USERDATA 4679 NK_API void nk_draw_list_init(
struct nk_draw_list*);
4683 #define nk_draw_list_foreach(cmd, can, b) for((cmd)=nk__draw_list_begin(can, b); (cmd)!=0; (cmd)=nk__draw_list_next(cmd, b, can)) 4684 NK_API const struct nk_draw_command* nk__draw_list_begin(
const struct nk_draw_list*,
const struct nk_buffer*);
4685 NK_API const struct nk_draw_command* nk__draw_list_next(
const struct nk_draw_command*,
const struct nk_buffer*,
const struct nk_draw_list*);
4686 NK_API const struct nk_draw_command* nk__draw_list_end(
const struct nk_draw_list*,
const struct nk_buffer*);
4689 NK_API void nk_draw_list_path_clear(
struct nk_draw_list*);
4690 NK_API void nk_draw_list_path_line_to(
struct nk_draw_list*,
struct nk_vec2 pos);
4691 NK_API void nk_draw_list_path_arc_to_fast(
struct nk_draw_list*,
struct nk_vec2 center,
float radius,
int a_min,
int a_max);
4692 NK_API void nk_draw_list_path_arc_to(
struct nk_draw_list*,
struct nk_vec2 center,
float radius,
float a_min,
float a_max,
unsigned int segments);
4693 NK_API void nk_draw_list_path_rect_to(
struct nk_draw_list*,
struct nk_vec2 a,
struct nk_vec2 b,
float rounding);
4694 NK_API void nk_draw_list_path_curve_to(
struct nk_draw_list*,
struct nk_vec2 p2,
struct nk_vec2 p3,
struct nk_vec2 p4,
unsigned int num_segments);
4695 NK_API void nk_draw_list_path_fill(
struct nk_draw_list*,
struct nk_color);
4696 NK_API void nk_draw_list_path_stroke(
struct nk_draw_list*,
struct nk_color,
enum nk_draw_list_stroke closed,
float thickness);
4700 NK_API void nk_draw_list_stroke_rect(
struct nk_draw_list*,
struct nk_rect rect,
struct nk_color,
float rounding,
float thickness);
4702 NK_API void nk_draw_list_stroke_circle(
struct nk_draw_list*,
struct nk_vec2 center,
float radius,
struct nk_color,
unsigned int segs,
float thickness);
4704 NK_API void nk_draw_list_stroke_poly_line(
struct nk_draw_list*,
const struct nk_vec2 *pnts,
const unsigned int cnt,
struct nk_color,
enum nk_draw_list_stroke,
float thickness,
enum nk_anti_aliasing);
4707 NK_API void nk_draw_list_fill_rect(
struct nk_draw_list*,
struct nk_rect rect,
struct nk_color,
float rounding);
4708 NK_API void nk_draw_list_fill_rect_multi_color(
struct nk_draw_list*,
struct nk_rect rect,
struct nk_color
left,
struct nk_color
top,
struct nk_color right,
struct nk_color
bottom);
4710 NK_API void nk_draw_list_fill_circle(
struct nk_draw_list*,
struct nk_vec2 center,
float radius,
struct nk_color col,
unsigned int segs);
4715 NK_API void nk_draw_list_add_text(
struct nk_draw_list*,
const struct nk_user_font*,
struct nk_rect,
const char *text,
int len,
float font_height,
struct nk_color);
4716 #ifdef NK_INCLUDE_COMMAND_USERDATA 4717 NK_API void nk_draw_list_push_userdata(
struct nk_draw_list*, nk_handle userdata);
4734 struct nk_color color;
4743 struct nk_color color;
4752 struct nk_color border_color;
4755 struct nk_color text_background;
4756 struct nk_color text_normal;
4757 struct nk_color text_hover;
4758 struct nk_color text_active;
4779 struct nk_color border_color;
4786 struct nk_color text_normal;
4787 struct nk_color text_hover;
4788 struct nk_color text_active;
4789 struct nk_color text_background;
4816 struct nk_color text_normal;
4817 struct nk_color text_hover;
4818 struct nk_color text_pressed;
4821 struct nk_color text_normal_active;
4822 struct nk_color text_hover_active;
4823 struct nk_color text_pressed_active;
4824 struct nk_color text_background;
4844 struct nk_color border_color;
4847 struct nk_color bar_normal;
4848 struct nk_color bar_hover;
4849 struct nk_color bar_active;
4850 struct nk_color bar_filled;
4883 struct nk_color border_color;
4889 struct nk_color cursor_border_color;
4909 struct nk_color border_color;
4915 struct nk_color cursor_border_color;
4942 struct nk_color border_color;
4946 struct nk_color cursor_normal;
4947 struct nk_color cursor_hover;
4948 struct nk_color cursor_text_normal;
4949 struct nk_color cursor_text_hover;
4952 struct nk_color text_normal;
4953 struct nk_color text_hover;
4954 struct nk_color text_active;
4957 struct nk_color selected_normal;
4958 struct nk_color selected_hover;
4959 struct nk_color selected_text_normal;
4960 struct nk_color selected_text_hover;
4976 struct nk_color border_color;
4979 struct nk_color label_normal;
4980 struct nk_color label_hover;
4981 struct nk_color label_active;
5005 struct nk_color border_color;
5006 struct nk_color selected_color;
5007 struct nk_color color;
5020 struct nk_color border_color;
5023 struct nk_color label_normal;
5024 struct nk_color label_hover;
5025 struct nk_color label_active;
5028 struct nk_color symbol_normal;
5029 struct nk_color symbol_hover;
5030 struct nk_color symbol_active;
5049 struct nk_color border_color;
5050 struct nk_color text;
5086 struct nk_color label_normal;
5087 struct nk_color label_hover;
5088 struct nk_color label_active;
5100 struct nk_color background;
5102 struct nk_color border_color;
5103 struct nk_color popup_border_color;
5104 struct nk_color combo_border_color;
5105 struct nk_color contextual_border_color;
5106 struct nk_color menu_border_color;
5107 struct nk_color group_border_color;
5108 struct nk_color tooltip_border_color;
5167 #ifndef NK_MAX_LAYOUT_ROW_TEMPLATE_COLUMNS 5168 #define NK_MAX_LAYOUT_ROW_TEMPLATE_COLUMNS 16 5170 #ifndef NK_CHART_MAX_SLOT 5171 #define NK_CHART_MAX_SLOT 4 5192 struct nk_color color;
5193 struct nk_color highlight;
5269 #ifndef NK_WINDOW_MAX_NAME 5270 #define NK_WINDOW_MAX_NAME 64 5382 #ifndef NK_BUTTON_BEHAVIOR_STACK_SIZE 5383 #define NK_BUTTON_BEHAVIOR_STACK_SIZE 8 5386 #ifndef NK_FONT_STACK_SIZE 5387 #define NK_FONT_STACK_SIZE 8 5390 #ifndef NK_STYLE_ITEM_STACK_SIZE 5391 #define NK_STYLE_ITEM_STACK_SIZE 16 5394 #ifndef NK_FLOAT_STACK_SIZE 5395 #define NK_FLOAT_STACK_SIZE 32 5398 #ifndef NK_VECTOR_STACK_SIZE 5399 #define NK_VECTOR_STACK_SIZE 16 5402 #ifndef NK_FLAGS_STACK_SIZE 5403 #define NK_FLAGS_STACK_SIZE 32 5406 #ifndef NK_COLOR_STACK_SIZE 5407 #define NK_COLOR_STACK_SIZE 32 5410 #define NK_CONFIGURATION_STACK_TYPE(prefix, name, type)\ 5411 struct nk_config_stack_##name##_element {\ 5412 prefix##_##type *address;\ 5413 prefix##_##type old_value;\ 5415 #define NK_CONFIG_STACK(type,size)\ 5416 struct nk_config_stack_##type {\ 5418 struct nk_config_stack_##type##_element elements[size];\ 5421 #define nk_float float 5439 struct nk_config_stack_style_item style_items;
5440 struct nk_config_stack_float floats;
5441 struct nk_config_stack_vec2 vectors;
5444 struct nk_config_stack_user_font fonts;
5445 struct nk_config_stack_button_behavior button_behaviors;
5451 #define NK_VALUE_PAGE_CAPACITY \ 5452 (((NK_MAX(sizeof(struct nk_window),sizeof(struct nk_panel)) / sizeof(nk_uint))) / 2) 5505 #ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT 5506 struct nk_draw_list draw_list;
5508 #ifdef NK_INCLUDE_COMMAND_USERDATA 5535 #define NK_PI 3.141592654f 5536 #define NK_UTF_INVALID 0xFFFD 5537 #define NK_MAX_FLOAT_PRECISION 2 5539 #define NK_UNUSED(x) ((void)(x)) 5540 #define NK_SATURATE(x) (NK_MAX(0, NK_MIN(1.0f, x))) 5541 #define NK_LEN(a) (sizeof(a)/sizeof(a)[0]) 5542 #define NK_ABS(a) (((a) < 0) ? -(a) : (a)) 5543 #define NK_BETWEEN(x, a, b) ((a) <= (x) && (x) < (b)) 5544 #define NK_INBOX(px, py, x, y, w, h)\ 5545 (NK_BETWEEN(px,x,x+w) && NK_BETWEEN(py,y,y+h)) 5546 #define NK_INTERSECT(x0, y0, w0, h0, x1, y1, w1, h1) \ 5547 (!(((x1 > (x0 + w0)) || ((x1 + w1) < x0) || (y1 > (y0 + h0)) || (y1 + h1) < y0))) 5548 #define NK_CONTAINS(x, y, w, h, bx, by, bw, bh)\ 5549 (NK_INBOX(x,y, bx, by, bw, bh) && NK_INBOX(x+w,y+h, bx, by, bw, bh)) 5551 #define nk_vec2_sub(a, b) nk_vec2((a).x - (b).x, (a).y - (b).y) 5552 #define nk_vec2_add(a, b) nk_vec2((a).x + (b).x, (a).y + (b).y) 5553 #define nk_vec2_len_sqr(a) ((a).x*(a).x+(a).y*(a).y) 5554 #define nk_vec2_muls(a, t) nk_vec2((a).x * (t), (a).y * (t)) 5556 #define nk_ptr_add(t, p, i) ((t*)((void*)((nk_byte*)(p) + (i)))) 5557 #define nk_ptr_add_const(t, p, i) ((const t*)((const void*)((const nk_byte*)(p) + (i)))) 5558 #define nk_zero_struct(s) nk_zero(&s, sizeof(s)) 5564 #if defined(__PTRDIFF_TYPE__) 5565 # define NK_UINT_TO_PTR(x) ((void*)(__PTRDIFF_TYPE__)(x)) 5566 # define NK_PTR_TO_UINT(x) ((nk_size)(__PTRDIFF_TYPE__)(x)) 5567 #elif !defined(__GNUC__) 5568 # define NK_UINT_TO_PTR(x) ((void*)&((char*)0)[x]) 5569 # define NK_PTR_TO_UINT(x) ((nk_size)(((char*)x)-(char*)0)) 5570 #elif defined(NK_USE_FIXED_TYPES) 5571 # define NK_UINT_TO_PTR(x) ((void*)(uintptr_t)(x)) 5572 # define NK_PTR_TO_UINT(x) ((uintptr_t)(x)) 5574 # define NK_UINT_TO_PTR(x) ((void*)(x)) 5575 # define NK_PTR_TO_UINT(x) ((nk_size)(x)) 5578 #define NK_ALIGN_PTR(x, mask)\ 5579 (NK_UINT_TO_PTR((NK_PTR_TO_UINT((nk_byte*)(x) + (mask-1)) & ~(mask-1)))) 5580 #define NK_ALIGN_PTR_BACK(x, mask)\ 5581 (NK_UINT_TO_PTR((NK_PTR_TO_UINT((nk_byte*)(x)) & ~(mask-1)))) 5583 #define NK_OFFSETOF(st,m) ((nk_ptr)&(((st*)0)->m)) 5584 #define NK_CONTAINER_OF(ptr,type,member)\ 5585 (type*)((void*)((char*)(1 ? (ptr): &((type*)0)->member) - NK_OFFSETOF(type, member))) 5592 template<
typename T>
struct nk_alignof;
5593 template<
typename T,
int size_diff>
struct nk_helper{
enum {
value = size_diff};};
5595 template<
typename T>
struct nk_alignof{
struct Big {
T x;
char c;};
enum {
5597 #define NK_ALIGNOF(t) (nk_alignof<t>::value) 5598 #elif defined(_MSC_VER) 5599 #define NK_ALIGNOF(t) (__alignof(t)) 5601 #define NK_ALIGNOF(t) ((char*)(&((struct {char c; t _h;}*)0)->_h) - (char*)0) 5607 #ifdef NK_IMPLEMENTATION 5609 #ifndef NK_INTERNAL_H 5610 #define NK_INTERNAL_H 5612 #ifndef NK_POOL_DEFAULT_CAPACITY 5613 #define NK_POOL_DEFAULT_CAPACITY 16 5616 #ifndef NK_DEFAULT_COMMAND_BUFFER_SIZE 5617 #define NK_DEFAULT_COMMAND_BUFFER_SIZE (4*1024) 5620 #ifndef NK_BUFFER_DEFAULT_INITIAL_SIZE 5621 #define NK_BUFFER_DEFAULT_INITIAL_SIZE (4*1024) 5625 #ifdef NK_INCLUDE_DEFAULT_ALLOCATOR 5628 #ifdef NK_INCLUDE_STANDARD_IO 5633 #define NK_ASSERT(expr) assert(expr) 5637 #define NK_MEMSET nk_memset 5640 #define NK_MEMCPY nk_memcopy 5643 #define NK_SQRT nk_sqrt 5646 #define NK_SIN nk_sin 5649 #define NK_COS nk_cos 5652 #define NK_STRTOD nk_strtod 5655 #define NK_DTOA nk_dtoa 5658 #define NK_DEFAULT (-1) 5660 #ifndef NK_VSNPRINTF 5665 #if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) ||\ 5666 (defined(__cplusplus) && (__cplusplus >= 201103L)) || \ 5667 (defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200112L)) ||\ 5668 (defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)) ||\ 5669 defined(_ISOC99_SOURCE) || defined(_BSD_SOURCE) 5670 #define NK_VSNPRINTF(s,n,f,a) vsnprintf(s,n,f,a) 5672 #define NK_VSNPRINTF(s,n,f,a) vsprintf(s,f,a) 5676 #define NK_SCHAR_MIN (-127) 5677 #define NK_SCHAR_MAX 127 5678 #define NK_UCHAR_MIN 0 5679 #define NK_UCHAR_MAX 256 5680 #define NK_SSHORT_MIN (-32767) 5681 #define NK_SSHORT_MAX 32767 5682 #define NK_USHORT_MIN 0 5683 #define NK_USHORT_MAX 65535 5684 #define NK_SINT_MIN (-2147483647) 5685 #define NK_SINT_MAX 2147483647 5686 #define NK_UINT_MIN 0 5687 #define NK_UINT_MAX 4294967295u 5702 NK_GLOBAL const struct nk_rect nk_null_rect = {-8192.0f, -8192.0f, 16384, 16384};
5703 #define NK_FLOAT_PRECISION 0.00000000000001 5705 NK_GLOBAL const struct nk_color nk_red = {255,0,0,255};
5706 NK_GLOBAL const struct nk_color nk_green = {0,255,0,255};
5707 NK_GLOBAL const struct nk_color nk_blue = {0,0,255,255};
5708 NK_GLOBAL const struct nk_color nk_white = {255,255,255,255};
5709 NK_GLOBAL const struct nk_color nk_black = {0,0,0,255};
5710 NK_GLOBAL const struct nk_color nk_yellow = {255,255,0,255};
5713 #define nk_widget_state_reset(s)\ 5714 if ((*(s)) & NK_WIDGET_STATE_MODIFIED)\ 5715 (*(s)) = NK_WIDGET_STATE_INACTIVE|NK_WIDGET_STATE_MODIFIED;\ 5716 else (*(s)) = NK_WIDGET_STATE_INACTIVE; 5719 NK_LIB float nk_inv_sqrt(
float n);
5720 NK_LIB float nk_sqrt(
float x);
5723 NK_LIB nk_uint nk_round_up_pow2(nk_uint
v);
5727 NK_LIB double nk_pow(
double x,
int n);
5728 NK_LIB int nk_ifloord(
double x);
5729 NK_LIB int nk_ifloorf(
float x);
5730 NK_LIB int nk_iceilf(
float x);
5731 NK_LIB int nk_log10(
double n);
5734 enum {NK_DO_NOT_STOP_ON_NEW_LINE, NK_STOP_ON_NEW_LINE};
5735 NK_LIB int nk_is_lower(
int c);
5736 NK_LIB int nk_is_upper(
int c);
5737 NK_LIB int nk_to_upper(
int c);
5738 NK_LIB int nk_to_lower(
int c);
5739 NK_LIB void* nk_memcopy(
void *
dst,
const void *
src, nk_size
n);
5740 NK_LIB void nk_memset(
void *ptr,
int c0, nk_size
size);
5741 NK_LIB void nk_zero(
void *ptr, nk_size
size);
5742 NK_LIB char *nk_itoa(
char *
s,
long n);
5743 NK_LIB int nk_string_float_limit(
char *
string,
int prec);
5744 NK_LIB char *nk_dtoa(
char *
s,
double n);
5745 NK_LIB int nk_text_clamp(
const struct nk_user_font *
font,
const char *text,
int text_len,
float space,
int *glyphs,
float *text_width, nk_rune *sep_list,
int sep_count);
5746 NK_LIB struct nk_vec2 nk_text_calculate_text_bounds(const struct
nk_user_font *
font,
const char *
begin,
int byte_len,
float row_height,
const char **remaining,
struct nk_vec2 *out_offset,
int *glyphs,
int op);
5747 #ifdef NK_INCLUDE_STANDARD_VARARGS 5748 NK_LIB int nk_strfmt(
char *
buf,
int buf_size,
const char *
fmt, va_list
args);
5750 #ifdef NK_INCLUDE_STANDARD_IO 5755 #ifdef NK_INCLUDE_DEFAULT_ALLOCATOR 5756 NK_LIB void* nk_malloc(nk_handle unused,
void *old,nk_size
size);
5757 NK_LIB void nk_mfree(nk_handle unused,
void *ptr);
5776 NK_LIB void nk_build(
struct nk_context *
ctx);
5785 enum nk_window_insert_location {
5789 NK_LIB void *nk_create_window(
struct nk_context *
ctx);
5793 NK_LIB void nk_insert_window(
struct nk_context *
ctx,
struct nk_window *win,
enum nk_window_insert_location loc);
5815 NK_LIB void *nk_create_panel(
struct nk_context *
ctx);
5816 NK_LIB void nk_free_panel(
struct nk_context*,
struct nk_panel *pan);
5817 NK_LIB int nk_panel_has_header(nk_flags
flags,
const char *title);
5824 NK_LIB void nk_panel_end(
struct nk_context *
ctx);
5831 NK_LIB void nk_layout_widget_space(
struct nk_rect *bounds,
const struct nk_context *
ctx,
struct nk_window *win,
int modify);
5832 NK_LIB void nk_panel_alloc_space(
struct nk_rect *bounds,
const struct nk_context *
ctx);
5833 NK_LIB void nk_layout_peek(
struct nk_rect *bounds,
struct nk_context *
ctx);
5841 struct nk_color background;
5842 struct nk_color text;
5858 NK_LIB int nk_do_button_text_symbol(nk_flags *
state,
struct nk_command_buffer *
out,
struct nk_rect bounds,
enum nk_symbol_type symbol,
const char *
str,
int len, nk_flags
align,
enum nk_button_behavior behavior,
const struct nk_style_button *style,
const struct nk_user_font *font,
const struct nk_input *
in);
5860 NK_LIB int nk_do_button_text_image(nk_flags *
state,
struct nk_command_buffer *
out,
struct nk_rect bounds,
struct nk_image img,
const char*
str,
int len, nk_flags
align,
enum nk_button_behavior behavior,
const struct nk_style_button *style,
const struct nk_user_font *font,
const struct nk_input *
in);
5863 enum nk_toggle_type {
5878 NK_LIB float nk_slider_behavior(nk_flags *
state,
struct nk_rect *logical_cursor,
struct nk_rect *visual_cursor,
struct nk_input *
in,
struct nk_rect bounds,
float slider_min,
float slider_max,
float slider_value,
float slider_step,
float slider_steps);
5883 NK_LIB float nk_scrollbar_behavior(nk_flags *
state,
struct nk_input *
in,
int has_scrolling,
const struct nk_rect *scroll,
const struct nk_rect *cursor,
const struct nk_rect *empty0,
const struct nk_rect *empty1,
float scroll_offset,
float target,
float scroll_step,
enum nk_orientation o);
5885 NK_LIB float nk_do_scrollbarv(nk_flags *
state,
struct nk_command_buffer *
out,
struct nk_rect scroll,
int has_scrolling,
float offset,
float target,
float step,
float button_pixel_inc,
const struct nk_style_scrollbar *style,
struct nk_input *
in,
const struct nk_user_font *font);
5886 NK_LIB float nk_do_scrollbarh(nk_flags *
state,
struct nk_command_buffer *
out,
struct nk_rect scroll,
int has_scrolling,
float offset,
float target,
float step,
float button_pixel_inc,
const struct nk_style_scrollbar *style,
struct nk_input *
in,
const struct nk_user_font *font);
5889 NK_LIB void nk_draw_selectable(
struct nk_command_buffer *
out, nk_flags
state,
const struct nk_style_selectable *style,
int active,
const struct nk_rect *bounds,
const struct nk_rect *icon,
const struct nk_image *
img,
enum nk_symbol_type sym,
const char *
string,
int len, nk_flags
align,
const struct nk_user_font *font);
5891 NK_LIB int nk_do_selectable_image(nk_flags *
state,
struct nk_command_buffer *
out,
struct nk_rect bounds,
const char *
str,
int len, nk_flags
align,
int *
value,
const struct nk_image *
img,
const struct nk_style_selectable *style,
const struct nk_input *
in,
const struct nk_user_font *font);
5894 NK_LIB void nk_edit_draw_text(
struct nk_command_buffer *
out,
const struct nk_style_edit *style,
float pos_x,
float pos_y,
float x_offset,
const char *text,
int byte_len,
float row_height,
const struct nk_user_font *font,
struct nk_color background,
struct nk_color foreground,
int is_selected);
5903 enum nk_property_status {
5904 NK_PROPERTY_DEFAULT,
5908 enum nk_property_filter {
5912 enum nk_property_kind {
5922 struct nk_property_variant {
5923 enum nk_property_kind kind;
5924 union nk_property
value;
5925 union nk_property min_value;
5926 union nk_property max_value;
5927 union nk_property step;
5929 NK_LIB struct nk_property_variant nk_property_variant_int(int
value, int min_value, int max_value, int step);
5930 NK_LIB struct nk_property_variant nk_property_variant_float(float
value, float min_value, float max_value, float step);
5931 NK_LIB struct nk_property_variant nk_property_variant_double(double
value, double min_value, double max_value, double step);
5933 NK_LIB void nk_drag_behavior(nk_flags *
state,
const struct nk_input *
in,
struct nk_rect drag,
struct nk_property_variant *variant,
float inc_per_pixel);
5936 NK_LIB void nk_do_property(nk_flags *ws,
struct nk_command_buffer *
out,
struct nk_rect property,
const char *
name,
struct nk_property_variant *variant,
float inc_per_pixel,
char *
buffer,
int *
len,
int *
state,
int *cursor,
int *select_begin,
int *select_end,
const struct nk_style_property *style,
enum nk_property_filter
filter,
struct nk_input *
in,
const struct nk_user_font *font,
struct nk_text_edit *text_edit,
enum nk_button_behavior behavior);
5937 NK_LIB void nk_property(
struct nk_context *
ctx,
const char *
name,
struct nk_property_variant *variant,
float inc_per_pixel,
const enum nk_property_filter
filter);
5978 nk_inv_sqrt(
float n)
5981 const float threehalfs = 1.5f;
5982 union {nk_uint
i;
float f;} conv = {0};
5985 conv.i = 0x5f375A84 - (conv.i >> 1);
5986 conv.f = conv.f * (threehalfs - (x2 * conv.f * conv.f));
5992 return x * nk_inv_sqrt(x);
5997 NK_STORAGE const float a0 = +1.91059300966915117e-31
f;
5998 NK_STORAGE const float a1 = +1.00086760103908896f;
5999 NK_STORAGE const float a2 = -1.21276126894734565e-2
f;
6000 NK_STORAGE const float a3 = -1.38078780785773762e-1
f;
6001 NK_STORAGE const float a4 = -2.67353392911981221e-2
f;
6002 NK_STORAGE const float a5 = +2.08026600266304389e-2
f;
6003 NK_STORAGE const float a6 = -3.03996055049204407e-3
f;
6004 NK_STORAGE const float a7 = +1.38235642404333740e-4
f;
6005 return a0 + x*(a1 + x*(a2 + x*(a3 + x*(a4 + x*(a5 + x*(a6 + x*a7))))));
6010 NK_STORAGE const float a0 = +1.00238601909309722f;
6011 NK_STORAGE const float a1 = -3.81919947353040024e-2
f;
6012 NK_STORAGE const float a2 = -3.94382342128062756e-1
f;
6013 NK_STORAGE const float a3 = -1.18134036025221444e-1
f;
6014 NK_STORAGE const float a4 = +1.07123798512170878e-1
f;
6015 NK_STORAGE const float a5 = -1.86637164165180873e-2
f;
6016 NK_STORAGE const float a6 = +9.90140908664079833e-4
f;
6017 NK_STORAGE const float a7 = -5.23022132118824778e-14
f;
6018 return a0 + x*(a1 + x*(a2 + x*(a3 + x*(a4 + x*(a5 + x*(a6 + x*a7))))));
6021 nk_round_up_pow2(nk_uint
v)
6033 nk_pow(
double x,
int n)
6038 n = (plus) ? n : -n;
6045 return plus ? r : 1.0 /
r;
6048 nk_ifloord(
double x)
6050 x = (double)((
int)x - ((x < 0.0) ? 1 : 0));
6056 x = (float)((
int)x - ((x < 0.0f) ? 1 : 0));
6064 return (x > i) ? i+1:
i;
6067 float r = x - (float)t;
6068 return (r > 0.0
f) ? t+1:
t;
6078 neg = (n < 0) ? 1 : 0;
6079 ret = (neg) ? (
int)-n : (int)n;
6080 while ((ret / 10) > 0) {
6084 if (neg) exp = -exp;
6090 return nk_null_rect;
6118 return nk_rect(r[0], r[1], r[2], r[3]);
6123 return nk_recti(r[0], r[1], r[2], r[3]);
6129 ret.
x = r.x; ret.y = r.y;
6136 ret.
x = r.w; ret.y = r.h;
6140 nk_shrink_rect(struct
nk_rect r, float amount)
6143 r.
w =
NK_MAX(r.w, 2 * amount);
6144 r.h =
NK_MAX(r.h, 2 * amount);
6145 res.x = r.x + amount;
6146 res.y = r.y + amount;
6147 res.w = r.w - 2 * amount;
6148 res.h = r.h - 2 * amount;
6155 r.h =
NK_MAX(r.h, 2 * pad.y);
6156 r.x += pad.x; r.y += pad.y;
6165 ret.
x =
x; ret.y =
y;
6204 float w_half, h_half;
6209 r.
w = r.
w - 2 * pad_x;
6210 r.
h = r.
h - 2 * pad_y;
6215 w_half = r.
w / 2.0f;
6216 h_half = r.
h / 2.0f;
6218 if (direction ==
NK_UP) {
6222 }
else if (direction ==
NK_RIGHT) {
6224 result[1] =
nk_vec2(r.
x + r.
w, r.
y + h_half);
6226 }
else if (direction ==
NK_DOWN) {
6229 result[2] =
nk_vec2(r.
x + w_half, r.
y + r.
h);
6246 NK_INTERN int nk_str_match_here(
const char *regexp,
const char *text);
6247 NK_INTERN int nk_str_match_star(
int c,
const char *regexp,
const char *text);
6248 NK_LIB int nk_is_lower(
int c) {
return (c >=
'a' && c <=
'z') || (c >= 0xE0 && c <= 0xFF);}
6249 NK_LIB int nk_is_upper(
int c){
return (c >=
'A' && c <=
'Z') || (c >= 0xC0 && c <= 0xDF);}
6250 NK_LIB int nk_to_upper(
int c) {
return (c >=
'a' && c <=
'z') ? (c - (
'a' -
'A')) :
c;}
6251 NK_LIB int nk_to_lower(
int c) {
return (c >=
'A' && c <=
'Z') ? (c - (
'a' +
'A')) :
c;}
6254 nk_memcopy(
void *dst0,
const void *src0, nk_size
length)
6257 char *
dst = (
char*)dst0;
6258 const char *
src = (
const char*)src0;
6259 if (length == 0 || dst == src)
6263 #define nk_wsize sizeof(nk_word) 6264 #define nk_wmask (nk_wsize-1) 6265 #define NK_TLOOP(s) if (t) NK_TLOOP1(s) 6266 #define NK_TLOOP1(s) do { s; } while (--t) 6270 if ((t | (nk_ptr)
dst) & nk_wmask) {
6271 if ((t ^ (nk_ptr)
dst) & nk_wmask || length < nk_wsize)
6274 t = nk_wsize - (t & nk_wmask);
6276 NK_TLOOP1(*dst++ = *src++);
6278 t = length / nk_wsize;
6279 NK_TLOOP(*(nk_word*)(
void*)dst = *(
const nk_word*)(
const void*)src;
6280 src += nk_wsize; dst += nk_wsize);
6281 t = length & nk_wmask;
6282 NK_TLOOP(*dst++ = *src++);
6287 if ((t | (nk_ptr)dst) & nk_wmask) {
6288 if ((t ^ (nk_ptr)dst) & nk_wmask || length <= nk_wsize)
6293 NK_TLOOP1(*--dst = *--src);
6295 t = length / nk_wsize;
6296 NK_TLOOP(src -= nk_wsize; dst -= nk_wsize;
6297 *(nk_word*)(
void*)dst = *(
const nk_word*)(
const void*)
src);
6298 t = length & nk_wmask;
6299 NK_TLOOP(*--dst = *--src);
6310 nk_memset(
void *ptr,
int c0, nk_size
size)
6312 #define nk_word unsigned 6313 #define nk_wsize sizeof(nk_word) 6314 #define nk_wmask (nk_wsize - 1) 6315 nk_byte *dst = (nk_byte*)ptr;
6319 if ((c = (nk_byte)c0) != 0) {
6321 if (
sizeof(
unsigned int) > 2)
6326 dst = (nk_byte*)ptr;
6327 if (size < 3 * nk_wsize) {
6328 while (size--) *dst++ = (
nk_byte)c0;
6342 t = size / nk_wsize;
6344 *(nk_word*)((
void*)
dst) = c;
6349 t = (size & nk_wmask);
6361 nk_zero(
void *ptr, nk_size size)
6364 NK_MEMSET(ptr, 0, size);
6371 while (str && *str++ !=
'\0') siz++;
6375 nk_strtoi(
const char *str,
const char **endptr)
6378 const char *
p =
str;
6385 while (*p ==
' ') p++;
6390 while (*p && *p >=
'0' && *p <=
'9') {
6391 value = value * 10 + (int) (*p -
'0');
6399 nk_strtod(
const char *str,
const char **endptr)
6403 const char *p =
str;
6411 while (*p ==
' ') p++;
6417 while (*p && *p !=
'.' && *p !=
'e') {
6418 value = value * 10.0 + (double) (*p -
'0');
6424 for(m = 0.1; *p && *p !=
'e'; p++ ) {
6425 value = value + (double) (*p -
'0') *
m;
6435 }
else if (*p ==
'+') {
6440 for (pow = 0; *
p; p++)
6441 pow = pow * 10 + (
int) (*p -
'0');
6443 for (m = 1.0, i = 0; i < pow; i++)
6450 number = value * neg;
6456 nk_strtof(
const char *str,
const char **endptr)
6459 double double_value;
6460 double_value = NK_STRTOD(str, endptr);
6461 float_value = (float)double_value;
6473 if (c1 <= 'Z' && c1 >=
'A') {
6477 if (c2 <= 'Z' && c2 >=
'A') {
6481 return ((d >= 0) << 1) - 1;
6487 nk_stricmpn(
const char *s1,
const char *s2,
int n)
6498 if (c1 <= 'Z' && c1 >=
'A') {
6502 if (c2 <= 'Z' && c2 >=
'A') {
6506 return ((d >= 0) << 1) - 1;
6512 nk_str_match_here(
const char *regexp,
const char *text)
6514 if (regexp[0] ==
'\0')
6516 if (regexp[1] ==
'*')
6517 return nk_str_match_star(regexp[0], regexp+2, text);
6518 if (regexp[0] ==
'$' && regexp[1] ==
'\0')
6519 return *text ==
'\0';
6520 if (*text!=
'\0' && (regexp[0]==
'.' || regexp[0]==*text))
6521 return nk_str_match_here(regexp+1, text+1);
6525 nk_str_match_star(
int c,
const char *regexp,
const char *text)
6528 if (nk_str_match_here(regexp, text))
6530 }
while (*text !=
'\0' && (*text++ == c || c ==
'.'));
6542 if (regexp[0] ==
'^')
6543 return nk_str_match_here(regexp+1, text);
6545 if (nk_str_match_here(regexp, text))
6547 }
while (*text++ !=
'\0');
6552 const char *
pattern,
int *out_score)
6559 #define NK_ADJACENCY_BONUS 5 6561 #define NK_SEPARATOR_BONUS 10 6563 #define NK_CAMEL_BONUS 10 6565 #define NK_LEADING_LETTER_PENALTY (-3) 6567 #define NK_MAX_LEADING_LETTER_PENALTY (-9) 6569 #define NK_UNMATCHED_LETTER_PENALTY (-1) 6573 char const * pattern_iter =
pattern;
6581 char const * best_letter = 0;
6582 int best_letter_score = 0;
6587 if (!str || !str_len || !pattern)
return 0;
6588 while (str_iter < str_len)
6590 const char pattern_letter = *pattern_iter;
6591 const char str_letter = str[str_iter];
6593 int next_match = *pattern_iter !=
'\0' &&
6594 nk_to_lower(pattern_letter) == nk_to_lower(str_letter);
6595 int rematch = best_letter && nk_to_upper(*best_letter) == nk_to_upper(str_letter);
6597 int advanced = next_match && best_letter;
6598 int pattern_repeat = best_letter && *pattern_iter !=
'\0';
6599 pattern_repeat = pattern_repeat &&
6600 nk_to_lower(*best_letter) == nk_to_lower(pattern_letter);
6602 if (advanced || pattern_repeat) {
6603 score += best_letter_score;
6605 best_letter_score = 0;
6608 if (next_match || rematch)
6612 if (pattern_iter == pattern) {
6613 int count = (int)(&str[str_iter] - str);
6614 int penalty = NK_LEADING_LETTER_PENALTY *
count;
6615 if (penalty < NK_MAX_LEADING_LETTER_PENALTY)
6616 penalty = NK_MAX_LEADING_LETTER_PENALTY;
6623 new_score += NK_ADJACENCY_BONUS;
6627 new_score += NK_SEPARATOR_BONUS;
6630 if (prev_lower && nk_is_upper(str_letter))
6631 new_score += NK_CAMEL_BONUS;
6638 if (new_score >= best_letter_score) {
6640 if (best_letter != 0)
6641 score += NK_UNMATCHED_LETTER_PENALTY;
6643 best_letter = &str[str_iter];
6644 best_letter_score = new_score;
6648 score += NK_UNMATCHED_LETTER_PENALTY;
6653 prev_lower = nk_is_lower(str_letter) != 0;
6654 prev_separator = str_letter ==
'_' || str_letter ==
' ';
6661 score += best_letter_score;
6664 if (*pattern_iter !=
'\0')
6677 nk_string_float_limit(
char *
string,
int prec)
6687 if (dot == (prec+1)) {
6694 return (
int)(c -
string);
6697 nk_strrev_ascii(
char *
s)
6703 for (; i <
end; ++
i) {
6705 s[
i] = s[len - 1 -
i];
6710 nk_itoa(
char *s,
long n)
6723 s[i++] = (char)(
'0' + (n % 10));
6734 nk_dtoa(
char *s,
double n)
6737 int digit = 0, m = 0, m1 = 0;
6745 s[0] =
'0'; s[1] =
'\0';
6754 useExp = (m >= 14 || (neg && m >= 9) || m <= -9);
6755 if (neg) *(c++) =
'-';
6761 n = n / (double)nk_pow(10.0, m);
6770 while (n > NK_FLOAT_PRECISION || m >= 0) {
6771 double weight = nk_pow(10.0, m);
6773 double t = (double)n / weight;
6774 digit = nk_ifloord(t);
6775 n -= ((double)digit * weight);
6776 *(c++) = (
char)(
'0' + (char)digit);
6778 if (m == 0 && n > 0)
6795 *(c++) = (
char)(
'0' + (char)(m1 % 10));
6800 for (i = 0, j = m-1; i<
j; i++, j--) {
6811 #ifdef NK_INCLUDE_STANDARD_VARARGS 6812 #ifndef NK_INCLUDE_STANDARD_IO 6814 nk_vsnprintf(
char *
buf,
int buf_size,
const char *
fmt, va_list
args)
6819 NK_ARG_TYPE_DEFAULT,
6823 NK_ARG_FLAG_LEFT = 0x01,
6824 NK_ARG_FLAG_PLUS = 0x02,
6825 NK_ARG_FLAG_SPACE = 0x04,
6826 NK_ARG_FLAG_NUM = 0x10,
6827 NK_ARG_FLAG_ZERO = 0x20
6831 enum nk_arg_type arg_type = NK_ARG_TYPE_DEFAULT;
6833 int width = NK_DEFAULT;
6838 const char *iter =
fmt;
6841 NK_ASSERT(buf_size);
6842 if (!buf || !buf_size || !fmt)
return 0;
6843 for (iter = fmt; *iter && len < buf_size; iter++) {
6845 while (*iter && (*iter !=
'%') && (len < buf_size))
6846 buf[len++] = *iter++;
6847 if (!(*iter) || len >= buf_size)
break;
6852 if (*iter ==
'-') flag |= NK_ARG_FLAG_LEFT;
6853 else if (*iter ==
'+') flag |= NK_ARG_FLAG_PLUS;
6854 else if (*iter ==
' ') flag |= NK_ARG_FLAG_SPACE;
6855 else if (*iter ==
'#') flag |= NK_ARG_FLAG_NUM;
6856 else if (*iter ==
'0') flag |= NK_ARG_FLAG_ZERO;
6863 if (*iter >=
'1' && *iter <=
'9') {
6869 }
else if (*iter ==
'*') {
6870 width = va_arg(args,
int);
6875 precision = NK_DEFAULT;
6879 precision = va_arg(args,
int);
6892 if (*(iter+1) ==
'h') {
6893 arg_type = NK_ARG_TYPE_CHAR;
6895 }
else arg_type = NK_ARG_TYPE_SHORT;
6897 }
else if (*iter ==
'l') {
6898 arg_type = NK_ARG_TYPE_LONG;
6900 }
else arg_type = NK_ARG_TYPE_DEFAULT;
6904 NK_ASSERT(arg_type == NK_ARG_TYPE_DEFAULT);
6905 NK_ASSERT(precision == NK_DEFAULT);
6906 NK_ASSERT(width == NK_DEFAULT);
6909 }
else if (*iter ==
's') {
6911 const char *str = va_arg(args,
const char*);
6912 NK_ASSERT(str != buf &&
"buffer and argument are not allowed to overlap!");
6913 NK_ASSERT(arg_type == NK_ARG_TYPE_DEFAULT);
6914 NK_ASSERT(precision == NK_DEFAULT);
6915 NK_ASSERT(width == NK_DEFAULT);
6916 if (str == buf)
return -1;
6917 while (str && *str && len < buf_size)
6918 buf[len++] = *str++;
6919 }
else if (*iter ==
'n') {
6921 signed int *n = va_arg(args,
int*);
6922 NK_ASSERT(arg_type == NK_ARG_TYPE_DEFAULT);
6923 NK_ASSERT(precision == NK_DEFAULT);
6924 NK_ASSERT(width == NK_DEFAULT);
6926 }
else if (*iter ==
'c' || *iter ==
'i' || *iter ==
'd') {
6929 const char *num_iter;
6930 int num_len, num_print, padding;
6931 int cur_precision =
NK_MAX(precision, 1);
6932 int cur_width =
NK_MAX(width, 0);
6935 if (arg_type == NK_ARG_TYPE_CHAR)
6936 value = (
signed char)va_arg(args,
int);
6937 else if (arg_type == NK_ARG_TYPE_SHORT)
6938 value = (
signed short)va_arg(args,
int);
6939 else if (arg_type == NK_ARG_TYPE_LONG)
6940 value = va_arg(args,
signed long);
6941 else if (*iter ==
'c')
6942 value = (
unsigned char)va_arg(args,
int);
6943 else value = va_arg(args,
signed int);
6946 nk_itoa(number_buffer, value);
6948 padding =
NK_MAX(cur_width -
NK_MAX(cur_precision, num_len), 0);
6949 if ((flag & NK_ARG_FLAG_PLUS) || (flag & NK_ARG_FLAG_SPACE))
6950 padding =
NK_MAX(padding-1, 0);
6953 if (!(flag & NK_ARG_FLAG_LEFT)) {
6954 while (padding-- > 0 && (len < buf_size)) {
6955 if ((flag & NK_ARG_FLAG_ZERO) && (precision == NK_DEFAULT))
6957 else buf[len++] =
' ';
6962 if ((flag & NK_ARG_FLAG_PLUS) && value >= 0 && len < buf_size)
6964 else if ((flag & NK_ARG_FLAG_SPACE) && value >= 0 && len < buf_size)
6968 num_print =
NK_MAX(cur_precision, num_len);
6969 while (precision && (num_print > num_len) && (len < buf_size)) {
6975 num_iter = number_buffer;
6976 while (precision && *num_iter && len < buf_size)
6977 buf[len++] = *num_iter++;
6980 if (flag & NK_ARG_FLAG_LEFT) {
6981 while ((padding-- > 0) && (len < buf_size))
6984 }
else if (*iter ==
'o' || *iter ==
'x' || *iter ==
'X' || *iter ==
'u') {
6986 unsigned long value = 0;
6987 int num_len = 0, num_print, padding = 0;
6988 int cur_precision =
NK_MAX(precision, 1);
6989 int cur_width =
NK_MAX(width, 0);
6990 unsigned int base = (*iter ==
'o') ? 8: (*iter ==
'u')? 10: 16;
6993 const char *upper_output_format =
"0123456789ABCDEF";
6994 const char *lower_output_format =
"0123456789abcdef";
6995 const char *output_format = (*iter ==
'x') ?
6996 lower_output_format: upper_output_format;
6999 if (arg_type == NK_ARG_TYPE_CHAR)
7000 value = (
unsigned char)va_arg(args,
int);
7001 else if (arg_type == NK_ARG_TYPE_SHORT)
7002 value = (
unsigned short)va_arg(args,
int);
7003 else if (arg_type == NK_ARG_TYPE_LONG)
7004 value = va_arg(args,
unsigned long);
7005 else value = va_arg(args,
unsigned int);
7009 int digit = output_format[value % base];
7011 number_buffer[num_len++] = (char)digit;
7013 }
while (value > 0);
7015 num_print =
NK_MAX(cur_precision, num_len);
7016 padding =
NK_MAX(cur_width -
NK_MAX(cur_precision, num_len), 0);
7017 if (flag & NK_ARG_FLAG_NUM)
7018 padding =
NK_MAX(padding-1, 0);
7021 if (!(flag & NK_ARG_FLAG_LEFT)) {
7022 while ((padding-- > 0) && (len < buf_size)) {
7023 if ((flag & NK_ARG_FLAG_ZERO) && (precision == NK_DEFAULT))
7025 else buf[len++] =
' ';
7030 if (num_print && (flag & NK_ARG_FLAG_NUM)) {
7031 if ((*iter ==
'o') && (len < buf_size)) {
7033 }
else if ((*iter ==
'x') && ((len+1) < buf_size)) {
7036 }
else if ((*iter ==
'X') && ((len+1) < buf_size)) {
7041 while (precision && (num_print > num_len) && (len < buf_size)) {
7047 while (num_len > 0) {
7048 if (precision && (len < buf_size))
7049 buf[len++] = number_buffer[num_len-1];
7054 if (flag & NK_ARG_FLAG_LEFT) {
7055 while ((padding-- > 0) && (len < buf_size))
7058 }
else if (*iter ==
'f') {
7060 const char *num_iter;
7061 int cur_precision = (precision < 0) ? 6: precision;
7062 int prefix, cur_width =
NK_MAX(width, 0);
7063 double value = va_arg(args,
double);
7064 int num_len = 0, frac_len = 0, dot = 0;
7067 NK_ASSERT(arg_type == NK_ARG_TYPE_DEFAULT);
7068 NK_DTOA(number_buffer, value);
7072 num_iter = number_buffer;
7073 while (*num_iter && *num_iter !=
'.')
7076 prefix = (*num_iter ==
'.')?(
int)(num_iter - number_buffer)+1:0;
7077 padding =
NK_MAX(cur_width - (prefix +
NK_MIN(cur_precision, num_len - prefix)) , 0);
7078 if ((flag & NK_ARG_FLAG_PLUS) || (flag & NK_ARG_FLAG_SPACE))
7079 padding =
NK_MAX(padding-1, 0);
7082 if (!(flag & NK_ARG_FLAG_LEFT)) {
7083 while (padding-- > 0 && (len < buf_size)) {
7084 if (flag & NK_ARG_FLAG_ZERO)
7086 else buf[len++] =
' ';
7091 num_iter = number_buffer;
7092 if ((flag & NK_ARG_FLAG_PLUS) && (value >= 0) && (len < buf_size))
7094 else if ((flag & NK_ARG_FLAG_SPACE) && (value >= 0) && (len < buf_size))
7097 if (dot) frac_len++;
7099 buf[len++] = *num_iter;
7100 if (*num_iter ==
'.') dot = 1;
7101 if (frac_len >= cur_precision)
break;
7106 while (frac_len < cur_precision) {
7107 if (!dot && len < buf_size) {
7117 if (flag & NK_ARG_FLAG_LEFT) {
7118 while ((padding-- > 0) && (len < buf_size))
7123 NK_ASSERT(0 &&
"specifier is not supported!");
7127 buf[(len >= buf_size)?(buf_size-1):len] = 0;
7128 result = (len >= buf_size)?-1:len;
7133 nk_strfmt(
char *buf,
int buf_size,
const char *fmt, va_list args)
7137 NK_ASSERT(buf_size);
7138 if (!buf || !buf_size || !fmt)
return 0;
7139 #ifdef NK_INCLUDE_STANDARD_IO 7140 result = NK_VSNPRINTF(buf, (nk_size)buf_size, fmt, args);
7141 result = (result >= buf_size) ? -1: result;
7142 buf[buf_size-1] = 0;
7144 result = nk_vsnprintf(buf, buf_size, fmt, args);
7153 #define NK_ROTL(x,r) ((x) << (r) | ((x) >> (32 - r))) 7154 union {
const nk_uint *
i;
const nk_byte *
b;} conv = {0};
7155 const nk_byte *
data = (
const nk_byte*)key;
7156 const int nblocks = len/4;
7158 const nk_uint c1 = 0xcc9e2d51;
7159 const nk_uint c2 = 0x1b873593;
7160 const nk_byte *tail;
7161 const nk_uint *blocks;
7167 conv.b = (data + nblocks*4);
7168 blocks = (
const nk_uint*)conv.i;
7169 for (i = -nblocks;
i; ++
i) {
7172 k1 = NK_ROTL(k1,15);
7176 h1 = NK_ROTL(h1,13);
7177 h1 = h1*5+0xe6546b64;
7181 tail = (
const nk_byte*)(data + nblocks*4);
7184 case 3: k1 ^= (
nk_uint)(tail[2] << 16);
7185 case 2: k1 ^= (
nk_uint)(tail[1] << 8u);
7186 case 1: k1 ^= tail[0];
7188 k1 = NK_ROTL(k1,15);
7207 #ifdef NK_INCLUDE_STANDARD_IO 7218 if (!path || !siz || !alloc)
7221 fd = fopen(path,
"rb");
7223 fseek(fd, 0, SEEK_END);
7230 fseek(fd, 0, SEEK_SET);
7237 *siz = (
nk_size)fread(buf, 1,*siz, fd);
7244 int text_len,
float space,
int *glyphs,
float *text_width,
7245 nk_rune *sep_list,
int sep_count)
7249 float last_width = 0;
7250 nk_rune unicode = 0;
7258 float sep_width = 0;
7259 sep_count =
NK_MAX(sep_count,0);
7262 while (glyph_len && (width < space) && (len < text_len)) {
7265 for (i = 0; i < sep_count; ++
i) {
7266 if (unicode != sep_list[i])
continue;
7267 sep_width = last_width =
width;
7272 if (i == sep_count){
7273 last_width = sep_width =
width;
7277 glyph_len =
nk_utf_decode(&text[len], &unicode, text_len - len);
7280 if (len >= text_len) {
7282 *text_width = last_width;
7286 *text_width = sep_width;
7287 return (!sep_len) ? len: sep_len;
7292 const char *
begin,
int byte_len,
float row_height,
const char **remaining,
7293 struct nk_vec2 *out_offset,
int *glyphs,
int op)
7295 float line_height = row_height;
7297 float line_width = 0.0f;
7301 nk_rune unicode = 0;
7303 if (!begin || byte_len <= 0 || !font)
7307 if (!glyph_len)
return text_size;
7308 glyph_width = font->width(font->userdata, font->height, begin, glyph_len);
7311 while ((text_len < byte_len) && glyph_len) {
7312 if (unicode ==
'\n') {
7313 text_size.
x =
NK_MAX(text_size.
x, line_width);
7314 text_size.
y += line_height;
7317 if (op == NK_STOP_ON_NEW_LINE)
7321 glyph_len =
nk_utf_decode(begin + text_len, &unicode, byte_len-text_len);
7325 if (unicode ==
'\r') {
7328 glyph_len =
nk_utf_decode(begin + text_len, &unicode, byte_len-text_len);
7332 *glyphs = *glyphs + 1;
7333 text_len += glyph_len;
7334 line_width += (float)glyph_width;
7335 glyph_len =
nk_utf_decode(begin + text_len, &unicode, byte_len-text_len);
7336 glyph_width = font->width(font->userdata, font->height, begin+text_len, glyph_len);
7340 if (text_size.
x < line_width)
7341 text_size.
x = line_width;
7343 *out_offset =
nk_vec2(line_width, text_size.
y + line_height);
7344 if (line_width > 0 || text_size.
y == 0.0f)
7345 text_size.
y += line_height;
7347 *remaining = begin+text_len;
7361 nk_parse_hex(
const char *p,
int length)
7365 while (len < length) {
7367 if (p[len] >=
'a' && p[len] <=
'f')
7368 i += ((p[
len] -
'a') + 10);
7369 else if (p[len] >=
'A' && p[len] <=
'F')
7370 i += ((p[
len] -
'A') + 10);
7371 else i += (p[
len] -
'0');
7379 struct nk_color ret;
7389 struct nk_color
col;
7390 const char *c = rgb;
7401 struct nk_color
col;
7402 const char *c = rgb;
7413 #define NK_TO_HEX(i) ((i) <= 9 ? '0' + (i): 'A' - 10 + (i)) 7414 output[0] = (char)NK_TO_HEX((col.
r & 0xF0) >> 4);
7415 output[1] = (char)NK_TO_HEX((col.
r & 0x0F));
7416 output[2] = (char)NK_TO_HEX((col.
g & 0xF0) >> 4);
7417 output[3] = (char)NK_TO_HEX((col.
g & 0x0F));
7418 output[4] = (char)NK_TO_HEX((col.
b & 0xF0) >> 4);
7419 output[5] = (char)NK_TO_HEX((col.
b & 0x0F));
7420 output[6] = (char)NK_TO_HEX((col.
a & 0xF0) >> 4);
7421 output[7] = (char)NK_TO_HEX((col.
a & 0x0F));
7428 #define NK_TO_HEX(i) ((i) <= 9 ? '0' + (i): 'A' - 10 + (i)) 7429 output[0] = (char)NK_TO_HEX((col.
r & 0xF0) >> 4);
7430 output[1] = (char)NK_TO_HEX((col.
r & 0x0F));
7431 output[2] = (char)NK_TO_HEX((col.
g & 0xF0) >> 4);
7432 output[3] = (char)NK_TO_HEX((col.
g & 0x0F));
7433 output[4] = (char)NK_TO_HEX((col.
b & 0xF0) >> 4);
7434 output[5] = (char)NK_TO_HEX((col.
b & 0x0F));
7441 return nk_rgba(c[0], c[1], c[2], c[3]);
7446 return nk_rgba(c[0], c[1], c[2], c[3]);
7451 struct nk_color ret;
7461 return nk_rgb(c[0], c[1], c[2]);
7466 return nk_rgb(c[0], c[1], c[2]);
7471 struct nk_color ret;
7472 ret.
r = (
in & 0xFF);
7473 ret.g = ((
in >> 8) & 0xFF);
7474 ret.b = ((
in >> 16) & 0xFF);
7481 struct nk_color ret;
7491 return nk_rgba_f(c[0], c[1], c[2], c[3]);
7501 struct nk_color ret;
7526 return nk_hsv(c[0], c[1], c[2]);
7531 return nk_hsv(c[0], c[1], c[2]);
7546 float hf = ((float)
NK_CLAMP(0,
h, 255)) / 255.0
f;
7547 float sf = ((float)
NK_CLAMP(0, s, 255)) / 255.0
f;
7548 float vf = ((float)
NK_CLAMP(0,
v, 255)) / 255.0
f;
7549 float af = ((float)
NK_CLAMP(0,
a, 255)) / 255.0
f;
7555 return nk_hsva(c[0], c[1], c[2], c[3]);
7560 return nk_hsva(c[0], c[1], c[2], c[3]);
7569 out.
r =
v; out.
g =
v; out.
b =
v; out.
a =
a;
7572 h =
h / (60.0f/360.0f);
7576 q =
v * (1.0f - (s *
f));
7577 t =
v * (1.0f - s * (1.0f -
f));
7580 case 0:
default:
out.r =
v;
out.g =
t;
out.b =
p;
break;
7603 return nk_hsva_f(c[0], c[1], c[2], c[3]);
7609 out |= ((nk_uint)in.
g << 8);
7615 nk_color_f(
float *r,
float *g,
float *
b,
float *
a,
struct nk_color
in)
7618 *r = (float)in.
r * s;
7619 *g = (
float)in.
g *
s;
7620 *b = (float)in.
b * s;
7621 *a = (
float)in.
a *
s;
7636 nk_color_d(
double *r,
double *g,
double *
b,
double *
a,
struct nk_color
in)
7639 *r = (double)in.
r * s;
7640 *g = (
double)in.
g *
s;
7641 *b = (double)in.
b * s;
7642 *a = (
double)in.
a *
s;
7650 nk_color_hsv_f(
float *out_h,
float *out_s,
float *out_v,
struct nk_color
in)
7668 const float t = in.
g; in.
g = in.
b; in.
b =
t;
7672 const float t = in.
r; in.
r = in.
g; in.
g =
t;
7675 chroma = in.
r - ((in.
g < in.
b) ? in.
g: in.
b);
7676 *out_h =
NK_ABS(K + (in.
g - in.
b)/(6.0f * chroma + 1
e-20
f));
7677 *out_s = chroma / (in.
r + 1
e-20
f);
7689 float *out_v,
float *out_a,
struct nk_color in)
7702 int *out_a,
struct nk_color in)
7707 *out_s = (
nk_byte)(s * 255.0f);
7708 *out_v = (
nk_byte)(v * 255.0f);
7709 *out_a = (
nk_byte)(a * 255.0f);
7727 nk_color_hsva_b(nk_byte *h, nk_byte *s, nk_byte *v, nk_byte *a,
struct nk_color in)
7737 nk_color_hsv_i(
int *out_h,
int *out_s,
int *out_v,
struct nk_color in)
7743 nk_color_hsv_b(nk_byte *out_h, nk_byte *out_s, nk_byte *out_v,
struct nk_color in)
7781 nk_utf_validate(nk_rune *u,
int i)
7785 if (!
NK_BETWEEN(*u, nk_utfmin[i], nk_utfmax[i]) ||
7788 for (i = 1; *u > nk_utfmax[
i]; ++
i);
7792 nk_utf_decode_byte(
char c,
int *i)
7796 for(*i = 0; *i < (int)
NK_LEN(nk_utfmask); ++(*i)) {
7797 if (((nk_byte)c & nk_utfmask[*i]) == nk_utfbyte[*
i])
7798 return (nk_byte)(c & ~nk_utfmask[*
i]);
7811 if (!c || !u)
return 0;
7812 if (!clen)
return 0;
7815 udecoded = nk_utf_decode_byte(c[0], &len);
7819 for (i = 1, j = 1; i < clen && j <
len; ++
i, ++
j) {
7820 udecoded = (udecoded << 6) | nk_utf_decode_byte(c[i], &type);
7827 nk_utf_validate(u, len);
7831 nk_utf_encode_byte(nk_rune u,
int i)
7833 return (
char)((nk_utfbyte[
i]) | ((nk_byte)u & ~nk_utfmask[
i]));
7839 len = nk_utf_validate(&u, 0);
7843 for (i = len - 1; i != 0; --
i) {
7844 c[
i] = nk_utf_encode_byte(u, 0);
7847 c[0] = nk_utf_encode_byte(u, len);
7861 if (!str || !len)
return 0;
7866 while (glyph_len && src_len < len) {
7868 src_len = src_len + glyph_len;
7869 glyph_len =
nk_utf_decode(text + src_len, &unicode, text_len - src_len);
7875 nk_rune *unicode,
int *len)
7887 if (!buffer || !unicode || !len)
return 0;
7904 src_len = src_len + glyph_len;
7905 glyph_len =
nk_utf_decode(text + src_len, unicode, text_len - src_len);
7907 if (i != index)
return 0;
7908 return buffer + src_len;
7920 #ifdef NK_INCLUDE_DEFAULT_ALLOCATOR 7922 nk_malloc(nk_handle unused,
void *old,nk_size size)
7926 return malloc(size);
7929 nk_mfree(nk_handle unused,
void *ptr)
7935 nk_buffer_init_default(
struct nk_buffer *buffer)
7939 alloc.
alloc = nk_malloc;
7940 alloc.
free = nk_mfree;
7947 nk_size initial_size)
7951 NK_ASSERT(initial_size);
7952 if (!b || !a || !initial_size)
return;
7954 nk_zero(b,
sizeof(*b));
7958 b->
size = initial_size;
7968 if (!b || !m || !size)
return;
7970 nk_zero(b,
sizeof(*b));
7977 nk_buffer_align(
void *unaligned,
7978 nk_size
align, nk_size *alignment,
7988 *alignment = (
nk_size)((nk_byte*)memory - (nk_byte*)unaligned);
7997 *alignment = (
nk_size)((nk_byte*)unaligned - (nk_byte*)memory);
8007 nk_buffer_realloc(
struct nk_buffer *b, nk_size capacity, nk_size *size)
8010 nk_size buffer_size;
8020 if (!temp)
return 0;
8024 NK_MEMCPY(temp, b->
memory.
ptr, buffer_size);
8028 if (b->
size == buffer_size) {
8036 back_size = buffer_size - b->
size;
8037 dst =
nk_ptr_add(
void, temp, capacity - back_size);
8039 NK_MEMCPY(dst, src, back_size);
8040 b->
size = capacity - back_size;
8046 nk_size size, nk_size align)
8055 if (!b || !size)
return 0;
8062 memory = nk_buffer_align(unaligned, align, &alignment, type);
8079 capacity =
NK_MAX(capacity, nk_round_up_pow2((nk_uint)(b->
allocated + size)));
8087 memory = nk_buffer_align(unaligned, align, &alignment, type);
8091 else b->
size -= (size + alignment);
8098 const void *memory, nk_size size, nk_size align)
8100 void *mem = nk_buffer_alloc(b, type, size, align);
8102 NK_MEMCPY(mem, memory, size);
8108 if (!buffer)
return;
8118 if (!buffer)
return;
8160 if (!s || !b)
return;
8171 if (!buffer)
return 0;
8178 if (!buffer)
return 0;
8185 if (!buffer)
return 0;
8198 #ifdef NK_INCLUDE_DEFAULT_ALLOCATOR 8200 nk_str_init_default(
struct nk_str *str)
8204 alloc.
alloc = nk_malloc;
8205 alloc.
free = nk_mfree;
8229 if (!s || !str || !len)
return 0;
8232 NK_MEMCPY(mem, str, (nk_size)len *
sizeof(
char));
8247 if (!str || !text || !len)
return 0;
8248 for (i = 0; i <
len; ++
i)
8261 if (!str || !text)
return 0;
8263 glyph_len = byte_len =
nk_utf_decode(text+byte_len, &unicode, 4);
8264 while (unicode !=
'\0' && glyph_len) {
8266 byte_len += glyph_len;
8280 if (!str || !text || !len)
return 0;
8281 for (i = 0; i <
len; ++
i) {
8283 if (!byte_len)
break;
8295 if (!str || !runes)
return 0;
8296 while (runes[i] !=
'\0') {
8314 NK_ASSERT(len >= 0);
8315 if (!s || !str || !len || (nk_size)pos > s->
buffer.
allocated)
return 0;
8328 NK_ASSERT(((
int)pos + (
int)len + ((
int)copylen - 1)) >= 0);
8329 NK_ASSERT(((
int)pos + ((
int)copylen - 1)) >= 0);
8332 for (i = 0; i < copylen; ++
i) *dst-- = *src--;
8334 NK_MEMCPY(mem, str, (nk_size)len *
sizeof(
char));
8349 if (!str || !cstr || !len)
return 0;
8354 if (!begin)
return 0;
8376 if (!str || !text || !len)
return 0;
8377 for (i = 0; i <
len; ++
i)
8390 if (!str || !text)
return 0;
8392 glyph_len = byte_len =
nk_utf_decode(text+byte_len, &unicode, 4);
8393 while (unicode !=
'\0' && glyph_len) {
8395 byte_len += glyph_len;
8409 if (!str || !runes || !len)
return 0;
8410 for (i = 0; i <
len; ++
i) {
8412 if (!byte_len)
break;
8424 if (!str || !runes)
return 0;
8425 while (runes[i] !=
'\0') {
8436 NK_ASSERT(len >= 0);
8451 NK_ASSERT(len >= 0);
8452 if (!str || len < 0)
return;
8453 if (len >= str->
len) {
8490 NK_ASSERT(s->
len >= pos + len);
8491 if (s->
len < pos + len)
8524 if (!str || !unicode || !len)
return 0;
8541 src_len = src_len + glyph_len;
8542 glyph_len =
nk_utf_decode(text + src_len, unicode, text_len - src_len);
8544 if (i != pos)
return 0;
8545 return text + src_len;
8567 if (!str || !unicode || !len)
return 0;
8584 src_len = src_len + glyph_len;
8585 glyph_len =
nk_utf_decode(text + src_len, unicode, text_len - src_len);
8587 if (i != pos)
return 0;
8588 return text + src_len;
8594 nk_rune unicode = 0;
8656 if (!cb || !b)
return;
8671 b->
clip = nk_null_rect;
8672 #ifdef NK_INCLUDE_COMMAND_USERDATA 8694 unaligned = (nk_byte*)cmd + size;
8696 alignment = (
nk_size)((nk_byte*)memory - (nk_byte*)unaligned);
8697 #ifdef NK_ZERO_COMMAND_MEMORY 8698 NK_MEMSET(cmd, 0, size + alignment);
8703 #ifdef NK_INCLUDE_COMMAND_USERDATA 8724 cmd->
x = (short)r.
x;
8725 cmd->
y = (
short)r.
y;
8726 cmd->
w = (
unsigned short)
NK_MAX(0, r.
w);
8727 cmd->
h = (
unsigned short)
NK_MAX(0, r.
h);
8731 float x1,
float y1,
float line_thickness,
struct nk_color c)
8735 if (!b || line_thickness <= 0)
return;
8740 cmd->
begin.
x = (short)x0;
8741 cmd->
begin.
y = (short)y0;
8742 cmd->
end.
x = (short)x1;
8743 cmd->
end.
y = (short)y1;
8748 float ctrl0x,
float ctrl0y,
float ctrl1x,
float ctrl1y,
8749 float bx,
float by,
float line_thickness,
struct nk_color col)
8753 if (!b || col.
a == 0 || line_thickness <= 0)
return;
8759 cmd->
begin.
x = (short)ax;
8760 cmd->
begin.
y = (short)ay;
8761 cmd->
ctrl[0].
x = (short)ctrl0x;
8762 cmd->
ctrl[0].
y = (short)ctrl0y;
8763 cmd->
ctrl[1].
x = (short)ctrl1x;
8764 cmd->
ctrl[1].
y = (short)ctrl1y;
8765 cmd->
end.
x = (short)bx;
8766 cmd->
end.
y = (short)by;
8771 float rounding,
float line_thickness,
struct nk_color c)
8775 if (!b || c.
a == 0 || rect.
w == 0 || rect.
h == 0 || line_thickness <= 0)
return;
8779 clip->
x, clip->
y, clip->
w, clip->
h))
return;
8784 cmd->
rounding = (
unsigned short)rounding;
8786 cmd->
x = (short)rect.
x;
8787 cmd->
y = (
short)rect.
y;
8788 cmd->
w = (
unsigned short)
NK_MAX(0, rect.
w);
8789 cmd->
h = (
unsigned short)
NK_MAX(0, rect.
h);
8794 float rounding,
struct nk_color c)
8798 if (!b || c.
a == 0 || rect.
w == 0 || rect.
h == 0)
return;
8802 clip->
x, clip->
y, clip->
w, clip->
h))
return;
8808 cmd->
rounding = (
unsigned short)rounding;
8809 cmd->
x = (short)rect.
x;
8810 cmd->
y = (
short)rect.
y;
8811 cmd->
w = (
unsigned short)
NK_MAX(0, rect.
w);
8812 cmd->
h = (
unsigned short)
NK_MAX(0, rect.
h);
8817 struct nk_color
left,
struct nk_color
top,
struct nk_color
right,
8822 if (!b || rect.
w == 0 || rect.
h == 0)
return;
8826 clip->
x, clip->
y, clip->
w, clip->
h))
return;
8832 cmd->
x = (short)rect.
x;
8833 cmd->
y = (
short)rect.
y;
8834 cmd->
w = (
unsigned short)
NK_MAX(0, rect.
w);
8835 cmd->
h = (
unsigned short)
NK_MAX(0, rect.
h);
8843 float line_thickness,
struct nk_color c)
8846 if (!b || r.
w == 0 || r.
h == 0 || line_thickness <= 0)
return;
8857 cmd->
x = (short)r.
x;
8858 cmd->
y = (
short)r.
y;
8859 cmd->
w = (
unsigned short)
NK_MAX(r.
w, 0);
8860 cmd->
h = (
unsigned short)
NK_MAX(r.
h, 0);
8868 if (!b || c.
a == 0 || r.
w == 0 || r.
h == 0)
return;
8878 cmd->
x = (short)r.
x;
8879 cmd->
y = (
short)r.
y;
8880 cmd->
w = (
unsigned short)
NK_MAX(r.
w, 0);
8881 cmd->
h = (
unsigned short)
NK_MAX(r.
h, 0);
8886 float a_min,
float a_max,
float line_thickness,
struct nk_color c)
8889 if (!b || c.
a == 0 || line_thickness <= 0)
return;
8894 cmd->
cx = (short)cx;
8895 cmd->
cy = (short)cy;
8896 cmd->
r = (
unsigned short)radius;
8903 float a_min,
float a_max,
struct nk_color c)
8907 if (!b || c.
a == 0)
return;
8911 cmd->
cx = (short)cx;
8912 cmd->
cy = (short)cy;
8913 cmd->
r = (
unsigned short)radius;
8920 float y1,
float x2,
float y2,
float line_thickness,
struct nk_color c)
8924 if (!b || c.
a == 0 || line_thickness <= 0)
return;
8927 if (!
NK_INBOX(x0, y0, clip->
x, clip->
y, clip->
w, clip->
h) &&
8928 !
NK_INBOX(x1, y1, clip->
x, clip->
y, clip->
w, clip->
h) &&
8937 cmd->
a.
x = (short)x0;
8938 cmd->
a.
y = (short)y0;
8939 cmd->
b.
x = (short)x1;
8940 cmd->
b.
y = (short)y1;
8941 cmd->
c.
x = (short)x2;
8942 cmd->
c.
y = (short)y2;
8947 float y1,
float x2,
float y2,
struct nk_color c)
8951 if (!b || c.
a == 0)
return;
8955 if (!
NK_INBOX(x0, y0, clip->
x, clip->
y, clip->
w, clip->
h) &&
8956 !
NK_INBOX(x1, y1, clip->
x, clip->
y, clip->
w, clip->
h) &&
8964 cmd->
a.
x = (short)x0;
8965 cmd->
a.
y = (short)y0;
8966 cmd->
b.
x = (short)x1;
8967 cmd->
b.
y = (short)y1;
8968 cmd->
c.
x = (short)x2;
8969 cmd->
c.
y = (short)y2;
8974 float line_thickness,
struct nk_color col)
8981 if (!b || col.
a == 0 || line_thickness <= 0)
return;
8982 size =
sizeof(*cmd) +
sizeof(short) * 2 * (nk_size)point_count;
8986 cmd->line_thickness = (
unsigned short)line_thickness;
8987 cmd->point_count = (
unsigned short)point_count;
8988 for (i = 0; i < point_count; ++i) {
8989 cmd->
points[
i].
x = (short)points[i*2];
8990 cmd->
points[
i].
y = (short)points[i*2+1];
8995 struct nk_color col)
9002 if (!b || col.
a == 0)
return;
9003 size =
sizeof(*cmd) +
sizeof(short) * 2 * (nk_size)point_count;
9008 cmd->point_count = (
unsigned short)point_count;
9009 for (i = 0; i < point_count; ++i) {
9010 cmd->
points[
i].
x = (short)points[i*2+0];
9011 cmd->
points[
i].
y = (short)points[i*2+1];
9016 float line_thickness,
struct nk_color col)
9023 if (!b || col.
a == 0 || line_thickness <= 0)
return;
9024 size =
sizeof(*cmd) +
sizeof(short) * 2 * (nk_size)point_count;
9028 cmd->point_count = (
unsigned short)point_count;
9029 cmd->line_thickness = (
unsigned short)line_thickness;
9030 for (i = 0; i < point_count; ++i) {
9031 cmd->
points[
i].
x = (short)points[i*2];
9032 cmd->
points[
i].
y = (short)points[i*2+1];
9051 cmd->
x = (short)r.
x;
9052 cmd->
y = (
short)r.
y;
9053 cmd->
w = (
unsigned short)
NK_MAX(0, r.
w);
9054 cmd->
h = (
unsigned short)
NK_MAX(0, r.
h);
9074 cmd->
x = (short)r.
x;
9075 cmd->
y = (
short)r.
y;
9076 cmd->
w = (
unsigned short)
NK_MAX(0, r.
w);
9077 cmd->
h = (
unsigned short)
NK_MAX(0, r.
h);
9083 const char *
string,
int length,
const struct nk_user_font *font,
9084 struct nk_color bg,
struct nk_color fg)
9086 float text_width = 0;
9091 if (!b || !
string || !length || (bg.
a == 0 && fg.
a == 0))
return;
9100 if (text_width > r.
w){
9102 float txt_width = (float)text_width;
9103 length = nk_text_clamp(font,
string, length, r.
w, &glyphs, &txt_width, 0,0);
9106 if (!length)
return;
9110 cmd->
x = (short)r.
x;
9111 cmd->
y = (
short)r.
y;
9112 cmd->
w = (
unsigned short)r.
w;
9113 cmd->
h = (
unsigned short)r.
h;
9119 NK_MEMCPY(cmd->
string,
string, (nk_size)length);
9132 #ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT 9134 nk_draw_list_init(
struct nk_draw_list *list)
9139 nk_zero(list,
sizeof(*list));
9140 for (i = 0; i <
NK_LEN(list->circle_vtx); ++
i) {
9141 const float a = ((float)i / (
float)
NK_LEN(list->circle_vtx)) * 2 *
NK_PI;
9142 list->circle_vtx[
i].x = (float)NK_COS(a);
9143 list->circle_vtx[
i].y = (float)NK_SIN(a);
9154 NK_ASSERT(vertices);
9155 NK_ASSERT(elements);
9156 if (!canvas || !config || !cmds || !vertices || !elements)
9159 canvas->buffer = cmds;
9160 canvas->config = *
config;
9161 canvas->elements = elements;
9163 canvas->line_AA = line_aa;
9164 canvas->shape_AA = shape_aa;
9165 canvas->clip_rect = nk_null_rect;
9167 canvas->cmd_offset = 0;
9168 canvas->element_count = 0;
9169 canvas->vertex_count = 0;
9170 canvas->cmd_offset = 0;
9171 canvas->cmd_count = 0;
9172 canvas->path_count = 0;
9174 NK_API const struct nk_draw_command*
9175 nk__draw_list_begin(
const struct nk_draw_list *canvas,
const struct nk_buffer *buffer)
9179 const struct nk_draw_command *
cmd;
9182 if (!buffer || !buffer->
size || !canvas->cmd_count)
9186 offset = buffer->
memory.
size - canvas->cmd_offset;
9187 cmd =
nk_ptr_add(
const struct nk_draw_command, memory, offset);
9190 NK_API const struct nk_draw_command*
9191 nk__draw_list_end(
const struct nk_draw_list *canvas,
const struct nk_buffer *buffer)
9196 const struct nk_draw_command *
end;
9200 if (!buffer || !canvas)
9205 offset = size - canvas->cmd_offset;
9206 end =
nk_ptr_add(
const struct nk_draw_command, memory, offset);
9207 end -= (canvas->cmd_count-1);
9210 NK_API const struct nk_draw_command*
9211 nk__draw_list_next(
const struct nk_draw_command *cmd,
9212 const struct nk_buffer *buffer,
const struct nk_draw_list *canvas)
9214 const struct nk_draw_command *
end;
9217 if (!cmd || !buffer || !canvas)
9220 end = nk__draw_list_end(canvas, buffer);
9221 if (cmd <= end)
return 0;
9225 nk_draw_list_alloc_path(
struct nk_draw_list *list,
int count)
9232 point_size * (nk_size)
count, point_align);
9234 if (!points)
return 0;
9235 if (!list->path_offset) {
9237 list->path_offset = (
unsigned int)((nk_byte*)points - (nk_byte*)memory);
9239 list->path_count += (
unsigned int)count;
9243 nk_draw_list_path_last(struct nk_draw_list *list)
9247 NK_ASSERT(list->path_count);
9250 point += (list->path_count-1);
9254 nk_draw_list_push_command(
struct nk_draw_list *list,
struct nk_rect clip,
9258 NK_STORAGE const nk_size cmd_size =
sizeof(
struct nk_draw_command);
9259 struct nk_draw_command *
cmd;
9262 cmd = (
struct nk_draw_command*)
9263 nk_buffer_alloc(list->buffer,
NK_BUFFER_BACK, cmd_size, cmd_align);
9266 if (!list->cmd_count) {
9270 list->cmd_offset = (
nk_size)(memory - (nk_byte*)
cmd);
9273 cmd->elem_count = 0;
9274 cmd->clip_rect = clip;
9276 #ifdef NK_INCLUDE_COMMAND_USERDATA 9277 cmd->userdata = list->userdata;
9281 list->clip_rect = clip;
9285 nk_draw_list_command_last(
struct nk_draw_list *list)
9289 struct nk_draw_command *
cmd;
9290 NK_ASSERT(list->cmd_count);
9294 cmd =
nk_ptr_add(
struct nk_draw_command, memory, size - list->cmd_offset);
9295 return (cmd - (list->cmd_count-1));
9298 nk_draw_list_add_clip(
struct nk_draw_list *list,
struct nk_rect rect)
9302 if (!list->cmd_count) {
9303 nk_draw_list_push_command(list, rect, list->config.null.texture);
9305 struct nk_draw_command *prev = nk_draw_list_command_last(list);
9306 if (prev->elem_count == 0)
9307 prev->clip_rect = rect;
9308 nk_draw_list_push_command(list, rect, prev->texture);
9312 nk_draw_list_push_image(
struct nk_draw_list *list, nk_handle texture)
9316 if (!list->cmd_count) {
9317 nk_draw_list_push_command(list, nk_null_rect, texture);
9319 struct nk_draw_command *prev = nk_draw_list_command_last(list);
9320 if (prev->elem_count == 0) {
9322 #ifdef NK_INCLUDE_COMMAND_USERDATA 9323 prev->userdata = list->userdata;
9325 }
else if (prev->texture.id != texture.
id 9326 #ifdef NK_INCLUDE_COMMAND_USERDATA
9327 || prev->userdata.id != list->userdata.id
9329 ) nk_draw_list_push_command(list, prev->clip_rect, texture);
9332 #ifdef NK_INCLUDE_COMMAND_USERDATA 9334 nk_draw_list_push_userdata(
struct nk_draw_list *list, nk_handle userdata)
9336 list->userdata = userdata;
9340 nk_draw_list_alloc_vertices(
struct nk_draw_list *list, nk_size count)
9344 if (!list)
return 0;
9346 list->config.vertex_size*count, list->config.vertex_alignment);
9348 list->vertex_count += (
unsigned int)count;
9359 NK_ASSERT((
sizeof(nk_draw_index) == 2 && list->vertex_count < NK_USHORT_MAX &&
9360 "To many verticies for 16-bit vertex indicies. Please read comment above on how to solve this problem"));
9364 nk_draw_list_alloc_elements(
struct nk_draw_list *list, nk_size count)
9367 struct nk_draw_command *
cmd;
9369 NK_STORAGE const nk_size elem_size =
sizeof(nk_draw_index);
9371 if (!list)
return 0;
9373 ids = (nk_draw_index*)
9374 nk_buffer_alloc(list->elements,
NK_BUFFER_FRONT, elem_size*count, elem_align);
9376 cmd = nk_draw_list_command_last(list);
9377 list->element_count += (
unsigned int)count;
9378 cmd->elem_count += (
unsigned int)count;
9382 nk_draw_vertex_layout_element_is_end_of_layout(
9383 const struct nk_draw_vertex_layout_element *element)
9385 return (element->attribute == NK_VERTEX_ATTRIBUTE_COUNT ||
9386 element->format == NK_FORMAT_COUNT);
9389 nk_draw_vertex_color(
void *attr,
const float *vals,
9390 enum nk_draw_vertex_layout_format
format)
9394 NK_ASSERT(format >= NK_FORMAT_COLOR_BEGIN);
9395 NK_ASSERT(format <= NK_FORMAT_COLOR_END);
9404 default: NK_ASSERT(0 &&
"Invalid vertex layout color format");
break;
9405 case NK_FORMAT_R8G8B8A8:
9406 case NK_FORMAT_R8G8B8: {
9408 NK_MEMCPY(attr, &col.
r,
sizeof(col));
9410 case NK_FORMAT_B8G8R8A8: {
9412 struct nk_color bgra =
nk_rgba(col.
b, col.
g, col.
r, col.
a);
9413 NK_MEMCPY(attr, &bgra,
sizeof(bgra));
9415 case NK_FORMAT_R16G15B16: {
9417 col[0] = (
nk_ushort)(val[0]*(
float)NK_USHORT_MAX);
9418 col[1] = (
nk_ushort)(val[1]*(
float)NK_USHORT_MAX);
9419 col[2] = (
nk_ushort)(val[2]*(
float)NK_USHORT_MAX);
9420 NK_MEMCPY(attr, col,
sizeof(col));
9422 case NK_FORMAT_R16G15B16A16: {
9424 col[0] = (
nk_ushort)(val[0]*(
float)NK_USHORT_MAX);
9425 col[1] = (
nk_ushort)(val[1]*(
float)NK_USHORT_MAX);
9426 col[2] = (
nk_ushort)(val[2]*(
float)NK_USHORT_MAX);
9427 col[3] = (
nk_ushort)(val[3]*(
float)NK_USHORT_MAX);
9428 NK_MEMCPY(attr, col,
sizeof(col));
9430 case NK_FORMAT_R32G32B32: {
9432 col[0] = (
nk_uint)(val[0]*(
float)NK_UINT_MAX);
9433 col[1] = (
nk_uint)(val[1]*(
float)NK_UINT_MAX);
9434 col[2] = (
nk_uint)(val[2]*(
float)NK_UINT_MAX);
9435 NK_MEMCPY(attr, col,
sizeof(col));
9437 case NK_FORMAT_R32G32B32A32: {
9439 col[0] = (
nk_uint)(val[0]*(
float)NK_UINT_MAX);
9440 col[1] = (
nk_uint)(val[1]*(
float)NK_UINT_MAX);
9441 col[2] = (
nk_uint)(val[2]*(
float)NK_UINT_MAX);
9442 col[3] = (
nk_uint)(val[3]*(
float)NK_UINT_MAX);
9443 NK_MEMCPY(attr, col,
sizeof(col));
9445 case NK_FORMAT_R32G32B32A32_FLOAT:
9446 NK_MEMCPY(attr, val,
sizeof(
float)*4);
9448 case NK_FORMAT_R32G32B32A32_DOUBLE: {
9450 col[0] = (double)val[0];
9451 col[1] = (double)val[1];
9452 col[2] = (double)val[2];
9453 col[3] = (double)val[3];
9454 NK_MEMCPY(attr, col,
sizeof(col));
9456 case NK_FORMAT_RGB32:
9457 case NK_FORMAT_RGBA32: {
9460 NK_MEMCPY(attr, &color,
sizeof(color));
9464 nk_draw_vertex_element(
void *dst,
const float *
values,
int value_count,
9465 enum nk_draw_vertex_layout_format format)
9470 NK_ASSERT(format < NK_FORMAT_COLOR_BEGIN);
9471 if (format >= NK_FORMAT_COLOR_BEGIN && format <= NK_FORMAT_COLOR_END)
return;
9472 for (value_index = 0; value_index < value_count; ++value_index) {
9474 default: NK_ASSERT(0 &&
"invalid vertex layout format");
break;
9475 case NK_FORMAT_SCHAR: {
9476 char value = (char)
NK_CLAMP((
float)NK_SCHAR_MIN, values[value_index], (float)NK_SCHAR_MAX);
9477 NK_MEMCPY(attribute, &value,
sizeof(value));
9478 attribute = (
void*)((
char*)attribute +
sizeof(char));
9480 case NK_FORMAT_SSHORT: {
9481 nk_short value = (
nk_short)
NK_CLAMP((
float)NK_SSHORT_MIN, values[value_index], (float)NK_SSHORT_MAX);
9482 NK_MEMCPY(attribute, &value,
sizeof(value));
9483 attribute = (
void*)((
char*)attribute +
sizeof(
value));
9485 case NK_FORMAT_SINT: {
9486 nk_int value = (
nk_int)
NK_CLAMP((
float)NK_SINT_MIN, values[value_index], (float)NK_SINT_MAX);
9487 NK_MEMCPY(attribute, &value,
sizeof(value));
9488 attribute = (
void*)((
char*)attribute +
sizeof(
nk_int));
9490 case NK_FORMAT_UCHAR: {
9491 unsigned char value = (
unsigned char)
NK_CLAMP((
float)NK_UCHAR_MIN, values[value_index], (float)NK_UCHAR_MAX);
9492 NK_MEMCPY(attribute, &value,
sizeof(value));
9493 attribute = (
void*)((
char*)attribute +
sizeof(
unsigned char));
9495 case NK_FORMAT_USHORT: {
9496 nk_ushort value = (
nk_ushort)
NK_CLAMP((
float)NK_USHORT_MIN, values[value_index], (float)NK_USHORT_MAX);
9497 NK_MEMCPY(attribute, &value,
sizeof(value));
9498 attribute = (
void*)((
char*)attribute +
sizeof(
value));
9500 case NK_FORMAT_UINT: {
9501 nk_uint value = (
nk_uint)
NK_CLAMP((
float)NK_UINT_MIN, values[value_index], (float)NK_UINT_MAX);
9502 NK_MEMCPY(attribute, &value,
sizeof(value));
9503 attribute = (
void*)((
char*)attribute +
sizeof(
nk_uint));
9505 case NK_FORMAT_FLOAT:
9506 NK_MEMCPY(attribute, &values[value_index],
sizeof(values[value_index]));
9507 attribute = (
void*)((
char*)attribute +
sizeof(float));
9509 case NK_FORMAT_DOUBLE: {
9510 double value = (double)values[value_index];
9511 NK_MEMCPY(attribute, &value,
sizeof(value));
9512 attribute = (
void*)((
char*)attribute +
sizeof(double));
9521 void *result = (
void*)((
char*)dst + config->
vertex_size);
9522 const struct nk_draw_vertex_layout_element *elem_iter = config->
vertex_layout;
9523 while (!nk_draw_vertex_layout_element_is_end_of_layout(elem_iter)) {
9524 void *
address = (
void*)((
char*)dst + elem_iter->offset);
9525 switch (elem_iter->attribute) {
9526 case NK_VERTEX_ATTRIBUTE_COUNT:
9527 default: NK_ASSERT(0 &&
"wrong element attribute");
break;
9528 case NK_VERTEX_POSITION: nk_draw_vertex_element(address, &pos.
x, 2, elem_iter->format);
break;
9529 case NK_VERTEX_TEXCOORD: nk_draw_vertex_element(address, &uv.
x, 2, elem_iter->format);
break;
9530 case NK_VERTEX_COLOR: nk_draw_vertex_color(address, &color.
r, elem_iter->format);
break;
9537 nk_draw_list_stroke_poly_line(
struct nk_draw_list *list,
const struct nk_vec2 *points,
9538 const unsigned int points_count,
struct nk_color color,
enum nk_draw_list_stroke closed,
9546 if (!list || points_count < 2)
return;
9548 color.
a = (
nk_byte)((
float)color.
a * list->config.global_alpha);
9549 count = points_count;
9550 if (!closed) count = points_count-1;
9551 thick_line = thickness > 1.0f;
9553 #ifdef NK_INCLUDE_COMMAND_USERDATA 9554 nk_draw_list_push_userdata(list, list->userdata);
9557 color.
a = (
nk_byte)((
float)color.
a * list->config.global_alpha);
9562 if (aliasing == NK_ANTI_ALIASING_ON) {
9564 const float AA_SIZE = 1.0f;
9570 nk_size vertex_offset;
9571 nk_size index = list->vertex_count;
9573 const nk_size idx_count = (thick_line) ? (count * 18) : (count * 12);
9574 const nk_size vtx_count = (thick_line) ? (points_count * 4): (points_count *3);
9576 void *vtx = nk_draw_list_alloc_vertices(list, vtx_count);
9577 nk_draw_index *ids = nk_draw_list_alloc_elements(list, idx_count);
9580 struct nk_vec2 *normals, *temp;
9581 if (!vtx || !ids)
return;
9584 vertex_offset = (
nk_size)((nk_byte*)vtx - (nk_byte*)list->vertices->memory.ptr);
9586 size = pnt_size * ((thick_line) ? 5 : 3) * points_count;
9588 if (!normals)
return;
9589 temp = normals + points_count;
9592 vtx = (
void*)((nk_byte*)list->vertices->memory.ptr + vertex_offset);
9595 for (i1 = 0; i1 <
count; ++
i1) {
9596 const nk_size
i2 = ((i1 + 1) == points_count) ? 0 : (i1 + 1);
9603 len = nk_inv_sqrt(len);
9607 normals[
i1].
x = diff.
y;
9608 normals[
i1].
y = -diff.
x;
9612 normals[points_count-1] = normals[points_count-2];
9621 temp[(points_count-1) * 2 + 0] =
nk_vec2_add(points[points_count-1], d);
9622 temp[(points_count-1) * 2 + 1] =
nk_vec2_sub(points[points_count-1], d);
9627 for (i1 = 0; i1 <
count; i1++) {
9630 nk_size i2 = ((i1 + 1) == points_count) ? 0 : (i1 + 1);
9631 nk_size idx2 = ((i1+1) == points_count) ? index: (idx1 + 3);
9635 dmr2 = dm.x * dm.x + dm.y* dm.y;
9636 if (dmr2 > 0.000001f) {
9637 float scale = 1.0f/dmr2;
9638 scale =
NK_MIN(100.0f, scale);
9646 ids[0] = (nk_draw_index)(idx2 + 0); ids[1] = (nk_draw_index)(idx1+0);
9647 ids[2] = (nk_draw_index)(idx1 + 2); ids[3] = (nk_draw_index)(idx1+2);
9648 ids[4] = (nk_draw_index)(idx2 + 2); ids[5] = (nk_draw_index)(idx2+0);
9649 ids[6] = (nk_draw_index)(idx2 + 1); ids[7] = (nk_draw_index)(idx1+1);
9650 ids[8] = (nk_draw_index)(idx1 + 0); ids[9] = (nk_draw_index)(idx1+0);
9651 ids[10]= (nk_draw_index)(idx2 + 0); ids[11]= (nk_draw_index)(idx2+1);
9657 for (i = 0; i < points_count; ++
i) {
9658 const struct nk_vec2 uv = list->config.null.uv;
9659 vtx = nk_draw_vertex(vtx, &list->config, points[i], uv, col);
9660 vtx = nk_draw_vertex(vtx, &list->config, temp[i*2+0], uv, col_trans);
9661 vtx = nk_draw_vertex(vtx, &list->config, temp[i*2+1], uv, col_trans);
9665 const float half_inner_thickness = (thickness - AA_SIZE) * 0.5f;
9675 d1 =
nk_vec2_muls(normals[points_count-1], half_inner_thickness + AA_SIZE);
9676 d2 =
nk_vec2_muls(normals[points_count-1], half_inner_thickness);
9678 temp[(points_count-1)*4+0] =
nk_vec2_add(points[points_count-1], d1);
9679 temp[(points_count-1)*4+1] =
nk_vec2_add(points[points_count-1], d2);
9680 temp[(points_count-1)*4+2] =
nk_vec2_sub(points[points_count-1], d2);
9681 temp[(points_count-1)*4+3] =
nk_vec2_sub(points[points_count-1], d1);
9686 for (i1 = 0; i1 <
count; ++
i1) {
9688 const nk_size i2 = ((i1+1) == points_count) ? 0: (i1 + 1);
9689 nk_size idx2 = ((i1+1) == points_count) ? index: (idx1 + 4);
9693 float dmr2 = dm.
x * dm.
x + dm.
y* dm.
y;
9694 if (dmr2 > 0.000001f) {
9695 float scale = 1.0f/dmr2;
9696 scale =
NK_MIN(100.0f, scale);
9700 dm_out =
nk_vec2_muls(dm, ((half_inner_thickness) + AA_SIZE));
9708 ids[0] = (nk_draw_index)(idx2 + 1); ids[1] = (nk_draw_index)(idx1+1);
9709 ids[2] = (nk_draw_index)(idx1 + 2); ids[3] = (nk_draw_index)(idx1+2);
9710 ids[4] = (nk_draw_index)(idx2 + 2); ids[5] = (nk_draw_index)(idx2+1);
9711 ids[6] = (nk_draw_index)(idx2 + 1); ids[7] = (nk_draw_index)(idx1+1);
9712 ids[8] = (nk_draw_index)(idx1 + 0); ids[9] = (nk_draw_index)(idx1+0);
9713 ids[10]= (nk_draw_index)(idx2 + 0); ids[11] = (nk_draw_index)(idx2+1);
9714 ids[12]= (nk_draw_index)(idx2 + 2); ids[13] = (nk_draw_index)(idx1+2);
9715 ids[14]= (nk_draw_index)(idx1 + 3); ids[15] = (nk_draw_index)(idx1+3);
9716 ids[16]= (nk_draw_index)(idx2 + 3); ids[17] = (nk_draw_index)(idx2+2);
9722 for (i = 0; i < points_count; ++
i) {
9723 const struct nk_vec2 uv = list->config.null.uv;
9724 vtx = nk_draw_vertex(vtx, &list->config, temp[i*4+0], uv, col_trans);
9725 vtx = nk_draw_vertex(vtx, &list->config, temp[i*4+1], uv, col);
9726 vtx = nk_draw_vertex(vtx, &list->config, temp[i*4+2], uv, col);
9727 vtx = nk_draw_vertex(vtx, &list->config, temp[i*4+3], uv, col_trans);
9735 nk_size
idx = list->vertex_count;
9736 const nk_size idx_count = count * 6;
9737 const nk_size vtx_count = count * 4;
9738 void *vtx = nk_draw_list_alloc_vertices(list, vtx_count);
9739 nk_draw_index *ids = nk_draw_list_alloc_elements(list, idx_count);
9740 if (!vtx || !ids)
return;
9742 for (i1 = 0; i1 <
count; ++
i1) {
9744 const struct nk_vec2 uv = list->config.null.uv;
9745 const nk_size i2 = ((i1+1) == points_count) ? 0 : i1 + 1;
9754 len = nk_inv_sqrt(len);
9759 dx = diff.
x * (thickness * 0.5f);
9760 dy = diff.
y * (thickness * 0.5f);
9762 vtx = nk_draw_vertex(vtx, &list->config,
nk_vec2(p1.
x + dy, p1.
y - dx), uv, col);
9763 vtx = nk_draw_vertex(vtx, &list->config,
nk_vec2(p2.
x + dy, p2.
y - dx), uv, col);
9764 vtx = nk_draw_vertex(vtx, &list->config,
nk_vec2(p2.
x - dy, p2.
y + dx), uv, col);
9765 vtx = nk_draw_vertex(vtx, &list->config,
nk_vec2(p1.
x - dy, p1.
y + dx), uv, col);
9767 ids[0] = (nk_draw_index)(idx+0); ids[1] = (nk_draw_index)(idx+1);
9768 ids[2] = (nk_draw_index)(idx+2); ids[3] = (nk_draw_index)(idx+0);
9769 ids[4] = (nk_draw_index)(idx+2); ids[5] = (nk_draw_index)(idx+3);
9777 nk_draw_list_fill_poly_convex(
struct nk_draw_list *list,
9778 const struct nk_vec2 *points,
const unsigned int points_count,
9787 if (!list || points_count < 3)
return;
9789 #ifdef NK_INCLUDE_COMMAND_USERDATA 9790 nk_draw_list_push_userdata(list, list->userdata);
9793 color.
a = (
nk_byte)((
float)color.
a * list->config.global_alpha);
9798 if (aliasing == NK_ANTI_ALIASING_ON) {
9803 const float AA_SIZE = 1.0f;
9804 nk_size vertex_offset = 0;
9805 nk_size index = list->vertex_count;
9807 const nk_size idx_count = (points_count-2)*3 + points_count*6;
9808 const nk_size vtx_count = (points_count*2);
9810 void *vtx = nk_draw_list_alloc_vertices(list, vtx_count);
9811 nk_draw_index *ids = nk_draw_list_alloc_elements(list, idx_count);
9815 unsigned int vtx_inner_idx = (
unsigned int)(index + 0);
9816 unsigned int vtx_outer_idx = (
unsigned int)(index + 1);
9817 if (!vtx || !ids)
return;
9820 vertex_offset = (
nk_size)((nk_byte*)vtx - (nk_byte*)list->vertices->memory.ptr);
9822 size = pnt_size * points_count;
9824 if (!normals)
return;
9825 vtx = (
void*)((nk_byte*)list->vertices->memory.ptr + vertex_offset);
9828 for (i = 2; i < points_count; i++) {
9829 ids[0] = (nk_draw_index)(vtx_inner_idx);
9830 ids[1] = (nk_draw_index)(vtx_inner_idx + ((i-1) << 1));
9831 ids[2] = (nk_draw_index)(vtx_inner_idx + (i << 1));
9836 for (i0 = points_count-1, i1 = 0; i1 < points_count; i0 = i1++) {
9837 struct nk_vec2 p0 = points[i0];
9844 len = nk_inv_sqrt(len);
9848 normals[i0].
x = diff.
y;
9849 normals[i0].
y = -diff.
x;
9853 for (i0 = points_count-1, i1 = 0; i1 < points_count; i0 = i1++) {
9854 const struct nk_vec2 uv = list->config.null.uv;
9855 struct nk_vec2 n0 = normals[i0];
9858 float dmr2 = dm.
x*dm.
x + dm.
y*dm.
y;
9859 if (dmr2 > 0.000001f) {
9860 float scale = 1.0f / dmr2;
9861 scale =
NK_MIN(scale, 100.0f);
9867 vtx = nk_draw_vertex(vtx, &list->config,
nk_vec2_sub(points[i1], dm), uv, col);
9868 vtx = nk_draw_vertex(vtx, &list->config,
nk_vec2_add(points[i1], dm), uv, col_trans);
9871 ids[0] = (nk_draw_index)(vtx_inner_idx+(i1<<1));
9872 ids[1] = (nk_draw_index)(vtx_inner_idx+(i0<<1));
9873 ids[2] = (nk_draw_index)(vtx_outer_idx+(i0<<1));
9874 ids[3] = (nk_draw_index)(vtx_outer_idx+(i0<<1));
9875 ids[4] = (nk_draw_index)(vtx_outer_idx+(i1<<1));
9876 ids[5] = (nk_draw_index)(vtx_inner_idx+(i1<<1));
9883 nk_size index = list->vertex_count;
9884 const nk_size idx_count = (points_count-2)*3;
9885 const nk_size vtx_count = points_count;
9886 void *vtx = nk_draw_list_alloc_vertices(list, vtx_count);
9887 nk_draw_index *ids = nk_draw_list_alloc_elements(list, idx_count);
9889 if (!vtx || !ids)
return;
9890 for (i = 0; i < vtx_count; ++
i)
9891 vtx = nk_draw_vertex(vtx, &list->config, points[i], list->config.null.uv, col);
9892 for (i = 2; i < points_count; ++
i) {
9893 ids[0] = (nk_draw_index)index;
9894 ids[1] = (nk_draw_index)(index+ i - 1);
9895 ids[2] = (nk_draw_index)(index+i);
9901 nk_draw_list_path_clear(
struct nk_draw_list *list)
9906 list->path_count = 0;
9907 list->path_offset = 0;
9910 nk_draw_list_path_line_to(
struct nk_draw_list *list,
struct nk_vec2 pos)
9913 struct nk_draw_command *cmd = 0;
9916 if (!list->cmd_count)
9917 nk_draw_list_add_clip(list, nk_null_rect);
9919 cmd = nk_draw_list_command_last(list);
9920 if (cmd && cmd->texture.ptr != list->config.null.texture.ptr)
9921 nk_draw_list_push_image(list, list->config.null.texture);
9923 points = nk_draw_list_alloc_path(list, 1);
9924 if (!points)
return;
9928 nk_draw_list_path_arc_to_fast(
struct nk_draw_list *list,
struct nk_vec2 center,
9929 float radius,
int a_min,
int a_max)
9934 if (a_min <= a_max) {
9935 for (a = a_min; a <= a_max; a++) {
9937 const float x = center.
x + c.
x * radius;
9938 const float y = center.
y + c.
y * radius;
9939 nk_draw_list_path_line_to(list,
nk_vec2(x, y));
9944 nk_draw_list_path_arc_to(
struct nk_draw_list *list,
struct nk_vec2 center,
9945 float radius,
float a_min,
float a_max,
unsigned int segments)
9950 if (radius == 0.0f)
return;
9970 {
const float d_angle = (a_max - a_min) / (
float)
segments;
9971 const float sin_d = (float)NK_SIN(d_angle);
9972 const float cos_d = (float)NK_COS(d_angle);
9974 float cx = (float)NK_COS(a_min) * radius;
9975 float cy = (float)NK_SIN(a_min) * radius;
9977 float new_cx, new_cy;
9978 const float x = center.
x + cx;
9979 const float y = center.
y + cy;
9980 nk_draw_list_path_line_to(list,
nk_vec2(x, y));
9982 new_cx = cx * cos_d - cy * sin_d;
9983 new_cy = cy * cos_d + cx * sin_d;
9989 nk_draw_list_path_rect_to(
struct nk_draw_list *list,
struct nk_vec2 a,
9990 struct nk_vec2 b,
float rounding)
9996 r =
NK_MIN(r, ((b.
x-a.
x) < 0) ? -(b.
x-a.
x): (b.
x-a.
x));
9997 r =
NK_MIN(r, ((b.
y-a.
y) < 0) ? -(b.
y-a.
y): (b.
y-a.
y));
10000 nk_draw_list_path_line_to(list, a);
10001 nk_draw_list_path_line_to(list,
nk_vec2(b.
x,a.
y));
10002 nk_draw_list_path_line_to(list, b);
10003 nk_draw_list_path_line_to(list,
nk_vec2(a.
x,b.
y));
10005 nk_draw_list_path_arc_to_fast(list,
nk_vec2(a.
x + r, a.
y + r), r, 6, 9);
10006 nk_draw_list_path_arc_to_fast(list,
nk_vec2(b.
x - r, a.
y + r), r, 9, 12);
10007 nk_draw_list_path_arc_to_fast(list,
nk_vec2(b.
x - r, b.
y - r), r, 0, 3);
10008 nk_draw_list_path_arc_to_fast(list,
nk_vec2(a.
x + r, b.
y - r), r, 3, 6);
10012 nk_draw_list_path_curve_to(
struct nk_draw_list *list,
struct nk_vec2 p2,
10013 struct nk_vec2 p3,
struct nk_vec2 p4,
unsigned int num_segments)
10016 unsigned int i_step;
10020 NK_ASSERT(list->path_count);
10021 if (!list || !list->path_count)
return;
10022 num_segments =
NK_MAX(num_segments, 1);
10024 p1 = nk_draw_list_path_last(list);
10025 t_step = 1.0f/(float)num_segments;
10026 for (i_step = 1; i_step <= num_segments; ++i_step) {
10027 float t = t_step * (float)i_step;
10028 float u = 1.0f -
t;
10030 float w2 = 3*u*u*
t;
10031 float w3 = 3*u*t*
t;
10032 float w4 = t * t *
t;
10033 float x = w1 * p1.
x + w2 * p2.
x + w3 * p3.
x + w4 * p4.
x;
10034 float y = w1 * p1.
y + w2 * p2.
y + w3 * p3.
y + w4 * p4.
y;
10035 nk_draw_list_path_line_to(list,
nk_vec2(x,y));
10039 nk_draw_list_path_fill(
struct nk_draw_list *list,
struct nk_color color)
10045 nk_draw_list_fill_poly_convex(list, points, list->path_count, color, list->config.shape_AA);
10046 nk_draw_list_path_clear(list);
10049 nk_draw_list_path_stroke(
struct nk_draw_list *list,
struct nk_color color,
10050 enum nk_draw_list_stroke closed,
float thickness)
10056 nk_draw_list_stroke_poly_line(list, points, list->path_count, color,
10057 closed, thickness, list->config.line_AA);
10058 nk_draw_list_path_clear(list);
10061 nk_draw_list_stroke_line(
struct nk_draw_list *list,
struct nk_vec2 a,
10062 struct nk_vec2 b,
struct nk_color col,
float thickness)
10065 if (!list || !col.
a)
return;
10066 if (list->line_AA == NK_ANTI_ALIASING_ON) {
10067 nk_draw_list_path_line_to(list, a);
10068 nk_draw_list_path_line_to(list, b);
10073 nk_draw_list_path_stroke(list, col, NK_STROKE_OPEN, thickness);
10076 nk_draw_list_fill_rect(
struct nk_draw_list *list,
struct nk_rect rect,
10077 struct nk_color col,
float rounding)
10080 if (!list || !col.
a)
return;
10082 if (list->line_AA == NK_ANTI_ALIASING_ON) {
10083 nk_draw_list_path_rect_to(list,
nk_vec2(rect.
x, rect.
y),
10084 nk_vec2(rect.
x + rect.
w, rect.
y + rect.
h), rounding);
10086 nk_draw_list_path_rect_to(list,
nk_vec2(rect.
x-0.5f, rect.
y-0.5f),
10087 nk_vec2(rect.
x + rect.
w, rect.
y + rect.
h), rounding);
10088 } nk_draw_list_path_fill(list, col);
10091 nk_draw_list_stroke_rect(
struct nk_draw_list *list,
struct nk_rect rect,
10092 struct nk_color col,
float rounding,
float thickness)
10095 if (!list || !col.
a)
return;
10096 if (list->line_AA == NK_ANTI_ALIASING_ON) {
10097 nk_draw_list_path_rect_to(list,
nk_vec2(rect.
x, rect.
y),
10098 nk_vec2(rect.
x + rect.
w, rect.
y + rect.
h), rounding);
10100 nk_draw_list_path_rect_to(list,
nk_vec2(rect.
x-0.5f, rect.
y-0.5f),
10101 nk_vec2(rect.
x + rect.
w, rect.
y + rect.
h), rounding);
10102 } nk_draw_list_path_stroke(list, col, NK_STROKE_CLOSED, thickness);
10105 nk_draw_list_fill_rect_multi_color(
struct nk_draw_list *list,
struct nk_rect rect,
10106 struct nk_color left,
struct nk_color top,
struct nk_color right,
10107 struct nk_color bottom)
10111 struct nk_colorf col_right, col_bottom;
10112 nk_draw_index *
idx;
10113 nk_draw_index
index;
10123 nk_draw_list_push_image(list, list->config.null.texture);
10124 index = (nk_draw_index)list->vertex_count;
10125 vtx = nk_draw_list_alloc_vertices(list, 4);
10126 idx = nk_draw_list_alloc_elements(list, 6);
10127 if (!vtx || !idx)
return;
10129 idx[0] = (nk_draw_index)(index+0); idx[1] = (nk_draw_index)(index+1);
10130 idx[2] = (nk_draw_index)(index+2); idx[3] = (nk_draw_index)(index+0);
10131 idx[4] = (nk_draw_index)(index+2); idx[5] = (nk_draw_index)(index+3);
10133 vtx = nk_draw_vertex(vtx, &list->config,
nk_vec2(rect.
x, rect.
y), list->config.null.uv, col_left);
10134 vtx = nk_draw_vertex(vtx, &list->config,
nk_vec2(rect.
x + rect.
w, rect.
y), list->config.null.uv, col_top);
10135 vtx = nk_draw_vertex(vtx, &list->config,
nk_vec2(rect.
x + rect.
w, rect.
y + rect.
h), list->config.null.uv, col_right);
10136 vtx = nk_draw_vertex(vtx, &list->config,
nk_vec2(rect.
x, rect.
y + rect.
h), list->config.null.uv, col_bottom);
10139 nk_draw_list_fill_triangle(
struct nk_draw_list *list,
struct nk_vec2 a,
10143 if (!list || !col.
a)
return;
10144 nk_draw_list_path_line_to(list, a);
10145 nk_draw_list_path_line_to(list, b);
10146 nk_draw_list_path_line_to(list, c);
10147 nk_draw_list_path_fill(list, col);
10150 nk_draw_list_stroke_triangle(
struct nk_draw_list *list,
struct nk_vec2 a,
10151 struct nk_vec2 b,
struct nk_vec2 c,
struct nk_color col,
float thickness)
10154 if (!list || !col.
a)
return;
10155 nk_draw_list_path_line_to(list, a);
10156 nk_draw_list_path_line_to(list, b);
10157 nk_draw_list_path_line_to(list, c);
10158 nk_draw_list_path_stroke(list, col, NK_STROKE_CLOSED, thickness);
10161 nk_draw_list_fill_circle(
struct nk_draw_list *list,
struct nk_vec2 center,
10162 float radius,
struct nk_color col,
unsigned int segs)
10166 if (!list || !col.
a)
return;
10167 a_max =
NK_PI * 2.0f * ((float)segs - 1.0f) / (float)segs;
10168 nk_draw_list_path_arc_to(list, center, radius, 0.0f, a_max, segs);
10169 nk_draw_list_path_fill(list, col);
10172 nk_draw_list_stroke_circle(
struct nk_draw_list *list,
struct nk_vec2 center,
10173 float radius,
struct nk_color col,
unsigned int segs,
float thickness)
10177 if (!list || !col.
a)
return;
10178 a_max =
NK_PI * 2.0f * ((float)segs - 1.0f) / (float)segs;
10179 nk_draw_list_path_arc_to(list, center, radius, 0.0f, a_max, segs);
10180 nk_draw_list_path_stroke(list, col, NK_STROKE_CLOSED, thickness);
10183 nk_draw_list_stroke_curve(
struct nk_draw_list *list,
struct nk_vec2 p0,
10185 struct nk_color col,
unsigned int segments,
float thickness)
10188 if (!list || !col.
a)
return;
10189 nk_draw_list_path_line_to(list, p0);
10190 nk_draw_list_path_curve_to(list, cp0, cp1, p1, segments);
10191 nk_draw_list_path_stroke(list, col, NK_STROKE_OPEN, thickness);
10194 nk_draw_list_push_rect_uv(
struct nk_draw_list *list,
struct nk_vec2 a,
10196 struct nk_color color)
10205 nk_draw_index *
idx;
10206 nk_draw_index
index;
10216 index = (nk_draw_index)list->vertex_count;
10217 vtx = nk_draw_list_alloc_vertices(list, 4);
10218 idx = nk_draw_list_alloc_elements(list, 6);
10219 if (!vtx || !idx)
return;
10221 idx[0] = (nk_draw_index)(index+0); idx[1] = (nk_draw_index)(index+1);
10222 idx[2] = (nk_draw_index)(index+2); idx[3] = (nk_draw_index)(index+0);
10223 idx[4] = (nk_draw_index)(index+2); idx[5] = (nk_draw_index)(index+3);
10225 vtx = nk_draw_vertex(vtx, &list->config, a, uva, col);
10226 vtx = nk_draw_vertex(vtx, &list->config, b, uvb, col);
10227 vtx = nk_draw_vertex(vtx, &list->config, c, uvc, col);
10228 vtx = nk_draw_vertex(vtx, &list->config, d, uvd, col);
10231 nk_draw_list_add_image(
struct nk_draw_list *list,
struct nk_image texture,
10232 struct nk_rect rect,
struct nk_color color)
10237 nk_draw_list_push_image(list, texture.
handle);
10241 uv[0].
x = (float)texture.
region[0]/(
float)texture.
w;
10242 uv[0].
y = (float)texture.
region[1]/(
float)texture.
h;
10243 uv[1].
x = (float)(texture.
region[0] + texture.
region[2])/(float)texture.
w;
10244 uv[1].
y = (
float)(texture.
region[1] + texture.
region[3])/(
float)texture.
h;
10245 nk_draw_list_push_rect_uv(list,
nk_vec2(rect.
x, rect.
y),
10246 nk_vec2(rect.
x + rect.
w, rect.
y + rect.
h), uv[0], uv[1], color);
10247 }
else nk_draw_list_push_rect_uv(list,
nk_vec2(rect.
x, rect.
y),
10252 nk_draw_list_add_text(
struct nk_draw_list *list,
const struct nk_user_font *font,
10253 struct nk_rect rect,
const char *text,
int len,
float font_height,
10254 struct nk_color fg)
10258 nk_rune unicode = 0;
10261 int next_glyph_len = 0;
10262 struct nk_user_font_glyph g;
10265 if (!list || !len || !text)
return;
10267 list->clip_rect.x, list->clip_rect.y, list->clip_rect.w, list->clip_rect.h))
return;
10269 nk_draw_list_push_image(list, font->texture);
10272 if (!glyph_len)
return;
10275 fg.
a = (
nk_byte)((
float)fg.
a * list->config.global_alpha);
10276 while (text_len < len && glyph_len) {
10277 float gx, gy, gh, gw;
10278 float char_width = 0;
10282 next_glyph_len =
nk_utf_decode(text + text_len + glyph_len, &next, (
int)len - text_len);
10283 font->query(font->
userdata, font_height, &g, unicode,
10287 gx = x + g.offset.x;
10288 gy = rect.
y + g.offset.y;
10289 gw = g.width; gh = g.height;
10290 char_width = g.xadvance;
10291 nk_draw_list_push_rect_uv(list,
nk_vec2(gx,gy),
nk_vec2(gx + gw, gy+ gh),
10292 g.uv[0], g.uv[1], fg);
10295 text_len += glyph_len;
10297 glyph_len = next_glyph_len;
10302 nk_convert(
struct nk_context *
ctx,
struct nk_buffer *cmds,
10310 NK_ASSERT(vertices);
10311 NK_ASSERT(elements);
10315 if (!ctx || !cmds || !vertices || !elements || !config || !config->
vertex_layout)
10318 nk_draw_list_setup(&ctx->draw_list, config, cmds, vertices, elements,
10322 #ifdef NK_INCLUDE_COMMAND_USERDATA 10323 ctx->draw_list.userdata = cmd->userdata;
10325 switch (cmd->
type) {
10329 nk_draw_list_add_clip(&ctx->draw_list,
nk_rect(s->
x, s->
y, s->
w, s->
h));
10345 nk_draw_list_stroke_rect(&ctx->draw_list,
nk_rect(r->
x, r->
y, r->
w, r->
h),
10350 nk_draw_list_fill_rect(&ctx->draw_list,
nk_rect(r->
x, r->
y, r->
w, r->
h),
10355 nk_draw_list_fill_rect_multi_color(&ctx->draw_list,
nk_rect(r->
x, r->
y, r->
w, r->
h),
10360 nk_draw_list_stroke_circle(&ctx->draw_list,
nk_vec2((
float)c->
x + (
float)c->
w/2,
10361 (
float)c->
y + (
float)c->
h/2), (
float)c->
w/2, c->
color,
10366 nk_draw_list_fill_circle(&ctx->draw_list,
nk_vec2((
float)c->
x + (
float)c->
w/2,
10367 (
float)c->
y + (
float)c->
h/2), (
float)c->
w/2, c->
color,
10372 nk_draw_list_path_line_to(&ctx->draw_list,
nk_vec2(c->
cx, c->
cy));
10373 nk_draw_list_path_arc_to(&ctx->draw_list,
nk_vec2(c->
cx, c->
cy), c->
r,
10375 nk_draw_list_path_stroke(&ctx->draw_list, c->
color, NK_STROKE_CLOSED, c->
line_thickness);
10379 nk_draw_list_path_line_to(&ctx->draw_list,
nk_vec2(c->
cx, c->
cy));
10380 nk_draw_list_path_arc_to(&ctx->draw_list,
nk_vec2(c->
cx, c->
cy), c->
r,
10382 nk_draw_list_path_fill(&ctx->draw_list, c->
color);
10386 nk_draw_list_stroke_triangle(&ctx->draw_list,
nk_vec2(t->
a.
x, t->
a.
y),
10392 nk_draw_list_fill_triangle(&ctx->draw_list,
nk_vec2(t->
a.
x, t->
a.
y),
10400 nk_draw_list_path_line_to(&ctx->draw_list, pnt);
10402 nk_draw_list_path_stroke(&ctx->draw_list, p->
color, NK_STROKE_CLOSED, p->
line_thickness);
10409 nk_draw_list_path_line_to(&ctx->draw_list, pnt);
10411 nk_draw_list_path_fill(&ctx->draw_list, p->
color);
10418 nk_draw_list_path_line_to(&ctx->draw_list, pnt);
10424 nk_draw_list_add_text(&ctx->draw_list, t->
font,
nk_rect(t->
x, t->
y, t->
w, t->
h),
10429 nk_draw_list_add_image(&ctx->draw_list, i->
img,
nk_rect(i->
x, i->
y, i->
w, i->
h), i->
col);
10443 NK_API const struct nk_draw_command*
10444 nk__draw_begin(
const struct nk_context *ctx,
10447 return nk__draw_list_begin(&ctx->draw_list, buffer);
10449 NK_API const struct nk_draw_command*
10450 nk__draw_end(
const struct nk_context *ctx,
const struct nk_buffer *buffer)
10452 return nk__draw_list_end(&ctx->draw_list, buffer);
10454 NK_API const struct nk_draw_command*
10455 nk__draw_next(
const struct nk_draw_command *cmd,
10456 const struct nk_buffer *buffer,
const struct nk_context *ctx)
10458 return nk__draw_list_next(cmd, buffer, &ctx->draw_list);
10466 #ifdef NK_INCLUDE_FONT_BAKING 10474 #define NK_RP__MAXVAL 0xffff 10475 typedef unsigned short nk_rp_coord;
10477 struct nk_rp_rect {
10488 struct nk_rp_node {
10490 struct nk_rp_node *
next;
10493 struct nk_rp_context {
10500 struct nk_rp_node *active_head;
10501 struct nk_rp_node *free_head;
10502 struct nk_rp_node extra[2];
10506 struct nk_rp__findresult {
10508 struct nk_rp_node **prev_link;
10511 enum NK_RP_HEURISTIC {
10512 NK_RP_HEURISTIC_Skyline_default=0,
10513 NK_RP_HEURISTIC_Skyline_BL_sortHeight = NK_RP_HEURISTIC_Skyline_default,
10514 NK_RP_HEURISTIC_Skyline_BF_sortHeight
10516 enum NK_RP_INIT_STATE{NK_RP__INIT_skyline = 1};
10519 nk_rp_setup_allow_out_of_mem(
struct nk_rp_context *context,
int allow_out_of_mem)
10521 if (allow_out_of_mem)
10526 context->align = 1;
10534 context->align = (context->width + context->num_nodes-1) / context->num_nodes;
10538 nk_rp_init_target(
struct nk_rp_context *context,
int width,
int height,
10539 struct nk_rp_node *nodes,
int num_nodes)
10542 #ifndef STBRP_LARGE_RECTS 10543 NK_ASSERT(width <= 0xffff && height <= 0xffff);
10546 for (i=0; i < num_nodes-1; ++
i)
10547 nodes[i].next = &nodes[i+1];
10549 context->init_mode = NK_RP__INIT_skyline;
10550 context->heuristic = NK_RP_HEURISTIC_Skyline_default;
10551 context->free_head = &nodes[0];
10552 context->active_head = &context->extra[0];
10553 context->width =
width;
10554 context->height =
height;
10555 context->num_nodes = num_nodes;
10556 nk_rp_setup_allow_out_of_mem(context, 0);
10559 context->extra[0].x = 0;
10560 context->extra[0].y = 0;
10561 context->extra[0].next = &context->extra[1];
10562 context->extra[1].x = (nk_rp_coord) width;
10563 context->extra[1].y = 65535;
10564 context->extra[1].next = 0;
10568 nk_rp__skyline_find_min_y(
struct nk_rp_context *c,
struct nk_rp_node *
first,
10569 int x0,
int width,
int *pwaste)
10571 struct nk_rp_node *node =
first;
10572 int x1 = x0 +
width;
10573 int min_y, visited_width, waste_area;
10574 NK_ASSERT(first->x <= x0);
10577 NK_ASSERT(node->next->x > x0);
10579 NK_ASSERT(node->x <= x0);
10584 while (node->x < x1)
10586 if (node->y > min_y) {
10590 waste_area += visited_width * (node->y - min_y);
10594 visited_width += node->next->x -
x0;
10596 visited_width += node->next->x - node->x;
10599 int under_width = node->next->x - node->x;
10600 if (under_width + visited_width > width)
10601 under_width = width - visited_width;
10602 waste_area += under_width * (min_y - node->y);
10603 visited_width += under_width;
10607 *pwaste = waste_area;
10611 nk_rp__skyline_find_best_pos(struct nk_rp_context *
c,
int width,
int height)
10613 int best_waste = (1<<30), best_x, best_y = (1 << 30);
10614 struct nk_rp__findresult fr;
10615 struct nk_rp_node **prev, *node, *tail, **best = 0;
10618 width = (width + c->align - 1);
10619 width -= width % c->align;
10620 NK_ASSERT(width % c->align == 0);
10622 node = c->active_head;
10623 prev = &c->active_head;
10626 y = nk_rp__skyline_find_min_y(c, node, node->x, width, &waste);
10628 if (c->heuristic == NK_RP_HEURISTIC_Skyline_BL_sortHeight) {
10638 if (y < best_y || (y == best_y && waste < best_waste)) {
10640 best_waste = waste;
10645 prev = &node->next;
10648 best_x = (best == 0) ? 0 : (*best)->x;
10666 if (c->heuristic == NK_RP_HEURISTIC_Skyline_BF_sortHeight)
10668 tail = c->active_head;
10669 node = c->active_head;
10670 prev = &c->active_head;
10672 while (tail->x < width)
10678 NK_ASSERT(xpos >= 0);
10680 while (node->next->x <= xpos) {
10681 prev = &node->next;
10684 NK_ASSERT(node->next->x > xpos && node->x <= xpos);
10685 y = nk_rp__skyline_find_min_y(c, node, xpos, width, &waste);
10688 if (y < best_y || waste < best_waste || (waste==best_waste && xpos < best_x)) {
10690 NK_ASSERT(y <= best_y);
10692 best_waste = waste;
10700 fr.prev_link = best;
10706 nk_rp__skyline_pack_rectangle(struct nk_rp_context *context,
int width,
int height)
10709 struct nk_rp__findresult res = nk_rp__skyline_find_best_pos(context, width, height);
10710 struct nk_rp_node *node, *cur;
10716 if (res.prev_link == 0 || res.y + height > context->height || context->free_head == 0) {
10722 node = context->free_head;
10723 node->x = (nk_rp_coord) res.x;
10724 node->y = (nk_rp_coord) (res.y +
height);
10726 context->free_head = node->next;
10731 cur = *res.prev_link;
10732 if (cur->x < res.x) {
10734 struct nk_rp_node *next = cur->next;
10738 *res.prev_link = node;
10743 while (cur->next && cur->next->x <= res.x + width) {
10744 struct nk_rp_node *next = cur->next;
10746 cur->next = context->free_head;
10747 context->free_head = cur;
10753 if (cur->x < res.x + width)
10754 cur->x = (nk_rp_coord) (res.x + width);
10758 nk_rect_height_compare(
const void *a,
const void *b)
10760 const struct nk_rp_rect *p = (
const struct nk_rp_rect *) a;
10761 const struct nk_rp_rect *q = (
const struct nk_rp_rect *) b;
10766 return (p->w > q->w) ? -1 : (p->w < q->w);
10769 nk_rect_original_order(
const void *a,
const void *b)
10771 const struct nk_rp_rect *p = (
const struct nk_rp_rect *) a;
10772 const struct nk_rp_rect *q = (
const struct nk_rp_rect *) b;
10773 return (p->was_packed < q->was_packed) ? -1 : (p->was_packed > q->was_packed);
10776 nk_rp_qsort(
struct nk_rp_rect *
array,
unsigned int len,
int(*cmp)(
const void*,
const void*))
10779 #define NK_MAX_SORT_STACK 64 10780 unsigned right, left = 0, stack[NK_MAX_SORT_STACK], pos = 0;
10781 unsigned seed = len/2 * 69069+1;
10783 for (; left+1 <
len; len++) {
10784 struct nk_rp_rect pivot,
tmp;
10785 if (pos == NK_MAX_SORT_STACK) len = stack[pos = 0];
10786 pivot = array[left+seed%(len-
left)];
10787 seed = seed * 69069 + 1;
10788 stack[pos++] =
len;
10789 for (right = left-1;;) {
10790 while (cmp(&array[++right], &pivot) < 0);
10791 while (cmp(&pivot, &array[--len]) < 0);
10792 if (right >= len)
break;
10798 if (pos == 0)
break;
10800 len = stack[--
pos];
10802 #undef NK_MAX_SORT_STACK 10805 nk_rp_pack_rects(
struct nk_rp_context *context,
struct nk_rp_rect *rects,
int num_rects)
10809 for (i=0; i < num_rects; ++
i) {
10810 rects[
i].was_packed =
i;
10814 nk_rp_qsort(rects, (
unsigned)num_rects, nk_rect_height_compare);
10816 for (i=0; i < num_rects; ++
i) {
10817 struct nk_rp__findresult fr = nk_rp__skyline_pack_rectangle(context, rects[i].
w, rects[i].h);
10818 if (fr.prev_link) {
10819 rects[
i].x = (nk_rp_coord) fr.x;
10820 rects[i].y = (nk_rp_coord) fr.y;
10822 rects[
i].x = rects[
i].y = NK_RP__MAXVAL;
10827 nk_rp_qsort(rects, (
unsigned)num_rects, nk_rect_original_order);
10830 for (i=0; i < num_rects; ++
i)
10831 rects[i].was_packed = !(rects[i].x == NK_RP__MAXVAL && rects[i].y == NK_RP__MAXVAL);
10842 #define NK_TT_MAX_OVERSAMPLE 8 10843 #define NK_TT__OVER_MASK (NK_TT_MAX_OVERSAMPLE-1) 10845 struct nk_tt_bakedchar {
10848 float xoff,yoff,xadvance;
10851 struct nk_tt_aligned_quad{
10856 struct nk_tt_packedchar {
10859 float xoff,yoff,xadvance;
10863 struct nk_tt_pack_range {
10865 int first_unicode_codepoint_in_range;
10867 int *array_of_unicode_codepoints;
10870 struct nk_tt_packedchar *chardata_for_range;
10871 unsigned char h_oversample, v_oversample;
10875 struct nk_tt_pack_context {
10879 int stride_in_bytes;
10881 unsigned int h_oversample, v_oversample;
10886 struct nk_tt_fontinfo {
10887 const unsigned char*
data;
10890 int loca,head,glyf,hhea,hmtx,kern;
10892 int indexToLocFormat;
10901 struct nk_tt_vertex {
10903 unsigned char type,padding;
10906 struct nk_tt__bitmap{
10911 struct nk_tt__hheap_chunk {
10912 struct nk_tt__hheap_chunk *
next;
10914 struct nk_tt__hheap {
10916 struct nk_tt__hheap_chunk *head;
10918 int num_remaining_in_head_chunk;
10921 struct nk_tt__edge {
10926 struct nk_tt__active_edge {
10927 struct nk_tt__active_edge *
next;
10933 struct nk_tt__point {
float x,
y;};
10935 #define NK_TT_MACSTYLE_DONTCARE 0 10936 #define NK_TT_MACSTYLE_BOLD 1 10937 #define NK_TT_MACSTYLE_ITALIC 2 10938 #define NK_TT_MACSTYLE_UNDERSCORE 4 10939 #define NK_TT_MACSTYLE_NONE 8 10943 NK_TT_PLATFORM_ID_UNICODE =0,
10944 NK_TT_PLATFORM_ID_MAC =1,
10945 NK_TT_PLATFORM_ID_ISO =2,
10946 NK_TT_PLATFORM_ID_MICROSOFT =3
10950 NK_TT_UNICODE_EID_UNICODE_1_0 =0,
10951 NK_TT_UNICODE_EID_UNICODE_1_1 =1,
10952 NK_TT_UNICODE_EID_ISO_10646 =2,
10953 NK_TT_UNICODE_EID_UNICODE_2_0_BMP=3,
10954 NK_TT_UNICODE_EID_UNICODE_2_0_FULL=4
10958 NK_TT_MS_EID_SYMBOL =0,
10959 NK_TT_MS_EID_UNICODE_BMP =1,
10960 NK_TT_MS_EID_SHIFTJIS =2,
10961 NK_TT_MS_EID_UNICODE_FULL =10
10965 NK_TT_MAC_EID_ROMAN =0, NK_TT_MAC_EID_ARABIC =4,
10966 NK_TT_MAC_EID_JAPANESE =1, NK_TT_MAC_EID_HEBREW =5,
10967 NK_TT_MAC_EID_CHINESE_TRAD =2, NK_TT_MAC_EID_GREEK =6,
10968 NK_TT_MAC_EID_KOREAN =3, NK_TT_MAC_EID_RUSSIAN =7
10973 NK_TT_MS_LANG_ENGLISH =0x0409, NK_TT_MS_LANG_ITALIAN =0x0410,
10974 NK_TT_MS_LANG_CHINESE =0x0804, NK_TT_MS_LANG_JAPANESE =0x0411,
10975 NK_TT_MS_LANG_DUTCH =0x0413, NK_TT_MS_LANG_KOREAN =0x0412,
10976 NK_TT_MS_LANG_FRENCH =0x040c, NK_TT_MS_LANG_RUSSIAN =0x0419,
10977 NK_TT_MS_LANG_GERMAN =0x0407, NK_TT_MS_LANG_SPANISH =0x0409,
10978 NK_TT_MS_LANG_HEBREW =0x040d, NK_TT_MS_LANG_SWEDISH =0x041D
10982 NK_TT_MAC_LANG_ENGLISH =0 , NK_TT_MAC_LANG_JAPANESE =11,
10983 NK_TT_MAC_LANG_ARABIC =12, NK_TT_MAC_LANG_KOREAN =23,
10984 NK_TT_MAC_LANG_DUTCH =4 , NK_TT_MAC_LANG_RUSSIAN =32,
10985 NK_TT_MAC_LANG_FRENCH =1 , NK_TT_MAC_LANG_SPANISH =6 ,
10986 NK_TT_MAC_LANG_GERMAN =2 , NK_TT_MAC_LANG_SWEDISH =5 ,
10987 NK_TT_MAC_LANG_HEBREW =10, NK_TT_MAC_LANG_CHINESE_SIMPLIFIED =33,
10988 NK_TT_MAC_LANG_ITALIAN =3 , NK_TT_MAC_LANG_CHINESE_TRAD =19
10991 #define nk_ttBYTE(p) (* (const nk_byte *) (p)) 10992 #define nk_ttCHAR(p) (* (const char *) (p)) 10994 #if defined(NK_BIGENDIAN) && !defined(NK_ALLOW_UNALIGNED_TRUETYPE) 10995 #define nk_ttUSHORT(p) (* (nk_ushort *) (p)) 10996 #define nk_ttSHORT(p) (* (nk_short *) (p)) 10997 #define nk_ttULONG(p) (* (nk_uint *) (p)) 10998 #define nk_ttLONG(p) (* (nk_int *) (p)) 11000 static nk_ushort nk_ttUSHORT(
const nk_byte *p) {
return (nk_ushort)(p[0]*256 + p[1]); }
11001 static nk_short nk_ttSHORT(
const nk_byte *p) {
return (nk_short)(p[0]*256 + p[1]); }
11002 static nk_uint nk_ttULONG(
const nk_byte *p) {
return (nk_uint)((p[0]<<24) + (p[1]<<16) + (p[2]<<8) + p[3]); }
11005 #define nk_tt_tag4(p,c0,c1,c2,c3)\ 11006 ((p)[0] == (c0) && (p)[1] == (c1) && (p)[2] == (c2) && (p)[3] == (c3)) 11007 #define nk_tt_tag(p,str) nk_tt_tag4(p,str[0],str[1],str[2],str[3]) 11010 int glyph_index,
struct nk_tt_vertex **pvertices);
11013 nk_tt__find_table(
const nk_byte *data, nk_uint fontstart,
const char *
tag)
11016 nk_int num_tables = nk_ttUSHORT(data+fontstart+4);
11017 nk_uint tabledir = fontstart + 12;
11019 for (i = 0; i < num_tables; ++
i) {
11020 nk_uint loc = tabledir + (
nk_uint)(16*i);
11021 if (nk_tt_tag(data+loc+0, tag))
11022 return nk_ttULONG(data+loc+8);
11027 nk_tt_InitFont(
struct nk_tt_fontinfo *
info,
const unsigned char *data2,
int fontstart)
11030 nk_int
i,numTables;
11031 const nk_byte *data = (
const nk_byte *) data2;
11034 info->fontstart = fontstart;
11036 cmap = nk_tt__find_table(data, (nk_uint)fontstart,
"cmap");
11037 info->loca = (int)nk_tt__find_table(data, (nk_uint)fontstart,
"loca");
11038 info->head = (int)nk_tt__find_table(data, (nk_uint)fontstart,
"head");
11039 info->glyf = (int)nk_tt__find_table(data, (nk_uint)fontstart,
"glyf");
11040 info->hhea = (int)nk_tt__find_table(data, (nk_uint)fontstart,
"hhea");
11041 info->hmtx = (int)nk_tt__find_table(data, (nk_uint)fontstart,
"hmtx");
11042 info->kern = (int)nk_tt__find_table(data, (nk_uint)fontstart,
"kern");
11043 if (!cmap || !info->loca || !info->head || !info->glyf || !info->hhea || !info->hmtx)
11046 t = nk_tt__find_table(data, (nk_uint)fontstart,
"maxp");
11047 if (t) info->numGlyphs = nk_ttUSHORT(data+t+4);
11048 else info->numGlyphs = 0xffff;
11053 numTables = nk_ttUSHORT(data + cmap + 2);
11054 info->index_map = 0;
11055 for (i=0; i < numTables; ++
i)
11057 nk_uint encoding_record = cmap + 4 + 8 * (
nk_uint)i;
11059 switch(nk_ttUSHORT(data+encoding_record)) {
11060 case NK_TT_PLATFORM_ID_MICROSOFT:
11061 switch (nk_ttUSHORT(data+encoding_record+2)) {
11062 case NK_TT_MS_EID_UNICODE_BMP:
11063 case NK_TT_MS_EID_UNICODE_FULL:
11065 info->index_map = (int)(cmap + nk_ttULONG(data+encoding_record+4));
11069 case NK_TT_PLATFORM_ID_UNICODE:
11072 info->index_map = (int)(cmap + nk_ttULONG(data+encoding_record+4));
11077 if (info->index_map == 0)
11079 info->indexToLocFormat = nk_ttUSHORT(data+info->head + 50);
11083 nk_tt_FindGlyphIndex(
const struct nk_tt_fontinfo *info,
int unicode_codepoint)
11085 const nk_byte *data = info->data;
11086 nk_uint index_map = (
nk_uint)info->index_map;
11088 nk_ushort format = nk_ttUSHORT(data + index_map + 0);
11090 nk_int bytes = nk_ttUSHORT(data + index_map + 2);
11091 if (unicode_codepoint < bytes-6)
11092 return nk_ttBYTE(data + index_map + 6 + unicode_codepoint);
11094 }
else if (format == 6) {
11095 nk_uint first = nk_ttUSHORT(data + index_map + 6);
11096 nk_uint count = nk_ttUSHORT(data + index_map + 8);
11097 if ((nk_uint) unicode_codepoint >= first && (nk_uint) unicode_codepoint < first+count)
11098 return nk_ttUSHORT(data + index_map + 10 + (unicode_codepoint - (
int)first)*2);
11100 }
else if (format == 2) {
11103 }
else if (format == 4) {
11104 nk_ushort segcount = nk_ttUSHORT(data+index_map+6) >> 1;
11105 nk_ushort searchRange = nk_ttUSHORT(data+index_map+8) >> 1;
11106 nk_ushort entrySelector = nk_ttUSHORT(data+index_map+10);
11107 nk_ushort rangeShift = nk_ttUSHORT(data+index_map+12) >> 1;
11110 nk_uint endCount = index_map + 14;
11111 nk_uint search = endCount;
11113 if (unicode_codepoint > 0xffff)
11118 if (unicode_codepoint >= nk_ttUSHORT(data + search + rangeShift*2))
11119 search += (
nk_uint)(rangeShift*2);
11123 while (entrySelector) {
11126 end = nk_ttUSHORT(data + search + searchRange*2);
11127 if (unicode_codepoint > end)
11128 search += (
nk_uint)(searchRange*2);
11135 nk_ushort item = (
nk_ushort) ((search - endCount) >> 1);
11137 NK_ASSERT(unicode_codepoint <= nk_ttUSHORT(data + endCount + 2*item));
11138 start = nk_ttUSHORT(data + index_map + 14 + segcount*2 + 2 + 2*item);
11139 if (unicode_codepoint < start)
11142 offset = nk_ttUSHORT(data + index_map + 14 + segcount*6 + 2 + 2*item);
11144 return (nk_ushort) (unicode_codepoint + nk_ttSHORT(data + index_map + 14 + segcount*4 + 2 + 2*item));
11146 return nk_ttUSHORT(data + offset + (unicode_codepoint-start)*2 + index_map + 14 + segcount*6 + 2 + 2*item);
11148 }
else if (format == 12 || format == 13) {
11149 nk_uint ngroups = nk_ttULONG(data+index_map+12);
11151 low = 0; high = (
nk_int)ngroups;
11153 while (low < high) {
11154 nk_int mid = low + ((high-
low) >> 1);
11155 nk_uint start_char = nk_ttULONG(data+index_map+16+mid*12);
11156 nk_uint end_char = nk_ttULONG(data+index_map+16+mid*12+4);
11157 if ((nk_uint) unicode_codepoint < start_char)
11159 else if ((nk_uint) unicode_codepoint > end_char)
11162 nk_uint start_glyph = nk_ttULONG(data+index_map+16+mid*12+8);
11164 return (
int)start_glyph + (int)unicode_codepoint - (
int)start_char;
11166 return (
int)start_glyph;
11176 nk_tt_setvertex(struct nk_tt_vertex *v, nk_byte type, nk_int x, nk_int y, nk_int cx, nk_int cy)
11185 nk_tt__GetGlyfOffset(
const struct nk_tt_fontinfo *info,
int glyph_index)
11188 if (glyph_index >= info->numGlyphs)
return -1;
11189 if (info->indexToLocFormat >= 2)
return -1;
11191 if (info->indexToLocFormat == 0) {
11192 g1 = info->glyf + nk_ttUSHORT(info->data + info->loca + glyph_index * 2) * 2;
11193 g2 = info->glyf + nk_ttUSHORT(info->data + info->loca + glyph_index * 2 + 2) * 2;
11195 g1 = info->glyf + (int)nk_ttULONG (info->data + info->loca + glyph_index * 4);
11196 g2 = info->glyf + (int)nk_ttULONG (info->data + info->loca + glyph_index * 4 + 4);
11198 return g1==g2 ? -1 : g1;
11201 nk_tt_GetGlyphBox(
const struct nk_tt_fontinfo *info,
int glyph_index,
11202 int *x0,
int *y0,
int *x1,
int *y1)
11204 int g = nk_tt__GetGlyfOffset(info, glyph_index);
11205 if (g < 0)
return 0;
11207 if (x0) *x0 = nk_ttSHORT(info->data + g + 2);
11208 if (y0) *y0 = nk_ttSHORT(info->data + g + 4);
11209 if (x1) *x1 = nk_ttSHORT(info->data + g + 6);
11210 if (y1) *y1 = nk_ttSHORT(info->data + g + 8);
11214 nk_tt__close_shape(
struct nk_tt_vertex *vertices,
int num_vertices,
int was_off,
11215 int start_off, nk_int sx, nk_int sy, nk_int scx, nk_int scy, nk_int cx, nk_int cy)
11219 nk_tt_setvertex(&vertices[num_vertices++], NK_TT_vcurve, (cx+scx)>>1, (cy+scy)>>1, cx,cy);
11220 nk_tt_setvertex(&vertices[num_vertices++], NK_TT_vcurve, sx,sy,scx,scy);
11223 nk_tt_setvertex(&vertices[num_vertices++], NK_TT_vcurve,sx,sy,cx,cy);
11225 nk_tt_setvertex(&vertices[num_vertices++], NK_TT_vline,sx,sy,0,0);
11227 return num_vertices;
11230 nk_tt_GetGlyphShape(
const struct nk_tt_fontinfo *info,
struct nk_allocator *alloc,
11231 int glyph_index,
struct nk_tt_vertex **pvertices)
11233 nk_short numberOfContours;
11234 const nk_byte *endPtsOfContours;
11235 const nk_byte *data = info->data;
11236 struct nk_tt_vertex *vertices=0;
11237 int num_vertices=0;
11238 int g = nk_tt__GetGlyfOffset(info, glyph_index);
11241 if (g < 0)
return 0;
11242 numberOfContours = nk_ttSHORT(data + g);
11243 if (numberOfContours > 0) {
11244 nk_byte
flags=0,flagcount;
11245 nk_int ins,
i,j=0,
m,
n, next_move, was_off=0, off, start_off=0;
11246 nk_int
x,
y,cx,cy,sx,sy, scx,scy;
11248 endPtsOfContours = (data + g + 10);
11249 ins = nk_ttUSHORT(data + g + 10 + numberOfContours * 2);
11250 points = data + g + 10 + numberOfContours * 2 + 2 + ins;
11252 n = 1+nk_ttUSHORT(endPtsOfContours + numberOfContours*2-2);
11253 m = n + 2*numberOfContours;
11254 vertices = (
struct nk_tt_vertex *)alloc->
alloc(alloc->
userdata, 0, (nk_size)m *
sizeof(vertices[0]));
11267 for (i=0; i <
n; ++
i) {
11268 if (flagcount == 0) {
11271 flagcount = *points++;
11272 }
else --flagcount;
11273 vertices[off+
i].type =
flags;
11278 for (i=0; i <
n; ++
i) {
11279 flags = vertices[off+
i].type;
11281 nk_short dx = *points++;
11282 x += (flags & 16) ? dx : -dx;
11284 if (!(flags & 16)) {
11285 x = x + (
nk_short) (points[0]*256 + points[1]);
11294 for (i=0; i <
n; ++
i) {
11295 flags = vertices[off+
i].type;
11297 nk_short dy = *points++;
11298 y += (flags & 32) ? dy : -dy;
11300 if (!(flags & 32)) {
11301 y = y + (
nk_short) (points[0]*256 + points[1]);
11310 sx = sy = cx = cy = scx = scy = 0;
11311 for (i=0; i <
n; ++
i)
11313 flags = vertices[off+
i].type;
11317 if (next_move == i) {
11319 num_vertices = nk_tt__close_shape(vertices, num_vertices, was_off, start_off, sx,sy,scx,scy,cx,cy);
11322 start_off = !(flags & 1);
11328 if (!(vertices[off+i+1].type & 1)) {
11330 sx = (x + (
nk_int) vertices[off+i+1].x) >> 1;
11331 sy = (y + (
nk_int) vertices[off+i+1].y) >> 1;
11334 sx = (
nk_int) vertices[off+i+1].x;
11335 sy = (
nk_int) vertices[off+i+1].y;
11342 nk_tt_setvertex(&vertices[num_vertices++], NK_TT_vmove,sx,sy,0,0);
11344 next_move = 1 + nk_ttUSHORT(endPtsOfContours+j*2);
11350 nk_tt_setvertex(&vertices[num_vertices++], NK_TT_vcurve, (cx+x)>>1, (cy+y)>>1, cx, cy);
11356 nk_tt_setvertex(&vertices[num_vertices++], NK_TT_vcurve, x,y, cx, cy);
11357 else nk_tt_setvertex(&vertices[num_vertices++], NK_TT_vline, x,y,0,0);
11362 num_vertices = nk_tt__close_shape(vertices, num_vertices, was_off, start_off, sx,sy,scx,scy,cx,cy);
11363 }
else if (numberOfContours == -1) {
11366 const nk_byte *comp = data + g + 10;
11372 nk_ushort
flags, gidx;
11373 int comp_num_verts = 0,
i;
11374 struct nk_tt_vertex *comp_verts = 0, *
tmp = 0;
11375 float mtx[6] = {1,0,0,1,0,0},
m,
n;
11377 flags = (
nk_ushort)nk_ttSHORT(comp); comp+=2;
11378 gidx = (
nk_ushort)nk_ttSHORT(comp); comp+=2;
11382 mtx[4] = nk_ttSHORT(comp); comp+=2;
11383 mtx[5] = nk_ttSHORT(comp); comp+=2;
11385 mtx[4] = nk_ttCHAR(comp); comp+=1;
11386 mtx[5] = nk_ttCHAR(comp); comp+=1;
11392 if (flags & (1<<3)) {
11393 mtx[0] = mtx[3] = nk_ttSHORT(comp)/16384.0f; comp+=2;
11394 mtx[1] = mtx[2] = 0;
11395 }
else if (flags & (1<<6)) {
11396 mtx[0] = nk_ttSHORT(comp)/16384.0f; comp+=2;
11397 mtx[1] = mtx[2] = 0;
11398 mtx[3] = nk_ttSHORT(comp)/16384.0f; comp+=2;
11399 }
else if (flags & (1<<7)) {
11400 mtx[0] = nk_ttSHORT(comp)/16384.0f; comp+=2;
11401 mtx[1] = nk_ttSHORT(comp)/16384.0f; comp+=2;
11402 mtx[2] = nk_ttSHORT(comp)/16384.0f; comp+=2;
11403 mtx[3] = nk_ttSHORT(comp)/16384.0f; comp+=2;
11407 m = (float) NK_SQRT(mtx[0]*mtx[0] + mtx[1]*mtx[1]);
11408 n = (float) NK_SQRT(mtx[2]*mtx[2] + mtx[3]*mtx[3]);
11411 comp_num_verts = nk_tt_GetGlyphShape(info, alloc, gidx, &comp_verts);
11412 if (comp_num_verts > 0)
11415 for (i = 0; i < comp_num_verts; ++
i) {
11416 struct nk_tt_vertex* v = &comp_verts[
i];
11419 v->x = (short)(m * (mtx[0]*x + mtx[2]*y + mtx[4]));
11420 v->y = (short)(n * (mtx[1]*x + mtx[3]*y + mtx[5]));
11422 v->cx = (short)(m * (mtx[0]*x + mtx[2]*y + mtx[4]));
11423 v->cy = (short)(n * (mtx[1]*x + mtx[3]*y + mtx[5]));
11427 (nk_size)(num_vertices+comp_num_verts)*
sizeof(
struct nk_tt_vertex));
11430 if (comp_verts) alloc->
free(alloc->
userdata, comp_verts);
11433 if (num_vertices > 0) NK_MEMCPY(
tmp, vertices, (nk_size)num_vertices*
sizeof(
struct nk_tt_vertex));
11434 NK_MEMCPY(
tmp+num_vertices, comp_verts, (nk_size)comp_num_verts*
sizeof(
struct nk_tt_vertex));
11438 num_vertices += comp_num_verts;
11441 more = flags & (1<<5);
11443 }
else if (numberOfContours < 0) {
11450 return num_vertices;
11453 nk_tt_GetGlyphHMetrics(
const struct nk_tt_fontinfo *info,
int glyph_index,
11454 int *advanceWidth,
int *leftSideBearing)
11456 nk_ushort numOfLongHorMetrics = nk_ttUSHORT(info->data+info->hhea + 34);
11457 if (glyph_index < numOfLongHorMetrics) {
11459 *advanceWidth = nk_ttSHORT(info->data + info->hmtx + 4*glyph_index);
11460 if (leftSideBearing)
11461 *leftSideBearing = nk_ttSHORT(info->data + info->hmtx + 4*glyph_index + 2);
11464 *advanceWidth = nk_ttSHORT(info->data + info->hmtx + 4*(numOfLongHorMetrics-1));
11465 if (leftSideBearing)
11466 *leftSideBearing = nk_ttSHORT(info->data + info->hmtx + 4*numOfLongHorMetrics + 2*(glyph_index - numOfLongHorMetrics));
11470 nk_tt_GetFontVMetrics(
const struct nk_tt_fontinfo *info,
11471 int *ascent,
int *descent,
int *lineGap)
11473 if (ascent ) *ascent = nk_ttSHORT(info->data+info->hhea + 4);
11474 if (descent) *descent = nk_ttSHORT(info->data+info->hhea + 6);
11475 if (lineGap) *lineGap = nk_ttSHORT(info->data+info->hhea + 8);
11478 nk_tt_ScaleForPixelHeight(
const struct nk_tt_fontinfo *info,
float height)
11480 int fheight = nk_ttSHORT(info->data + info->hhea + 4) - nk_ttSHORT(info->data + info->hhea + 6);
11481 return (
float) height / (float)fheight;
11484 nk_tt_ScaleForMappingEmToPixels(
const struct nk_tt_fontinfo *info,
float pixels)
11486 int unitsPerEm = nk_ttUSHORT(info->data + info->head + 18);
11487 return pixels / (float)unitsPerEm;
11494 nk_tt_GetGlyphBitmapBoxSubpixel(
const struct nk_tt_fontinfo *font,
11495 int glyph,
float scale_x,
float scale_y,
float shift_x,
float shift_y,
11496 int *ix0,
int *iy0,
int *ix1,
int *iy1)
11499 if (!nk_tt_GetGlyphBox(font, glyph, &x0,&y0,&x1,&y1)) {
11507 if (ix0) *ix0 = nk_ifloorf((
float)x0 * scale_x + shift_x);
11508 if (iy0) *iy0 = nk_ifloorf((
float)-y1 * scale_y + shift_y);
11509 if (ix1) *ix1 = nk_iceilf ((
float)x1 * scale_x + shift_x);
11510 if (iy1) *iy1 = nk_iceilf ((
float)-y0 * scale_y + shift_y);
11514 nk_tt_GetGlyphBitmapBox(
const struct nk_tt_fontinfo *font,
int glyph,
11515 float scale_x,
float scale_y,
int *ix0,
int *iy0,
int *ix1,
int *iy1)
11517 nk_tt_GetGlyphBitmapBoxSubpixel(font, glyph, scale_x, scale_y,0.0f,0.0f, ix0, iy0, ix1, iy1);
11524 nk_tt__hheap_alloc(
struct nk_tt__hheap *hh, nk_size size)
11526 if (hh->first_free) {
11527 void *p = hh->first_free;
11528 hh->first_free = * (
void **) p;
11531 if (hh->num_remaining_in_head_chunk == 0) {
11532 int count = (size < 32 ? 2000 : size < 128 ? 800 : 100);
11533 struct nk_tt__hheap_chunk *c = (
struct nk_tt__hheap_chunk *)
11534 hh->alloc.alloc(hh->alloc.userdata, 0,
11535 sizeof(
struct nk_tt__hheap_chunk) + size * (nk_size)count);
11536 if (c == 0)
return 0;
11537 c->next = hh->head;
11539 hh->num_remaining_in_head_chunk =
count;
11541 --hh->num_remaining_in_head_chunk;
11542 return (
char *) (hh->head) + size * (nk_size)hh->num_remaining_in_head_chunk;
11546 nk_tt__hheap_free(
struct nk_tt__hheap *hh,
void *p)
11548 *(
void **) p = hh->first_free;
11549 hh->first_free = p;
11552 nk_tt__hheap_cleanup(
struct nk_tt__hheap *hh)
11554 struct nk_tt__hheap_chunk *c = hh->head;
11556 struct nk_tt__hheap_chunk *n = c->next;
11557 hh->alloc.free(hh->alloc.userdata, c);
11562 nk_tt__new_active(
struct nk_tt__hheap *hh,
struct nk_tt__edge *
e,
11563 int off_x,
float start_point)
11565 struct nk_tt__active_edge *
z = (
struct nk_tt__active_edge *)
11566 nk_tt__hheap_alloc(hh,
sizeof(*z));
11567 float dxdy = (e->x1 - e->x0) / (e->y1 - e->y0);
11571 z->fdy = (dxdy != 0) ? (1/dxdy): 0;
11572 z->fx = e->x0 + dxdy * (start_point - e->y0);
11573 z->fx -= (float)off_x;
11574 z->direction = e->invert ? 1.0f : -1.0f;
11581 nk_tt__handle_clipped_edge(
float *scanline,
int x,
struct nk_tt__active_edge *e,
11582 float x0,
float y0,
float x1,
float y1)
11584 if (y0 == y1)
return;
11585 NK_ASSERT(y0 < y1);
11586 NK_ASSERT(e->sy <= e->ey);
11587 if (y0 > e->ey)
return;
11590 x0 += (x1-
x0) * (e->sy - y0) / (y1-
y0);
11594 x1 += (x1-
x0) * (e->ey - y1) / (y1-
y0);
11598 if (x0 == x) NK_ASSERT(x1 <= x+1);
11599 else if (x0 == x+1) NK_ASSERT(x1 >= x);
11600 else if (x0 <= x) NK_ASSERT(x1 <= x);
11601 else if (x0 >= x+1) NK_ASSERT(x1 >= x+1);
11602 else NK_ASSERT(x1 >= x && x1 <= x+1);
11604 if (x0 <= x && x1 <= x)
11605 scanline[
x] += e->direction * (y1-
y0);
11606 else if (x0 >= x+1 && x1 >= x+1);
11610 scanline[
x] += (float)e->direction * (
float)(y1-
y0) * (1.0f-((x0-(
float)x)+(x1-(float)x))/2.0f);
11614 nk_tt__fill_active_edges_new(
float *scanline,
float *scanline_fill,
int len,
11615 struct nk_tt__active_edge *e,
float y_top)
11617 float y_bottom = y_top+1;
11622 NK_ASSERT(e->ey >= y_top);
11627 nk_tt__handle_clipped_edge(scanline,(
int) x0,e, x0,y_top, x0,y_bottom);
11628 nk_tt__handle_clipped_edge(scanline_fill-1,(
int) x0+1,e, x0,y_top, x0,y_bottom);
11630 nk_tt__handle_clipped_edge(scanline_fill-1,0,e, x0,y_top, x0,y_bottom);
11636 float xb = x0 + dx;
11637 float x_top, x_bottom;
11640 NK_ASSERT(e->sy <= y_bottom && e->ey >= y_top);
11645 if (e->sy > y_top) {
11646 x_top = x0 + dx * (e->sy - y_top);
11653 if (e->ey < y_bottom) {
11654 x_bottom = x0 + dx * (e->ey - y_top);
11661 if (x_top >= 0 && x_bottom >= 0 && x_top < len && x_bottom < len)
11664 if ((
int) x_top == (int) x_bottom) {
11667 int x = (int) x_top;
11669 NK_ASSERT(x >= 0 && x < len);
11670 scanline[
x] += e->direction * (1.0f-(((float)x_top - (
float)
x) + ((
float)x_bottom-(float)x))/2.0f) * (float)height;
11671 scanline_fill[
x] += e->direction * (float)height;
11674 float y_crossing, step, sign, area;
11676 if (x_top > x_bottom)
11680 y0 = y_bottom - (y0 - y_top);
11681 y1 = y_bottom - (y1 - y_top);
11682 t =
y0; y0 =
y1; y1 =
t;
11683 t = x_bottom; x_bottom = x_top; x_top =
t;
11686 t =
x0; x0 = xb; xb =
t;
11690 x2 = (int) x_bottom;
11692 y_crossing = ((float)x1+1 - (
float)
x0) * (
float)dy + (float)y_top;
11694 sign = e->direction;
11696 area = sign * (y_crossing-
y0);
11698 scanline[
x1] += area * (1.0f-((float)((
float)x_top - (float)x1)+(float)(x1+1-x1))/2.0f);
11701 for (x = x1+1; x <
x2; ++
x) {
11702 scanline[
x] += area + step/2;
11705 y_crossing += (float)dy * (
float)(x2 - (x1+1));
11707 scanline[
x2] += area + sign * (1.0f-((float)(x2-x2)+((float)x_bottom-(
float)
x2))/2.0f) * (y1-y_crossing);
11708 scanline_fill[
x2] += sign * (y1-
y0);
11718 for (x=0; x <
len; ++
x)
11735 float x1 = (float) (x);
11736 float x2 = (float) (x+1);
11738 float y3 = y_bottom;
11741 yb = ((float)x - x0) / dx + y_top;
11742 y2 = ((float)x+1 - x0) / dx + y_top;
11745 nk_tt__handle_clipped_edge(scanline,x,e, x0,ya, x1,yb);
11746 nk_tt__handle_clipped_edge(scanline,x,e, x1,yb, x2,y2);
11747 nk_tt__handle_clipped_edge(scanline,x,e, x2,y2, x3,y3);
11748 }
else if (x3 < x1 && x0 > x2) {
11749 nk_tt__handle_clipped_edge(scanline,x,e, x0,ya, x2,y2);
11750 nk_tt__handle_clipped_edge(scanline,x,e, x2,y2, x1,yb);
11751 nk_tt__handle_clipped_edge(scanline,x,e, x1,yb, x3,y3);
11753 nk_tt__handle_clipped_edge(scanline,x,e, x0,ya, x1,yb);
11754 nk_tt__handle_clipped_edge(scanline,x,e, x1,yb, x3,y3);
11755 }
else if (x3 < x1 && x0 > x1) {
11756 nk_tt__handle_clipped_edge(scanline,x,e, x0,ya, x1,yb);
11757 nk_tt__handle_clipped_edge(scanline,x,e, x1,yb, x3,y3);
11759 nk_tt__handle_clipped_edge(scanline,x,e, x0,ya, x2,y2);
11760 nk_tt__handle_clipped_edge(scanline,x,e, x2,y2, x3,y3);
11761 }
else if (x3 < x2 && x0 > x2) {
11762 nk_tt__handle_clipped_edge(scanline,x,e, x0,ya, x2,y2);
11763 nk_tt__handle_clipped_edge(scanline,x,e, x2,y2, x3,y3);
11765 nk_tt__handle_clipped_edge(scanline,x,e, x0,ya, x3,y3);
11774 nk_tt__rasterize_sorted_edges(
struct nk_tt__bitmap *result,
struct nk_tt__edge *e,
11775 int n,
int vsubsample,
int off_x,
int off_y,
struct nk_allocator *alloc)
11778 struct nk_tt__hheap hh;
11779 struct nk_tt__active_edge *active = 0;
11781 float scanline_data[129], *scanline, *scanline2;
11787 if (result->w > 64)
11788 scanline = (
float *) alloc->
alloc(alloc->
userdata,0, (nk_size)(result->w*2+1) *
sizeof(
float));
11789 else scanline = scanline_data;
11791 scanline2 = scanline + result->w;
11793 e[
n].y0 = (float) (off_y + result->h) + 1;
11798 float scan_y_top = (float)y + 0.0f;
11799 float scan_y_bottom = (float)y + 1.0f;
11800 struct nk_tt__active_edge **step = &active;
11802 NK_MEMSET(scanline , 0, (nk_size)result->w*
sizeof(scanline[0]));
11803 NK_MEMSET(scanline2, 0, (nk_size)(result->w+1)*
sizeof(scanline[0]));
11808 struct nk_tt__active_edge * z = *step;
11809 if (z->ey <= scan_y_top) {
11811 NK_ASSERT(z->direction);
11813 nk_tt__hheap_free(&hh, z);
11815 step = &((*step)->next);
11820 while (e->y0 <= scan_y_bottom) {
11821 if (e->y0 != e->y1) {
11822 struct nk_tt__active_edge *z = nk_tt__new_active(&hh, e, off_x, scan_y_top);
11824 NK_ASSERT(z->ey >= scan_y_top);
11835 nk_tt__fill_active_edges_new(scanline, scanline2+1, result->w, active, scan_y_top);
11839 for (i=0; i < result->w; ++
i) {
11842 sum += scanline2[
i];
11843 k = scanline[
i] + sum;
11844 k = (float)
NK_ABS(k) * 255.0f + 0.5f;
11846 if (m > 255) m = 255;
11847 result->pixels[j*result->stride +
i] = (
unsigned char) m;
11853 struct nk_tt__active_edge *z = *step;
11855 step = &((*step)->next);
11860 nk_tt__hheap_cleanup(&hh);
11861 if (scanline != scanline_data)
11865 nk_tt__sort_edges_ins_sort(
struct nk_tt__edge *p,
int n)
11868 #define NK_TT__COMPARE(a,b) ((a)->y0 < (b)->y0) 11869 for (i=1; i <
n; ++
i) {
11870 struct nk_tt__edge t = p[
i], *a = &
t;
11873 struct nk_tt__edge *b = &p[j-1];
11874 int c = NK_TT__COMPARE(a,b);
11884 nk_tt__sort_edges_quicksort(
struct nk_tt__edge *p,
int n)
11888 struct nk_tt__edge t;
11889 int c01,c12,
c,
m,
i,
j;
11893 c01 = NK_TT__COMPARE(&p[0],&p[m]);
11894 c12 = NK_TT__COMPARE(&p[m],&p[n-1]);
11900 c = NK_TT__COMPARE(&p[0],&p[n-1]);
11903 z = (c == c12) ? 0 : n-1;
11922 if (!NK_TT__COMPARE(&p[i], &p[0]))
break;
11925 if (!NK_TT__COMPARE(&p[0], &p[j]))
break;
11941 nk_tt__sort_edges_quicksort(p,j);
11945 nk_tt__sort_edges_quicksort(p+i, n-i);
11951 nk_tt__sort_edges(
struct nk_tt__edge *p,
int n)
11953 nk_tt__sort_edges_quicksort(p, n);
11954 nk_tt__sort_edges_ins_sort(p, n);
11957 nk_tt__rasterize(
struct nk_tt__bitmap *result,
struct nk_tt__point *pts,
11958 int *wcount,
int windings,
float scale_x,
float scale_y,
11959 float shift_x,
float shift_y,
int off_x,
int off_y,
int invert,
11962 float y_scale_inv = invert ? -scale_y : scale_y;
11963 struct nk_tt__edge *
e;
11965 int vsubsample = 1;
11970 for (i=0; i < windings; ++
i)
11973 e = (
struct nk_tt__edge*)
11974 alloc->
alloc(alloc->
userdata, 0,(
sizeof(*e) * (nk_size)(n+1)));
11975 if (e == 0)
return;
11979 for (i=0; i < windings; ++
i)
11981 struct nk_tt__point *p = pts +
m;
11984 for (k=0; k < wcount[
i]; j=k++) {
11987 if (p[j].y == p[k].y)
11992 if (invert ? p[j].y > p[k].y : p[j].y < p[k].y) {
11996 e[
n].x0 = p[
a].x * scale_x + shift_x;
11997 e[
n].y0 = (p[
a].y * y_scale_inv + shift_y) * (
float)vsubsample;
11998 e[
n].x1 = p[
b].x * scale_x + shift_x;
11999 e[
n].y1 = (p[
b].y * y_scale_inv + shift_y) * (
float)vsubsample;
12006 nk_tt__sort_edges(e, n);
12008 nk_tt__rasterize_sorted_edges(result, e, n, vsubsample, off_x, off_y, alloc);
12012 nk_tt__add_point(
struct nk_tt__point *points,
int n,
float x,
float y)
12014 if (!points)
return;
12019 nk_tt__tesselate_curve(
struct nk_tt__point *points,
int *num_points,
12020 float x0,
float y0,
float x1,
float y1,
float x2,
float y2,
12021 float objspace_flatness_squared,
int n)
12026 float mx = (x0 + 2*x1 +
x2)/4;
12027 float my = (y0 + 2*y1 +
y2)/4;
12029 float dx = (x0+
x2)/2 - mx;
12030 float dy = (y0+
y2)/2 - my;
12035 if (dx*dx+dy*dy > objspace_flatness_squared) {
12036 nk_tt__tesselate_curve(points, num_points, x0,y0,
12037 (x0+x1)/2.0f,(y0+y1)/2.0f, mx,my, objspace_flatness_squared,n+1);
12038 nk_tt__tesselate_curve(points, num_points, mx,my,
12039 (x1+x2)/2.0f,(y1+y2)/2.0f, x2,y2, objspace_flatness_squared,n+1);
12041 nk_tt__add_point(points, *num_points,x2,y2);
12042 *num_points = *num_points+1;
12047 nk_tt_FlattenCurves(
struct nk_tt_vertex *vertices,
int num_verts,
12048 float objspace_flatness,
int **contour_lengths,
int *num_contours,
12052 struct nk_tt__point *points=0;
12054 float objspace_flatness_squared = objspace_flatness * objspace_flatness;
12061 for (i=0; i < num_verts; ++
i)
12062 if (vertices[i].type == NK_TT_vmove) ++
n;
12065 if (n == 0)
return 0;
12067 *contour_lengths = (
int *)
12068 alloc->
alloc(alloc->
userdata,0, (
sizeof(**contour_lengths) * (nk_size)n));
12069 if (*contour_lengths == 0) {
12075 for (pass=0; pass < 2; ++pass)
12079 points = (
struct nk_tt__point *)
12080 alloc->
alloc(alloc->
userdata,0, (nk_size)num_points *
sizeof(points[0]));
12081 if (points == 0)
goto error;
12086 for (i=0; i < num_verts; ++
i)
12088 switch (vertices[i].type) {
12092 (*contour_lengths)[
n] = num_points -
start;
12094 start = num_points;
12096 x = vertices[
i].x, y = vertices[
i].y;
12097 nk_tt__add_point(points, num_points++, x,y);
12100 x = vertices[
i].x, y = vertices[
i].y;
12101 nk_tt__add_point(points, num_points++, x, y);
12104 nk_tt__tesselate_curve(points, &num_points, x,y,
12105 vertices[i].cx, vertices[i].cy,
12106 vertices[i].x, vertices[i].y,
12107 objspace_flatness_squared, 0);
12108 x = vertices[
i].x, y = vertices[
i].y;
12113 (*contour_lengths)[
n] = num_points -
start;
12120 *contour_lengths = 0;
12125 nk_tt_Rasterize(
struct nk_tt__bitmap *result,
float flatness_in_pixels,
12126 struct nk_tt_vertex *vertices,
int num_verts,
12127 float scale_x,
float scale_y,
float shift_x,
float shift_y,
12128 int x_off,
int y_off,
int invert,
struct nk_allocator *alloc)
12130 float scale = scale_x > scale_y ? scale_y : scale_x;
12131 int winding_count, *winding_lengths;
12132 struct nk_tt__point *windings = nk_tt_FlattenCurves(vertices, num_verts,
12133 flatness_in_pixels / scale, &winding_lengths, &winding_count, alloc);
12137 nk_tt__rasterize(result, windings, winding_lengths, winding_count,
12138 scale_x, scale_y, shift_x, shift_y, x_off, y_off, invert, alloc);
12144 nk_tt_MakeGlyphBitmapSubpixel(
const struct nk_tt_fontinfo *info,
unsigned char *output,
12145 int out_w,
int out_h,
int out_stride,
float scale_x,
float scale_y,
12146 float shift_x,
float shift_y,
int glyph,
struct nk_allocator *alloc)
12150 int num_verts = nk_tt_GetGlyphShape(info, alloc, glyph, &vertices);
12151 struct nk_tt__bitmap gbm;
12153 nk_tt_GetGlyphBitmapBoxSubpixel(info, glyph, scale_x, scale_y, shift_x,
12154 shift_y, &ix0,&iy0,0,0);
12155 gbm.pixels = output;
12158 gbm.stride = out_stride;
12160 if (gbm.w && gbm.h)
12161 nk_tt_Rasterize(&gbm, 0.35f, vertices, num_verts, scale_x, scale_y,
12162 shift_x, shift_y, ix0,iy0, 1, alloc);
12170 nk_tt_PackBegin(
struct nk_tt_pack_context *spc,
unsigned char *
pixels,
12171 int pw,
int ph,
int stride_in_bytes,
int padding,
struct nk_allocator *alloc)
12173 int num_nodes = pw - padding;
12174 struct nk_rp_context *context = (
struct nk_rp_context *)
12176 struct nk_rp_node *nodes = (
struct nk_rp_node*)
12177 alloc->
alloc(alloc->
userdata,0, (
sizeof(*nodes ) * (nk_size)num_nodes));
12179 if (context == 0 || nodes == 0) {
12180 if (context != 0) alloc->
free(alloc->
userdata, context);
12188 spc->pack_info = context;
12189 spc->nodes = nodes;
12190 spc->padding = padding;
12191 spc->stride_in_bytes = (stride_in_bytes != 0) ? stride_in_bytes : pw;
12192 spc->h_oversample = 1;
12193 spc->v_oversample = 1;
12195 nk_rp_init_target(context, pw-padding, ph-padding, nodes, num_nodes);
12197 NK_MEMSET(pixels, 0, (nk_size)(pw*ph));
12201 nk_tt_PackEnd(
struct nk_tt_pack_context *spc,
struct nk_allocator *alloc)
12207 nk_tt_PackSetOversampling(
struct nk_tt_pack_context *spc,
12208 unsigned int h_oversample,
unsigned int v_oversample)
12210 NK_ASSERT(h_oversample <= NK_TT_MAX_OVERSAMPLE);
12211 NK_ASSERT(v_oversample <= NK_TT_MAX_OVERSAMPLE);
12212 if (h_oversample <= NK_TT_MAX_OVERSAMPLE)
12213 spc->h_oversample = h_oversample;
12214 if (v_oversample <= NK_TT_MAX_OVERSAMPLE)
12215 spc->v_oversample = v_oversample;
12218 nk_tt__h_prefilter(
unsigned char *pixels,
int w,
int h,
int stride_in_bytes,
12221 unsigned char buffer[NK_TT_MAX_OVERSAMPLE];
12222 int safe_w = w - kernel_width;
12225 for (j=0; j <
h; ++
j)
12228 unsigned int total;
12229 NK_MEMSET(buffer, 0, (nk_size)kernel_width);
12234 switch (kernel_width) {
12236 for (i=0; i <= safe_w; ++
i) {
12237 total += (
unsigned int)(pixels[i] - buffer[i & NK_TT__OVER_MASK]);
12238 buffer[(i+kernel_width) & NK_TT__OVER_MASK] = pixels[i];
12239 pixels[
i] = (
unsigned char) (total / 2);
12243 for (i=0; i <= safe_w; ++
i) {
12244 total += (
unsigned int)(pixels[i] - buffer[i & NK_TT__OVER_MASK]);
12245 buffer[(i+kernel_width) & NK_TT__OVER_MASK] = pixels[i];
12246 pixels[
i] = (
unsigned char) (total / 3);
12250 for (i=0; i <= safe_w; ++
i) {
12251 total += (
unsigned int)pixels[i] - buffer[i & NK_TT__OVER_MASK];
12252 buffer[(i+kernel_width) & NK_TT__OVER_MASK] = pixels[i];
12253 pixels[
i] = (
unsigned char) (total / 4);
12257 for (i=0; i <= safe_w; ++
i) {
12258 total += (
unsigned int)(pixels[i] - buffer[i & NK_TT__OVER_MASK]);
12259 buffer[(i+kernel_width) & NK_TT__OVER_MASK] = pixels[i];
12260 pixels[
i] = (
unsigned char) (total / 5);
12264 for (i=0; i <= safe_w; ++
i) {
12265 total += (
unsigned int)(pixels[i] - buffer[i & NK_TT__OVER_MASK]);
12266 buffer[(i+kernel_width) & NK_TT__OVER_MASK] = pixels[i];
12267 pixels[
i] = (
unsigned char) (total / (
unsigned int)kernel_width);
12272 for (; i <
w; ++
i) {
12273 NK_ASSERT(pixels[i] == 0);
12274 total -= (
unsigned int)(buffer[i & NK_TT__OVER_MASK]);
12275 pixels[
i] = (
unsigned char) (total / (
unsigned int)kernel_width);
12277 pixels += stride_in_bytes;
12281 nk_tt__v_prefilter(
unsigned char *pixels,
int w,
int h,
int stride_in_bytes,
12284 unsigned char buffer[NK_TT_MAX_OVERSAMPLE];
12285 int safe_h = h - kernel_width;
12288 for (j=0; j <
w; ++
j)
12291 unsigned int total;
12292 NK_MEMSET(buffer, 0, (nk_size)kernel_width);
12297 switch (kernel_width) {
12299 for (i=0; i <= safe_h; ++
i) {
12300 total += (
unsigned int)(pixels[i*stride_in_bytes] - buffer[i & NK_TT__OVER_MASK]);
12301 buffer[(i+kernel_width) & NK_TT__OVER_MASK] = pixels[i*stride_in_bytes];
12302 pixels[i*stride_in_bytes] = (
unsigned char) (total / 2);
12306 for (i=0; i <= safe_h; ++
i) {
12307 total += (
unsigned int)(pixels[i*stride_in_bytes] - buffer[i & NK_TT__OVER_MASK]);
12308 buffer[(i+kernel_width) & NK_TT__OVER_MASK] = pixels[i*stride_in_bytes];
12309 pixels[i*stride_in_bytes] = (
unsigned char) (total / 3);
12313 for (i=0; i <= safe_h; ++
i) {
12314 total += (
unsigned int)(pixels[i*stride_in_bytes] - buffer[i & NK_TT__OVER_MASK]);
12315 buffer[(i+kernel_width) & NK_TT__OVER_MASK] = pixels[i*stride_in_bytes];
12316 pixels[i*stride_in_bytes] = (
unsigned char) (total / 4);
12320 for (i=0; i <= safe_h; ++
i) {
12321 total += (
unsigned int)(pixels[i*stride_in_bytes] - buffer[i & NK_TT__OVER_MASK]);
12322 buffer[(i+kernel_width) & NK_TT__OVER_MASK] = pixels[i*stride_in_bytes];
12323 pixels[i*stride_in_bytes] = (
unsigned char) (total / 5);
12327 for (i=0; i <= safe_h; ++
i) {
12328 total += (
unsigned int)(pixels[i*stride_in_bytes] - buffer[i & NK_TT__OVER_MASK]);
12329 buffer[(i+kernel_width) & NK_TT__OVER_MASK] = pixels[i*stride_in_bytes];
12330 pixels[i*stride_in_bytes] = (
unsigned char) (total / (
unsigned int)kernel_width);
12335 for (; i <
h; ++
i) {
12336 NK_ASSERT(pixels[i*stride_in_bytes] == 0);
12337 total -= (
unsigned int)(buffer[i & NK_TT__OVER_MASK]);
12338 pixels[i*stride_in_bytes] = (
unsigned char) (total / (
unsigned int)kernel_width);
12344 nk_tt__oversample_shift(
int oversample)
12353 return (
float)-(oversample - 1) / (2.0f * (
float)oversample);
12356 nk_tt_PackFontRangesGatherRects(
struct nk_tt_pack_context *spc,
12357 struct nk_tt_fontinfo *info,
struct nk_tt_pack_range *ranges,
12358 int num_ranges,
struct nk_rp_rect *rects)
12364 for (i=0; i < num_ranges; ++
i) {
12365 float fh = ranges[
i].font_size;
12366 float scale = (fh > 0) ? nk_tt_ScaleForPixelHeight(info, fh):
12367 nk_tt_ScaleForMappingEmToPixels(info, -fh);
12368 ranges[
i].h_oversample = (
unsigned char) spc->h_oversample;
12369 ranges[i].v_oversample = (
unsigned char) spc->v_oversample;
12370 for (j=0; j < ranges[
i].num_chars; ++
j) {
12372 int codepoint = ranges[
i].first_unicode_codepoint_in_range ?
12373 ranges[
i].first_unicode_codepoint_in_range + j :
12374 ranges[
i].array_of_unicode_codepoints[
j];
12376 int glyph = nk_tt_FindGlyphIndex(info, codepoint);
12377 nk_tt_GetGlyphBitmapBoxSubpixel(info,glyph, scale * (
float)spc->h_oversample,
12378 scale * (
float)spc->v_oversample, 0,0, &x0,&y0,&x1,&y1);
12379 rects[k].w = (nk_rp_coord) (x1-x0 + spc->padding + (
int)spc->h_oversample-1);
12380 rects[k].h = (nk_rp_coord) (y1-y0 + spc->padding + (
int)spc->v_oversample-1);
12387 nk_tt_PackFontRangesRenderIntoRects(
struct nk_tt_pack_context *spc,
12388 struct nk_tt_fontinfo *info,
struct nk_tt_pack_range *ranges,
12389 int num_ranges,
struct nk_rp_rect *rects,
struct nk_allocator *alloc)
12391 int i,
j,k, return_value = 1;
12393 int old_h_over = (int)spc->h_oversample;
12394 int old_v_over = (
int)spc->v_oversample;
12398 for (i=0; i < num_ranges; ++
i)
12400 float fh = ranges[
i].font_size;
12401 float recip_h,recip_v,sub_x,sub_y;
12402 float scale = fh > 0 ? nk_tt_ScaleForPixelHeight(info, fh):
12403 nk_tt_ScaleForMappingEmToPixels(info, -fh);
12405 spc->h_oversample = ranges[
i].h_oversample;
12406 spc->v_oversample = ranges[
i].v_oversample;
12408 recip_h = 1.0f / (float)spc->h_oversample;
12409 recip_v = 1.0f / (
float)spc->v_oversample;
12411 sub_x = nk_tt__oversample_shift((
int)spc->h_oversample);
12412 sub_y = nk_tt__oversample_shift((
int)spc->v_oversample);
12414 for (j=0; j < ranges[
i].num_chars; ++
j)
12416 struct nk_rp_rect *r = &rects[k];
12419 struct nk_tt_packedchar *bc = &ranges[
i].chardata_for_range[
j];
12421 int codepoint = ranges[
i].first_unicode_codepoint_in_range ?
12422 ranges[
i].first_unicode_codepoint_in_range + j :
12423 ranges[
i].array_of_unicode_codepoints[
j];
12424 int glyph = nk_tt_FindGlyphIndex(info, codepoint);
12425 nk_rp_coord pad = (nk_rp_coord) spc->padding;
12428 r->x = (nk_rp_coord)((int)r->x + (
int)pad);
12429 r->y = (nk_rp_coord)((
int)r->y + (int)pad);
12430 r->w = (nk_rp_coord)((
int)r->w - (int)pad);
12431 r->h = (nk_rp_coord)((
int)r->h - (int)pad);
12433 nk_tt_GetGlyphHMetrics(info, glyph, &advance, &lsb);
12434 nk_tt_GetGlyphBitmapBox(info, glyph, scale * (
float)spc->h_oversample,
12435 (scale * (
float)spc->v_oversample), &x0,&y0,&x1,&y1);
12436 nk_tt_MakeGlyphBitmapSubpixel(info, spc->pixels + r->x + r->y*spc->stride_in_bytes,
12437 (
int)(r->w - spc->h_oversample+1), (
int)(r->h - spc->v_oversample+1),
12438 spc->stride_in_bytes, scale * (
float)spc->h_oversample,
12439 scale * (
float)spc->v_oversample, 0,0, glyph, alloc);
12441 if (spc->h_oversample > 1)
12442 nk_tt__h_prefilter(spc->pixels + r->x + r->y*spc->stride_in_bytes,
12443 r->w, r->h, spc->stride_in_bytes, (
int)spc->h_oversample);
12445 if (spc->v_oversample > 1)
12446 nk_tt__v_prefilter(spc->pixels + r->x + r->y*spc->stride_in_bytes,
12447 r->w, r->h, spc->stride_in_bytes, (
int)spc->v_oversample);
12450 bc->y0 = (nk_ushort) r->y;
12453 bc->xadvance = scale * (float)advance;
12454 bc->xoff = (float) x0 * recip_h + sub_x;
12455 bc->yoff = (float) y0 * recip_v + sub_y;
12456 bc->xoff2 = ((float)x0 + r->w) * recip_h + sub_x;
12457 bc->yoff2 = ((float)y0 + r->h) * recip_v + sub_y;
12465 spc->h_oversample = (
unsigned int)old_h_over;
12466 spc->v_oversample = (
unsigned int)old_v_over;
12467 return return_value;
12470 nk_tt_GetPackedQuad(
struct nk_tt_packedchar *chardata,
int pw,
int ph,
12471 int char_index,
float *xpos,
float *
ypos,
struct nk_tt_aligned_quad *q,
12472 int align_to_integer)
12474 float ipw = 1.0f / (float)pw, iph = 1.0f / (
float)ph;
12475 struct nk_tt_packedchar *b = (
struct nk_tt_packedchar*)(chardata + char_index);
12476 if (align_to_integer) {
12477 int tx = nk_ifloorf((*xpos + b->xoff) + 0.5f);
12478 int ty = nk_ifloorf((*ypos + b->yoff) + 0.5f);
12480 float x = (float)tx;
12481 float y = (float)ty;
12485 q->x1 = x + b->xoff2 - b->xoff;
12486 q->y1 = y + b->yoff2 - b->yoff;
12488 q->x0 = *xpos + b->xoff;
12489 q->y0 = *ypos + b->yoff;
12490 q->x1 = *xpos + b->xoff2;
12491 q->y1 = *ypos + b->yoff2;
12493 q->s0 = b->x0 * ipw;
12494 q->t0 = b->y0 * iph;
12495 q->s1 = b->x1 * ipw;
12496 q->t1 = b->y1 * iph;
12497 *xpos += b->xadvance;
12505 struct nk_font_bake_data {
12506 struct nk_tt_fontinfo info;
12507 struct nk_rp_rect *rects;
12508 struct nk_tt_pack_range *ranges;
12509 nk_rune range_count;
12512 struct nk_font_baker {
12514 struct nk_tt_pack_context spc;
12515 struct nk_font_bake_data *
build;
12516 struct nk_tt_packedchar *packed_chars;
12517 struct nk_rp_rect *rects;
12518 struct nk_tt_pack_range *ranges;
12528 nk_range_count(
const nk_rune *
range)
12530 const nk_rune *iter =
range;
12532 if (!range)
return 0;
12533 while (*(iter++) != 0);
12534 return (iter == range) ? 0 : (int)((iter - range)/2);
12537 nk_range_glyph_count(
const nk_rune *range,
int count)
12540 int total_glyphs = 0;
12541 for (i = 0; i <
count; ++
i) {
12543 nk_rune f = range[(i*2)+0];
12544 nk_rune t = range[(i*2)+1];
12546 diff = (int)((t - f) + 1);
12547 total_glyphs += diff;
12549 return total_glyphs;
12552 nk_font_default_glyph_ranges(
void)
12554 NK_STORAGE const nk_rune ranges[] = {0x0020, 0x00FF, 0};
12558 nk_font_chinese_glyph_ranges(
void)
12571 nk_font_cyrillic_glyph_ranges(
void)
12583 nk_font_korean_glyph_ranges(
void)
12594 nk_font_baker_memory(nk_size *temp,
int *glyph_count,
12597 int range_count = 0;
12598 int total_range_count = 0;
12599 struct nk_font_config *iter, *
i;
12601 NK_ASSERT(config_list);
12602 NK_ASSERT(glyph_count);
12603 if (!config_list) {
12609 for (iter = config_list; iter; iter = iter->next) {
12611 do {
if (!i->range) iter->range = nk_font_default_glyph_ranges();
12612 range_count = nk_range_count(i->range);
12613 total_range_count += range_count;
12614 *glyph_count += nk_range_glyph_count(i->range, range_count);
12615 }
while ((i = i->n) != iter);
12617 *temp = (
nk_size)*glyph_count *
sizeof(
struct nk_rp_rect);
12618 *temp += (
nk_size)total_range_count *
sizeof(
struct nk_tt_pack_range);
12619 *temp += (
nk_size)*glyph_count *
sizeof(
struct nk_tt_packedchar);
12620 *temp += (
nk_size)count *
sizeof(
struct nk_font_bake_data);
12621 *temp +=
sizeof(
struct nk_font_baker);
12622 *temp += nk_rect_align + nk_range_align + nk_char_align;
12623 *temp += nk_build_align + nk_baker_align;
12626 nk_font_baker(
void *memory,
int glyph_count,
int count,
struct nk_allocator *alloc)
12628 struct nk_font_baker *baker;
12629 if (!memory)
return 0;
12631 baker = (
struct nk_font_baker*)
NK_ALIGN_PTR(memory, nk_baker_align);
12632 baker->build = (
struct nk_font_bake_data*)
NK_ALIGN_PTR((baker + 1), nk_build_align);
12633 baker->packed_chars = (
struct nk_tt_packedchar*)
NK_ALIGN_PTR((baker->build + count), nk_char_align);
12634 baker->rects = (
struct nk_rp_rect*)
NK_ALIGN_PTR((baker->packed_chars + glyph_count), nk_rect_align);
12635 baker->ranges = (
struct nk_tt_pack_range*)
NK_ALIGN_PTR((baker->rects + glyph_count), nk_range_align);
12636 baker->alloc = *alloc;
12640 nk_font_bake_pack(
struct nk_font_baker *baker,
12641 nk_size *image_memory,
int *width,
int *height,
struct nk_recti *
custom,
12642 const struct nk_font_config *config_list,
int count,
12645 NK_STORAGE const nk_size max_height = 1024 * 32;
12646 const struct nk_font_config *config_iter, *
it;
12647 int total_glyph_count = 0;
12648 int total_range_count = 0;
12649 int range_count = 0;
12652 NK_ASSERT(image_memory);
12655 NK_ASSERT(config_list);
12659 if (!image_memory || !width || !height || !config_list || !count)
return nk_false;
12660 for (config_iter = config_list; config_iter; config_iter = config_iter->next) {
12662 do {range_count = nk_range_count(it->range);
12663 total_range_count += range_count;
12664 total_glyph_count += nk_range_glyph_count(it->range, range_count);
12665 }
while ((it = it->n) != config_iter);
12668 for (config_iter = config_list; config_iter; config_iter = config_iter->next) {
12670 do {
if (!nk_tt_InitFont(&baker->build[i++].info, (
const unsigned char*)it->ttf_blob, 0))
12672 }
while ((it = it->n) != config_iter);
12675 *width = (total_glyph_count > 1000) ? 1024 : 512;
12676 nk_tt_PackBegin(&baker->spc, 0, (
int)*width, (
int)max_height, 0, 1, alloc);
12685 struct nk_rp_rect custom_space;
12686 nk_zero(&custom_space,
sizeof(custom_space));
12687 custom_space.w = (nk_rp_coord)(custom->
w);
12688 custom_space.h = (nk_rp_coord)(custom->
h);
12690 nk_tt_PackSetOversampling(&baker->spc, 1, 1);
12691 nk_rp_pack_rects((
struct nk_rp_context*)baker->spc.pack_info, &custom_space, 1);
12692 *height =
NK_MAX(*height, (
int)(custom_space.y + custom_space.h));
12694 custom->
x = (short)custom_space.x;
12695 custom->
y = (
short)custom_space.y;
12696 custom->
w = (short)custom_space.w;
12697 custom->
h = (
short)custom_space.h;
12701 for (input_i = 0, config_iter = config_list; input_i < count && config_iter;
12702 config_iter = config_iter->next) {
12707 const struct nk_font_config *
cfg =
it;
12708 struct nk_font_bake_data *
tmp = &baker->build[input_i++];
12711 glyph_count = 0; range_count = 0;
12712 for (in_range = cfg->range; in_range[0] && in_range[1]; in_range += 2) {
12713 glyph_count += (int)(in_range[1] - in_range[0]) + 1;
12718 tmp->ranges = baker->ranges + range_n;
12719 tmp->range_count = (
nk_rune)range_count;
12720 range_n += range_count;
12721 for (i = 0; i < range_count; ++
i) {
12722 in_range = &cfg->range[i * 2];
12723 tmp->ranges[
i].font_size = cfg->size;
12724 tmp->ranges[
i].first_unicode_codepoint_in_range = (int)in_range[0];
12725 tmp->ranges[
i].num_chars = (int)(in_range[1]- in_range[0]) + 1;
12726 tmp->ranges[
i].chardata_for_range = baker->packed_chars + char_n;
12727 char_n += tmp->ranges[
i].num_chars;
12731 tmp->rects = baker->rects + rect_n;
12732 rect_n += glyph_count;
12733 nk_tt_PackSetOversampling(&baker->spc, cfg->oversample_h, cfg->oversample_v);
12734 n = nk_tt_PackFontRangesGatherRects(&baker->spc, &tmp->info,
12735 tmp->ranges, (
int)tmp->range_count, tmp->rects);
12736 nk_rp_pack_rects((
struct nk_rp_context*)baker->spc.pack_info, tmp->rects, (
int)n);
12739 for (i = 0; i <
n; ++
i) {
12740 if (tmp->rects[i].was_packed)
12741 *height =
NK_MAX(*height, tmp->rects[i].y + tmp->rects[i].h);
12743 }
while ((it = it->n) != config_iter);
12745 NK_ASSERT(rect_n == total_glyph_count);
12746 NK_ASSERT(char_n == total_glyph_count);
12747 NK_ASSERT(range_n == total_range_count);
12749 *height = (int)nk_round_up_pow2((nk_uint)*
height);
12754 nk_font_bake(
struct nk_font_baker *baker,
void *image_memory,
int width,
int height,
12755 struct nk_font_glyph *glyphs,
int glyphs_count,
12756 const struct nk_font_config *config_list,
int font_count)
12759 nk_rune glyph_n = 0;
12760 const struct nk_font_config *config_iter;
12761 const struct nk_font_config *
it;
12763 NK_ASSERT(image_memory);
12766 NK_ASSERT(config_list);
12768 NK_ASSERT(font_count);
12769 NK_ASSERT(glyphs_count);
12770 if (!image_memory || !width || !height || !config_list ||
12771 !font_count || !glyphs || !glyphs_count)
12775 nk_zero(image_memory, (nk_size)((nk_size)width * (nk_size)height));
12776 baker->spc.pixels = (
unsigned char*)image_memory;
12777 baker->spc.height = (int)height;
12778 for (input_i = 0, config_iter = config_list; input_i < font_count && config_iter;
12779 config_iter = config_iter->next) {
12781 do {
const struct nk_font_config *cfg =
it;
12782 struct nk_font_bake_data *tmp = &baker->build[input_i++];
12783 nk_tt_PackSetOversampling(&baker->spc, cfg->oversample_h, cfg->oversample_v);
12784 nk_tt_PackFontRangesRenderIntoRects(&baker->spc, &tmp->info, tmp->ranges,
12785 (
int)tmp->range_count, tmp->rects, &baker->alloc);
12786 }
while ((it = it->n) != config_iter);
12787 } nk_tt_PackEnd(&baker->spc, &baker->alloc);
12790 for (input_i = 0, config_iter = config_list; input_i < font_count && config_iter;
12791 config_iter = config_iter->next) {
12795 nk_rune glyph_count = 0;
12796 const struct nk_font_config *cfg =
it;
12797 struct nk_font_bake_data *tmp = &baker->build[input_i++];
12798 struct nk_baked_font *dst_font = cfg->font;
12800 float font_scale = nk_tt_ScaleForPixelHeight(&tmp->info, cfg->size);
12801 int unscaled_ascent, unscaled_descent, unscaled_line_gap;
12802 nk_tt_GetFontVMetrics(&tmp->info, &unscaled_ascent, &unscaled_descent,
12803 &unscaled_line_gap);
12806 if (!cfg->merge_mode) {
12807 dst_font->ranges = cfg->range;
12808 dst_font->height = cfg->size;
12809 dst_font->ascent = ((float)unscaled_ascent * font_scale);
12810 dst_font->descent = ((float)unscaled_descent * font_scale);
12811 dst_font->glyph_offset = glyph_n;
12815 for (i = 0; i < tmp->range_count; ++
i) {
12816 struct nk_tt_pack_range *range = &tmp->ranges[
i];
12817 for (char_idx = 0; char_idx < range->num_chars; char_idx++)
12819 nk_rune codepoint = 0;
12820 float dummy_x = 0, dummy_y = 0;
12821 struct nk_tt_aligned_quad q;
12822 struct nk_font_glyph *glyph;
12825 const struct nk_tt_packedchar *
pc = &range->chardata_for_range[char_idx];
12826 if (!pc->x0 && !pc->x1 && !pc->y0 && !pc->y1)
continue;
12827 codepoint = (
nk_rune)(range->first_unicode_codepoint_in_range + char_idx);
12828 nk_tt_GetPackedQuad(range->chardata_for_range, (
int)width,
12829 (
int)height, char_idx, &dummy_x, &dummy_y, &q, 0);
12832 glyph = &glyphs[dst_font->glyph_offset + dst_font->glyph_count + (
unsigned int)glyph_count];
12833 glyph->codepoint = codepoint;
12834 glyph->x0 = q.x0; glyph->y0 = q.y0;
12835 glyph->x1 = q.x1; glyph->y1 = q.y1;
12836 glyph->y0 += (dst_font->ascent + 0.5f);
12837 glyph->y1 += (dst_font->ascent + 0.5f);
12838 glyph->w = glyph->x1 - glyph->x0 + 0.5f;
12839 glyph->h = glyph->y1 - glyph->y0;
12841 if (cfg->coord_type == NK_COORD_PIXEL) {
12842 glyph->u0 = q.s0 * (float)width;
12843 glyph->v0 = q.t0 * (float)height;
12844 glyph->u1 = q.s1 * (float)width;
12845 glyph->v1 = q.t1 * (float)height;
12852 glyph->xadvance = (pc->xadvance + cfg->spacing.x);
12853 if (cfg->pixel_snap)
12854 glyph->xadvance = (float)(
int)(glyph->xadvance + 0.5f);
12858 dst_font->glyph_count += glyph_count;
12859 glyph_n += glyph_count;
12860 }
while ((it = it->n) != config_iter);
12865 struct nk_recti img_dst,
const char *texture_data_mask,
int tex_width,
12873 NK_ASSERT(img_memory);
12874 NK_ASSERT(img_width);
12875 NK_ASSERT(img_height);
12876 NK_ASSERT(texture_data_mask);
12878 if (!img_memory || !img_width || !img_height || !texture_data_mask)
12881 pixels = (nk_byte*)img_memory;
12882 for (y = 0, n = 0; y < tex_height; ++
y) {
12883 for (x = 0; x < tex_width; ++
x, ++
n) {
12884 const int off0 = ((img_dst.
x +
x) + (img_dst.
y + y) *
img_width);
12885 const int off1 = off0 + 1 + tex_width;
12886 pixels[off0] = (texture_data_mask[
n] ==
white) ? 0xFF : 0x00;
12887 pixels[off1] = (texture_data_mask[
n] ==
black) ? 0xFF : 0x00;
12892 nk_font_bake_convert(
void *out_memory,
int img_width,
int img_height,
12893 const void *in_memory)
12897 const nk_byte *
src;
12899 NK_ASSERT(out_memory);
12900 NK_ASSERT(in_memory);
12901 NK_ASSERT(img_width);
12902 NK_ASSERT(img_height);
12903 if (!out_memory || !in_memory || !img_height || !img_width)
return;
12905 dst = (nk_rune*)out_memory;
12906 src = (
const nk_byte*)in_memory;
12907 for (n = (
int)(img_width *
img_height); n > 0; n--)
12908 *dst++ = ((nk_rune)(*src++) << 24) | 0x00FFFFFF;
12917 nk_font_text_width(nk_handle
handle,
float height,
const char *text,
int len)
12921 float text_width = 0;
12925 struct nk_font *font = (
struct nk_font*)handle.
ptr;
12927 NK_ASSERT(font->glyphs);
12928 if (!font || !text || !len)
12931 scale = height/font->info.height;
12932 glyph_len = text_len =
nk_utf_decode(text, &unicode, (
int)len);
12933 if (!glyph_len)
return 0;
12934 while (text_len <= (
int)len && glyph_len) {
12935 const struct nk_font_glyph *
g;
12939 g = nk_font_find_glyph(font, unicode);
12940 text_width += g->xadvance *
scale;
12943 glyph_len =
nk_utf_decode(text + text_len, &unicode, (
int)len - text_len);
12944 text_len += glyph_len;
12948 #ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT 12950 nk_font_query_font_glyph(nk_handle handle,
float height,
12951 struct nk_user_font_glyph *glyph, nk_rune codepoint, nk_rune next_codepoint)
12954 const struct nk_font_glyph *
g;
12955 struct nk_font *
font;
12960 font = (
struct nk_font*)handle.
ptr;
12962 NK_ASSERT(font->glyphs);
12963 if (!font || !glyph)
12966 scale = height/font->info.height;
12967 g = nk_font_find_glyph(font, codepoint);
12968 glyph->width = (g->x1 - g->x0) * scale;
12969 glyph->height = (g->y1 - g->y0) * scale;
12970 glyph->offset =
nk_vec2(g->x0 * scale, g->y0 * scale);
12971 glyph->xadvance = (g->xadvance *
scale);
12972 glyph->uv[0] =
nk_vec2(g->u0, g->v0);
12973 glyph->uv[1] =
nk_vec2(g->u1, g->v1);
12976 NK_API const struct nk_font_glyph*
12977 nk_font_find_glyph(
struct nk_font *font, nk_rune unicode)
12981 int total_glyphs = 0;
12982 const struct nk_font_glyph *glyph = 0;
12983 const struct nk_font_config *iter = 0;
12986 NK_ASSERT(font->glyphs);
12987 NK_ASSERT(font->info.ranges);
12988 if (!font || !font->glyphs)
return 0;
12990 glyph = font->fallback;
12991 iter = font->config;
12992 do {count = nk_range_count(iter->range);
12993 for (i = 0; i <
count; ++
i) {
12994 nk_rune f = iter->range[(i*2)+0];
12995 nk_rune t = iter->range[(i*2)+1];
12996 int diff = (int)((t - f) + 1);
12997 if (unicode >= f && unicode <= t)
12998 return &font->glyphs[((
nk_rune)total_glyphs + (unicode - f))];
12999 total_glyphs += diff;
13001 }
while ((iter = iter->n) != font->config);
13005 nk_font_init(
struct nk_font *font,
float pixel_height,
13006 nk_rune fallback_codepoint,
struct nk_font_glyph *glyphs,
13007 const struct nk_baked_font *baked_font, nk_handle atlas)
13009 struct nk_baked_font baked;
13012 NK_ASSERT(baked_font);
13013 if (!font || !glyphs || !baked_font)
13016 baked = *baked_font;
13017 font->fallback = 0;
13018 font->info = baked;
13019 font->scale = (float)pixel_height / (
float)font->info.height;
13020 font->glyphs = &glyphs[baked_font->glyph_offset];
13021 font->texture = atlas;
13022 font->fallback_codepoint = fallback_codepoint;
13023 font->fallback = nk_font_find_glyph(font, fallback_codepoint);
13025 font->handle.height = font->info.height * font->scale;
13026 font->handle.width = nk_font_text_width;
13027 font->handle.userdata.ptr =
font;
13028 #ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT 13029 font->handle.query = nk_font_query_font_glyph;
13030 font->handle.texture = font->texture;
13044 #pragma clang diagnostic push 13045 #pragma clang diagnostic ignored "-Woverlength-strings" 13046 #elif defined(__GNUC__) || defined(__GNUG__) 13047 #pragma GCC diagnostic push 13048 #pragma GCC diagnostic ignored "-Woverlength-strings" 13051 #ifdef NK_INCLUDE_DEFAULT_FONT 13053 NK_GLOBAL const char nk_proggy_clean_ttf_compressed_data_base85[11980+1] =
13054 "7])#######hV0qs'/###[),##/l:$#Q6>##5[n42>c-TH`->>#/e>11NNV=Bv(*:.F?uu#(gRU.o0XGH`$vhLG1hxt9?W`#,5LsCp#-i>.r$<$6pD>Lb';9Crc6tgXmKVeU2cD4Eo3R/" 13055 "2*>]b(MC;$jPfY.;h^`IWM9<Lh2TlS+f-s$o6Q<BWH`YiU.xfLq$N;$0iR/GX:U(jcW2p/W*q?-qmnUCI;jHSAiFWM.R*kU@C=GH?a9wp8f$e.-4^Qg1)Q-GL(lf(r/7GrRgwV%MS=C#" 13056 "`8ND>Qo#t'X#(v#Y9w0#1D$CIf;W'#pWUPXOuxXuU(H9M(1<q-UE31#^-V'8IRUo7Qf./L>=Ke$$'5F%)]0^#0X@U.a<r:QLtFsLcL6##lOj)#.Y5<-R&KgLwqJfLgN&;Q?gI^#DY2uL" 13057 "i@^rMl9t=cWq6##weg>$FBjVQTSDgEKnIS7EM9>ZY9w0#L;>>#Mx&4Mvt//L[MkA#W@lK.N'[0#7RL_&#w+F%HtG9M#XL`N&.,GM4Pg;-<nLENhvx>-VsM.M0rJfLH2eTM`*oJMHRC`N" 13058 "kfimM2J,W-jXS:)r0wK#@Fge$U>`w'N7G#$#fB#$E^$#:9:hk+eOe--6x)F7*E%?76%^GMHePW-Z5l'&GiF#$956:rS?dA#fiK:)Yr+`�j@'DbG&#^$PG.Ll+DNa<XCMKEV*N)LN/N" 13059 "*b=%Q6pia-Xg8I$<MR&,VdJe$<(7G;Ckl'&hF;;$<_=X(b.RS%%)###MPBuuE1V:v&cXm#(&cV]`k9OhLMbn%s$G2,B$BfD3X*sp5#l,$R#]x_X1xKX%b5U*[r5iMfUo9U`N99hG)" 13060 "tm+/Us9pG)XPu`<0s-)WTt(gCRxIg(%6sfh=ktMKn3j)<6<b5Sk_/0(^]AaN#(p/L>&VZ>1i%h1S9u5o@YaaW$e+b<TWFn/Z:Oh(Cx2$lNEoN^e)#CFY@@I;BOQ*sRwZtZxRcU7uW6CX" 13061 "ow0i(?$Q[cjOd[P4d)]>ROPOpxTO7Stwi1::iB1q)C_=dV26J;2,]7op$]uQr@_V7$q^%lQwtuHY]=DX,n3L#0PHDO4f9>dC@O>HBuKPpP*E,N+b3L#lpR/MrTEH.IAQk.a>D[.e;mc." 13062 "x]Ip.PH^'/aqUO/$1WxLoW0[iLA<QT;5HKD+@qQ'NQ(3_PLhE48R.qAPSwQ0/WK?Z,[x?-J;jQTWA0X@KJ(_Y8N-:/M74:/-ZpKrUss?d#dZq]DAbkU*JqkL+nwX@@47`5>w=4h(9.`G" 13063 "CRUxHPeR`5Mjol(dUWxZa(>STrPkrJiWx`5U7F#.g*jrohGg`cg:lSTvEY/EV_7H4Q9[Z%cnv;JQYZ5q.l7Zeas:HOIZOB?G<Nald$qs]@]L<J7bR*>gv:[7MI2k).'2($5FNP&EQ(,)" 13064 "U]W]+fh18.vsai00);D3@4ku5P?DP8aJt+;qUM]=+b'8@;mViBKx0DE[-auGl8:PJ&Dj+M6OC]O^((##]`0i)drT;-7X`=-H3[igUnPG-NZlo.#k@h#=Ork$m>a>$-?Tm$UV(?#P6YY#" 13065 "'/###xe7q.73rI3*pP/$1>s9)W,JrM7SN]'/4C#v$U`0#V.[0>xQsH$fEmPMgY2u7Kh(G%siIfLSoS+MK2eTM$=5,M8p`A.;_R%#u[K#$x4AG8.kK/HSB==-'Ie/QTtG?-.*^N-4B/ZM" 13066 "_3YlQC7(p7q)&](`6_c)$/*JL(L-^(]$wIM`dPtOdGA,U3:w2M-0<q-]L_?^)1vw'.,MRsqVr.L;aN&#/EgJ)PBc[-f>+WomX2u7lqM2iEumMTcsF?-aT=Z-97UEnXglEn1K-bnEO`gu" 13067 "Ft(c%=;Am_Qs@jLooI&NX;]0#j4#F14;gl8-GQpgwhrq8'=l_f-b49'UOqkLu7-##oDY2L(te+Mch&gLYtJ,MEtJfLh'x'M=$CS-ZZ%P]8bZ>#S?YY#%Q&q'3^Fw&?D)UDNrocM3A76/" 13068 "/oL?#h7gl85[qW/NDOk%16ij;+:1a'iNIdb-ou8.P*w,v5#EI$TWS>Pot-R*H'-SEpA:g)f+O$%%`kA#G=8RMmG1&O`>to8bC]T&$,n.LoO>29sp3dt-52U%VM#q7'DHpg+#Z9%H[K<L" 13069 "%a2E-grWVM3@2=-k22tL]4$##6We'8UJCKE[d_=%wI;'6X-GsLX4j^SgJ$##R*w,vP3wK#iiW&#*h^D&R?jp7+/u&#(AP##XU8c$fSYW-J95_-Dp[g9wcO&#M-h1OcJlc-*vpw0xUX&#" 13070 "OQFKNX@QI'IoPp7nb,QU//MQ&ZDkKP)X<WSVL(68uVl&#c'[0#(s1X&xm$Y%B7*K:eDA323j998GXbA#pwMs-jgD$9QISB-A_(aN4xoFM^@C58D0+Q+q3n0#3U1InDjF682-SjMXJK)(" 13071 "h$hxua_K]ul92%'BOU&#BRRh-slg8KDlr:%L71Ka:.A;%YULjDPmL<LYs8i#XwJOYaKPKc1h:'9Ke,g)b),78=I39B;xiY$bgGw-&.Zi9InXDuYa%G*f2Bq7mn9^#p1vv%#(Wi-;/Z5h" 13072 "o;#2:;%d	v68C5g?ntX0X)pT`;%pB3q7mgGN)3%(P8nTd5L7GeA-GL@+%J3u2:(Yf>et`e;)f#Km8&+DC$I46>#Kr]]u-[=99tts1.qb#q72g1WJO81q+eN'03'eM>&1XxY-caEnO" 13073 "j%2n8)),?ILR5^.Ibn<-X-Mq7[a82Lq:F&#ce+S9wsCK*x`569E8ew'He]h:sI[2LM$[guka3ZRd6:t%IG:;$%YiJ:Nq=?eAw;/:nnDq0(CYcMpG)qLN4$##&J<j$UpK<Q4a1]MupW^-" 13074 "sj_$%[HK%'F####QRZJ::Y3EGl4'@%FkiAOg#p[##O`gukTfBHagL<LHw%q&OV0##F=6/:chIm0@eCP8X]:kFI%hl8hgO@RcBhS-@Qb$%+m=hPDLg*%K8ln(wcf3/'DW-$.lR?n[nCH-" 13075 "eXOONTJlh:.RYF%3'p6sq:UIMA945&^HFS87@$EP2iG<-lCO$%c`uKGD3rC$x0BL8aFn--`ke%#HMP'vh1/R&O_J9'um,.<tx[@%wsJk&bUT2`0uMv7gg#qp/ij.L56'hl;.s5CUrxjO" 13076 "M7-##.l+Au'A&O:-T72L]P`&=;ctp'XScX*rU.>-XTt,%OVU4)S1+R-#dg0/Nn?Ku1^0f$B*P:Rowwm-`0PKjYDDM'3]d39VZHEl4,.j']Pk-M.h^&:0FACm$maq-&sgw0t7/6(^xtk%" 13077 "LuH88Fj-ekm>GA#_>568x6(OFRl-IZp`&b,_P'$M<Jnq79VsJW/mWS*PUiq76;]/NM_>hLbxfc$mj`,O;&%W2m`Zh:/)Uetw:aJ%]K9h:TcF]u_-Sj9,VK3M.*'&0D[Ca]J9gp8,kAW]" 13078 "%(?A%R$f<->Zts'^kn=-^@c4%-pY6qI%J%1IGxfLU9CP8cbPlXv);C=b),<2mOvP8up,UVf3839acAWAW-W?#ao/^#%KYo8fRULNd2.>%m]UK:n%r$'sw]J;5pAoO_#2mO3n,'=H5(et" 13079 "Hg*`+RLgv>=4U8guD$I%D:W>-r5V*%j*W:Kvej.Lp$<M-SGZ':+Q_k+uvOSLiEo(<aD/K<CCc`'Lx>'?;++O'>()jLR-^u68PHm8ZFWe+ej8h:9r6L*0//c&iH&R8pRbA#Kjm%upV1g:" 13080 "a_#Ur7FuA#(tRh#.Y5K+@?3<-8m0$PEn;J:rh6?I6uG<-`wMU'ircp0LaE_OtlMb&1#6T.#FDKu#1Lw%u%+GM+X'e?YLfjM[VO0MbuFp7;>Q&#WIo)0@F%q7c#4XAXN-U&VB<HFF*qL(" 13081 "$/V,;(kXZejWO`<[5?\?ewY(*9=%wDc;,u<'9t3W-(H1th3+G]ucQ]kLs7df($/*JL]@*t7Bu_G3_7mp7<iaQjO@.kLg;x3B0lqp7Hf,^Ze7-##@/c58Mo(3;knp0%)A7?-W+eI'o8)b<" 13082 "nKnw'Ho8C=Y>pqB>0ie&jhZ[?iLR@@_AvA-iQC(=ksRZRVp7`.=+NpBC%rh&3]R:8XDmE5^V8O(x<<aG/1N$#FX$0V5Y6x'aErI3I$7x%E`v<-BY,)%-?Psf*l?%C3.mM(=/M0:JxG'?" 13083 "7WhH%o'a<-80g0NBxoO(GH<dM]n.+%q@jH?f.UsJ2Ggs&4<-e47&Kl+f//9@`b+?.TeN_&B8Ss?v;^Trk;f#YvJkl&w$]>-+k?'(<S:68tq*WoDfZu';mM?8X[ma8W%*`-=;D.(nc7/;" 13084 ")g:T1=^J$&BRV(-lTmNB6xqB[@0*o.erM*<SWF]u2=st-*(6v>^](H.aREZSi,#1:[IXaZFOm<-ui#qUq2$##Ri;u75OK#(RtaW-K-F`S+cF]uN`-KMQ%rP/Xri.LRcB##=YL3BgM/3M" 13085 "D?@f&1'BW-)Ju<L25gl8uhVm1hL$##*8###'A3/LkKW+(^rWX?5W_8g)a(m&K8P>#bmmWCMkk&#TR`C,5d>g)F;t,4:@_l8G/5h4vUd%&%950:VXD'QdWoY-F$BtUwmfe$YqL'8(PWX(" 13086 "P?^@Po3$##`MSs?DWBZ/S>+4%>fX,VWv/w'KD`LP5IbH;rTV>n3cEK8U#bX]l-/V+^lj3;vlMb&[5YQ8#pekX9JP3XUC72L,,?+Ni&co7ApnO*5NK,((W-i:$,kp'UDAO(G0Sq7MVjJs" 13087 "bIu)'Z,*[>br5fX^:FPAWr-m2KgL<LUN098kTF&#lvo58=/vjDo;.;)Ka*hLR#/k=rKbxuV`>Q_nN6'8uTGT5g)uLv:873UpTLgH+#FgpH'_o1780Ph8KmxQJ8#H72L4@768@Tm&Q" 13088 "h4CB/5OvmA&,Q&QbUoi$a_%3M01H)4x7I^&KQVgtFnV+;[Pc>[m4k//,]1?#`VY[Jr*3&&slRfLiVZJ:]?=K3Sw=[$=uRB?3xk48@aeg<Z'<$#4H)6,>e0jT6'N#(q%.O=?2S]u*(m<-" 13089 "V8J'(1)G][68hW$5'q[GC&5j`TE?m'esFGNRM)j,ffZ?-qx8;->g4t*:CIP/[Qap7/9'#(1sao7w-.qNUdkJ)tCF&#B^;xGvn2r9FEPFFFcL@.iFNkTve$m%#QvQS8U@)2Z+3K:AKM5i" 13090 "sZ88+dKQ)W6>J%CL<KE>`.d*(B`-n8D9oK<Up]c$X$(,)M8Zt7/[rdkqTgl-0cuGMv'?>-XV1q['-5k'cAZ69e;D_?$ZPP&s^+7])$*$#@QYi9,5P	r+$%CE=68>K8r0=dSC%%(@p7" 13091 ".m7jilQ02'0-VWAg<a/''3u.=4L$Y)6k/K:_[3=&jvL<L0C/2'v:^;-DIBW,B4E68:kZ;%?8(Q8BH=kO65BW?xSG&#@uU,DS*,?.+(o(#1vCS8#CHF>TlGW'b)Tq7VT9q^*^$$.:&N@@" 13092 "$&)WHtPm*5_rO0&e%K&#-30j(E4#'Zb.o/(Tpm$>K'f@[PvFl,hfINTNU6u'0pao7%XUp9]5.>%h`8_=VYbxuel.NTSsJfLacFu3B'lQSu/m6-Oqem8T+oE--$0a/k]uj9EwsG>%veR*" 13093 "hv^BFpQj:K'#SJ,sB-'#](j.Lg92rTw-*n%@/;39rrJF,l#qV%OrtBeC6/,;qB3ebNW[?,Hqj2L.1NP&GjUR=1D8QaS3Up&@*9wP?+lo7b?@%'k4`p0Z$22%K3+iCZj?XJN4Nm&+YF]u" 13094 "@-W$U%VEQ/,,>>#)D<h#`)h0:<Q6909ua+&VU%n2:cG3FJ-%@Bj-DgLr`Hw&HAKjKjseK</xKT*)B,N9X3]krc12t'pgTV(Lv-tL[xg_%=M_q7a^x?7Ubd>#%8cY#YZ?=,`Wdxu/ae&#" 13095 "w6)R89tI#6@s'(6Bf7a&?S=^ZI_kS&ai`&=tE72L_D,;^R)7[$s<Eh#c&)q.MXI%#v9ROa5FZO%sF7q7Nwb&#ptUJ:aqJe$Sl68%.D###EC><?-aF&#RNQv>o8lKN%5/$(vdfq7+ebA#" 13096 "u1p]ovUKW&Y%q]'>$1@-[xfn$7ZTp7mM,G,Ko7a&Gu%G[RMxJs[0MM%wci.LFDK)(<c`Q8N)jEIF*+?P2a8g%)$q]o2aH8C&<SibC/q,(e:v;-b#6[$NtDZ84Je2KNvB#$P5?tQ3nt(0" 13097 "d=j.LQf./Ll33+(;q3L-w=8dX$#WF&uIJ@-bfI>%:_i2B5CsR8&9Z&#=mPEnm0f`<&c)QL5uJ#%u%lJj+D-r;BoFDoS97h5g)E#o:&S4weDF,9^Hoe`h*L+_a*NrLW-1pG_&2UdB8" 13098 "6e%B/:=>)N4xeW.*wft-;$'58-ESqr<b?UI(_%@[P46>#U`'6AQ]m&6/`Z>#S?YY#Vc;r7U2&326d=w&H####?TZ`*4?&.MK?LP8Vxg>$[QXc%QJv92.(Db*B)gb*BM9dM*hJMAo*c&#" 13099 "b0v=Pjer]$gG&JXDf->'StvU7505l9$AFvgYRI^&<^b68?j#q9QX4SM'RO#&sL1IM.rJfLUAj221]d##DW=m83u5;'bYx,*Sl0hL(W;;$doB&O/TQ:(Z^xBdLjL<Lni;''X.`$#8+1GD" 13100 ":k$YUWsbn8ogh6rxZ2Z9]%nd+>V#*8U_72Lh+2Q8Cj0i:6hp&$C/:p(HK>T8Y[gHQ4`4)'$Ab(Nof%V'8hL&#<NEdtg(n'=S1A(Q1/I&4([%dM`,Iu'1:_hL>SfD07&6D<fp8dHM7/g+" 13101 "tlPN9J*rKaPct&?'uBCem^jn%9_K)<,C5K3s=5g&GmJb*[SYq7K;TRLGCsM-$$;S%:Y@r7AK0pprpL<Lrh,q7e/%KWK:50I^+m'vi`3?%Zp+<-d+$L-Sv:@.o19n$s0&39;kn;S%BSq*" 13102 "$3WoJSCLweV[aZ'MQIjO<7;X-X;&+dMLvu#^UsGEC9WEc[X(wI7#2.(F0jV*eZf<-Qv3J-c+J5AlrB#$p(H68LvEA'q3n0#m,[`*8Ft)FcYgEud]CWfm68,(aLA$@EFTgLXoBq/UPlp7" 13103 ":d[/;r_ix=:TF`S5H-b<LI&HY(K=h#)]Lk$K14lVfm:x$H<3^Ql<M`$OhapBnkup'D#L$Pb_`N*g]2e;X/Dtg,bsj&K#2[-:iYr'_wgH)NUIR8a1n#S?Yej'h8^58UbZd+^FKD*T@;6A" 13104 "7aQC[K8d-(v6GI$x:T<&'Gp5Uf>@M.*J:;$-rv29'M]8qMv-tLp,'886iaC=Hb*YJoKJ,(j%K=H`K.v9HggqBIiZu'QvBT.#=)0ukruV&.)3=(^1`o*Pj4<-<aN((^7('#Z0wK#5GX@7" 13105 "u][`*S^43933A4rl][`*O4CgLEl]v$1Q3AeF37dbXk,.)vj#x'd`;qgbQR%FW,2(?LO=s%Sc68%NP'##Aotl8x=BE#j1UD([3$M(]UI2LX3RpKN@;/#f'f/&_mt&F)XdF<9t4)Qa.*kT" 13106 "LwQ'(TTB9.xH'>#MJ+gLq9-##@HuZPN0]u:h7.T..G:;$/Usj(T7`Q8tT72LnYl<-qx8;-HV7Q-&Xdx%1a,hC=0u+HlsV>nuIQL-5<N?)NBS)QN*_I,?&)2'IM%L3I)X((e/dl2&8'<M" 13107 ":^#M*Q+[T.Xri.LYS3v%fF`68h;b-X[/En'CR.q7E)p'/kle2HM,u;^%OKC-N+Ll%F9CF<Nf'^#t2L,;27W:0O@6##U6W7:$rJfLWHj$#)woqBefIZ.PK<b*t7ed;p*_m;4ExK#h@&]>" 13108 "_>@kXQtMacfD.m-VAb8;IReM3$wf0''hra*so568'Ip&vRs849'MRYSp%:t:h5qSgwpEr$B>Q,;s(C#$)`svQuF$##-D,##,g68@2[T;.XSdN9Qe)rpt._K-#5wF)sP'##p#C0c%-Gb%" 13109 "hd+<-j'Ai*x&&HMkT]C'OSl##5RG[JXaHN;d'uA#x._U;.`PU@(Z3dt4r152@:v,'R.Sj'w#0<-;kPI)FfJ&#AYJ&#//)>-k=m=*XnK$>=)72L]0I%>.G690a:$##<,);?;72#?x9+d;" 13110 "^V'9;jY@;)br#q^YQpx:X#Te$Z^'=-=bGhLf:D6&bNwZ9-ZD#n^9HhLMr5G;']d&6'wYmTFmL<LD)F^%[tC'8;+9E#C$g%#5Y>q9wI>P(9mI[>kC-ekLC/R&CH+s'B;K-M6$EB%is00:" 13111 "+A4[7xks.LrNk0&E)wILYF@2L'0Nb$+pv<(2.768/FrY&h$^3i&@+G%JT'<-,v`3;_)I9M^AE]CN?Cl2AZg+%4iTpT3<n-&%H%b<FDj2M<hH=&Eh<2Len$b*aTX=-8QxN)k11IM1c^j%" 13112 "9s<L<NFSo)B?+<-(GxsF,^-Eh@$4dXhN$+#rxK8'je'D7k`e;)2pYwPA'_p9&@^18ml1^[@g4t*[JOa*[=Qp7(qJ_oOL^('7fB&Hq-:sf,sNj8xq^>$U4O]GKx'm9)b@p7YsvK3w^YR-" 13113 "CdQ*:Ir<($u&)#(&?L9Rg3H)4fiEp^iI9O8KnTj,]H?D*r7'M;PwZ9K0E^k&-cpI;.p/6_vwoFMV<->#%Xi.LxVnrU(4&8/P+:hLSKj$#U%]49t'I:rgMi'FL@a:0Y-uA[39',(vbma*" 13114 "hU%<-SRF`Tt:542R_VV$p@[p8DV[A,?1839FWdF<TddF<9Ah-6&9tWoDlh]&1SpGMq>Ti1O*H&#(AL8[_P%.M>v^-))qOT*F5Cq0`Ye%+$B6i:7@0IX<N+T+0MlMBPQ*Vj>SsD<U4JHY" 13115 "8kD2)2fU/M#$e.)T4,_=8hLim[&);?UkK'-x?'(:siIfL<$pFM`i<?%W(mGDHM%>iWP,##P`%/L<eXi:@Z9C.7o=@(pXdAO/NLQ8lPl+HPOQa8wD8=^GlPa8TKI1CjhsCTSLJM'/Wl>-" 13116 "S(qw%sf/@%#B6;/U7K]uZbi^Oc^2n<bhPmUkMw>%t<)'mEVE''n`WnJra$^TKvX5B>;_aSEK',(hwa0:i4G?.Bci.(X[?b*($,=-n<.Q%`(X=?+@Am*Js0&=3bh8K]mL<LoNs'6,'85`" 13117 "0?t/'_U59@]ddF<#LdF<eWdF<OuN/45rY<-L@&#+fm>69=Lb,OcZV/);TTm8VI;?%OtJ<(b4mq7M6:u?KRdF<gR@2L=FNU-<b[(9c/ML3m;Z[$oF3g)GAWqpARc=<ROu7cL5l;-[A]%/" 13118 "+fsd;l#SafT/f*W]0=O'$(Tb<[)*@e775R-:Yob%g*>l*:xP?Yb.5)%w_I?7uk5JC+FS(m#i'k.'a0i)9<7b'fs'59hq$*5Uhv##pi^8+hIEBF`nvo`;'l0.^S1<-wUK2/Coh58KKhLj" 13119 "M=SO*rfO`+qC`W-On.=AJ56>>i2@2LH6A:&5q`?9I3@@'04&p2/LVa*T-4<-i3;M9UvZd+N7>b*eIwg:CC)c<>nO&#<IGe;__.thjZl<%w(Wk2xmp4Q@I#I9,DF]u7-P=.-_:YJ]aS@V" 13120 "?6*C()dOp7:WL,b&3Rg/.cmM9&r^>$(>.Z-I&J(Q0Hd5Q%7Co-b`-c<N(6r@ip+AurK<m86QIth*#v;-OBqi+L7wDE-Ir8K['m+DDSLwK&/.?-V%U_%3:qKNu$_b*B-kp7NaD'QdWQPK" 13121 "Yq[@>P)hI;*_F]u`Rb[.j8_Q/<&>uu+VsH$sM9TA%?)(vmJ80),P7E>)tjD%2L=-t#fK[%`v=Q8<FfNkgg^oIbah*#8/Qt$F&:K*-(N/'+1vMB,u()-a.VUU*#[e%gAAO(S>WlA2);Sa" 13122 ">gXm8YB`1d@K#n]76-a$U,mF<fX]idqd)<3,]J7JmW4`6]uks=4-72L(jEk+:bJ0M^q-8Dm_Z?0olP1C9Sa&H[d&c$ooQUj]Exd*3ZM@-WGW2%s',B-_M%>%Ul:#/'xoFM9QX-$.QN'>" 13123 "[%$Z$uF6pA6Ki2O5:8w*vP1<-1`[G,)-m#>0`P&#eb#.3i)rtB61(o'$?X3B</R90;eZ]%Ncq;-Tl]#F>2Qft^ae_5tKL9MUe9b*sLEQ95C&`=G?@Mj=wh*'3E>=-<)Gt*Iw)'QG:`@I" 13124 "wOf7&]1i'S01B+Ev/Nac#9S;=;YQpg_6U`*kVY39xK,[/6Aj7:'1Bm-_1EYfa1+o&o4hp7KN_Q(OlIo@S%;jVdn0'1<Vc52=u`3^o-n1'g4v58Hj&6_t7$##?M)c<$bgQ_'SY((-xkA#" 13125 "Y(,p'H9rIVY-b,'%bCPF7.J<Up^,(dU1VY*5#WkTU>h19w,WQhLI)3S#f$2(eb,jr*b;3Vw]*7NH%$c4Vs,eD9>XW8?N]o+(*pgC%/72LV-u<Hp,3@e^9UB1J+ak9-TN/mhKPg+AJYd$" 13126 "MlvAF_jCK*.O-^(63adMT->W%iewS8W6m2rtCpo'RS1R84=@paTKt)>=%&1[)*vp'u+x,VrwN;&]kuO9JDbg=pO$J*.jVe;u'm0dr9l,<*wMK*Oe=g8lV_KEBFkO'oU]^=[-792#ok,)" 13127 "i]lR8qQ2oA8wcRCZ^7w/Njh;?.stX?Q1>S1q4Bn$)K1<-rGdO'$Wr.Lc.CG)$/*JL4tNR/,SVO3,aUw'DJN:)Ss;wGn9A32ijw%FL+Z0Fn.U9;reSq)bmI32U==5ALuG&#Vf1398/pVo" 13128 "1*c-(aY168o<`JsSbk-,1N;$>0:OUas(3:8Z972LSfF8eb=c-;>SPw7.6hn3m`9^Xkn(r.qS[0;T%&Qc=+STRxX'q1BNk3&*eu2;&8q$&x>Q#Q7^Tf+6<(d%ZVmj2bDi%.3L2n+4W'$P" 13129 "iDDG)g,r%+?,$@?uou5tSe2aN_AQU*<h`e-GI7)?OK2A.d7_c)?wQ5AS@DL3r#7fSkgl6-++D:'A,uq7SvlB$pcpH'q3n0#_%dY#xCpr-l<F0NR@-##FEV6NTF6##$l84N1w?AO>'IAO" 13130 "URQ##V^Fv-XFbGM7Fl(N<3DhLGF%q.1rC$#:T__&Pi68%0xi_&[qFJ(77j_&JWoF.V735&T,[R*:xFR*K5>>#`bW-?4Ne_&6Ne_&6Ne_&n`kr-#GJcM6X;uM6X;uM(.a..^2TkL%oR(#" 13131 ";u.T%fAr%4tJ8&><1=GHZ_+m9/#H1F^R#SC#*N=BA9(D?v[UiFY>>^8p,KKF.W]L29uLkLlu/+4T<XoIB&hx=T1PcDaB&;HH+-AFr?(m9HZV)FKS8JCw;SD=6[^/DZUL`EUDf]GGlG&>" 13132 "w$)F./^n3+rlo+DB;5sIYGNk+i1t-69Jg--0pao7Sm#K)pdHW&;LuDNH@H>#/X-TI(;P>#,Gc>#0Su>#4`1?#8lC?#<xU?#@.i?#D:%@#HF7@#LRI@#P_[@#Tkn@#Xw*A#]-=A#a9OA#" 13133 "d<F&#*;G##.GY##2Sl##6`($#:l:$#>xL$#B.`$#F:r$#JF.%#NR@%#R_R%#Vke%#Zww%#_-4^Rh%Sflr-k'MS.o?.5/sWel/wpEM0%3'/1)K^f1-d>G21&v(35>V`39V7A4=onx4" 13134 "A1OY5EI0;6Ibgr6M$HS7Q<)58C5w,;WoA*#[%T*#`1g*#d=#+#hI5+#lUG+#pbY+#tnl+#x$),#&1;,#*=M,#.I`,#2Ur,#6b.-#;w[H#iQtA#m^0B#qjBB#uvTB##-hB#'9$C#+E6C#" 13135 "/QHC#3^ZC#7jmC#;v)D#?,<D#C8ND#GDaD#KPsD#O]/E#g1A5#KA*1#gC17#MGd;#8(02#L-d3#rWM4#Hga1#,<w0#T.j<#O#'2#CYN1#qa^:#_4m3#o@/=#eG8=#t8J5#`+78#4uI-#" 13136 "m3B2#SB[8#Q0@8#i[*9#iOn8#1Nm;#^sN9#qh<9#:=x-#P;K2#$%X9#bC+.#Rg;<#mN=.#MTF.#RZO.#2?)4#Y#(/#[)1/#b;L/#dAU/#0Sv;#lY$0#n`-0#sf60#(F24#wrH0#%/e0#" 13137 "TmD<#%JSMFove:CTBEXI:<eh2g)B,3h2^G3i;#d3jD>)4kMYD4lVu`4m`:&5niUA5@(A5BA1]PBB:xlBCC=2CDLXMCEUtiCf&0g2'tN?PGT4CPGT4CPGT4CPGT4CPGT4CPGT4CPGT4CP" 13138 "GT4CPGT4CPGT4CPGT4CPGT4CPGT4CP-qekC`.9kEg^+F$kwViFJTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5o,^<-28ZI'O?;xp" 13139 "O?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xp;7q-#lLYI:xvD=#";
13143 #define NK_CURSOR_DATA_W 90 13144 #define NK_CURSOR_DATA_H 27 13145 NK_GLOBAL const char nk_custom_cursor_data[NK_CURSOR_DATA_W * NK_CURSOR_DATA_H + 1] =
13147 "..- -XXXXXXX- X - X -XXXXXXX - XXXXXXX" 13148 "..- -X.....X- X.X - X.X -X.....X - X.....X" 13149 "--- -XXX.XXX- X...X - X...X -X....X - X....X" 13150 "X - X.X - X.....X - X.....X -X...X - X...X" 13151 "XX - X.X -X.......X- X.......X -X..X.X - X.X..X" 13152 "X.X - X.X -XXXX.XXXX- XXXX.XXXX -X.X X.X - X.X X.X" 13153 "X..X - X.X - X.X - X.X -XX X.X - X.X XX" 13154 "X...X - X.X - X.X - XX X.X XX - X.X - X.X " 13155 "X....X - X.X - X.X - X.X X.X X.X - X.X - X.X " 13156 "X.....X - X.X - X.X - X..X X.X X..X - X.X - X.X " 13157 "X......X - X.X - X.X - X...XXXXXX.XXXXXX...X - X.X XX-XX X.X " 13158 "X.......X - X.X - X.X -X.....................X- X.X X.X-X.X X.X " 13159 "X........X - X.X - X.X - X...XXXXXX.XXXXXX...X - X.X..X-X..X.X " 13160 "X.........X -XXX.XXX- X.X - X..X X.X X..X - X...X-X...X " 13161 "X..........X-X.....X- X.X - X.X X.X X.X - X....X-X....X " 13162 "X......XXXXX-XXXXXXX- X.X - XX X.X XX - X.....X-X.....X " 13163 "X...X..X --------- X.X - X.X - XXXXXXX-XXXXXXX " 13164 "X..X X..X - -XXXX.XXXX- XXXX.XXXX ------------------------------------" 13165 "X.X X..X - -X.......X- X.......X - XX XX - " 13166 "XX X..X - - X.....X - X.....X - X.X X.X - " 13167 " X..X - X...X - X...X - X..X X..X - " 13168 " XX - X.X - X.X - X...XXXXXXXXXXXXX...X - " 13169 "------------ - X - X -X.....................X- " 13170 " ----------------------------------- X...XXXXXXXXXXXXX...X - " 13177 #pragma clang diagnostic pop 13178 #elif defined(__GNUC__) || defined(__GNUG__) 13179 #pragma GCC diagnostic pop 13189 nk_decompress_length(
unsigned char *
input)
13191 return (
unsigned int)((input[8] << 24) + (input[9] << 16) + (input[10] << 8) + input[11]);
13194 nk__match(
unsigned char *data,
unsigned int length)
13197 NK_ASSERT (nk__dout + length <= nk__barrier);
13198 if (nk__dout + length > nk__barrier) { nk__dout +=
length;
return; }
13199 if (data < nk__barrier4) { nk__dout = nk__barrier+1;
return; }
13200 while (length--) *nk__dout++ = *data++;
13203 nk__lit(
unsigned char *data,
unsigned int length)
13205 NK_ASSERT (nk__dout + length <= nk__barrier);
13206 if (nk__dout + length > nk__barrier) { nk__dout +=
length;
return; }
13207 if (data < nk__barrier2) { nk__dout = nk__barrier+1;
return; }
13208 NK_MEMCPY(nk__dout, data, length);
13212 nk_decompress_token(
unsigned char *i)
13214 #define nk__in2(x) ((i[x] << 8) + i[(x)+1]) 13215 #define nk__in3(x) ((i[x] << 16) + nk__in2((x)+1)) 13216 #define nk__in4(x) ((i[x] << 24) + nk__in3((x)+1)) 13219 if (*i >= 0x80) nk__match(nk__dout-i[1]-1, (
unsigned int)i[0] - 0x80 + 1), i += 2;
13220 else if (*i >= 0x40) nk__match(nk__dout-(nk__in2(0) - 0x4000 + 1), (
unsigned int)i[2]+1), i += 3;
13221 else nk__lit(i+1, (
unsigned int)i[0] - 0x20 + 1), i += 1 + (i[0] - 0x20 + 1);
13223 if (*i >= 0x18) nk__match(nk__dout-(
unsigned int)(nk__in3(0) - 0x180000 + 1), (
unsigned int)i[3]+1), i += 4;
13224 else if (*i >= 0x10) nk__match(nk__dout-(
unsigned int)(nk__in3(0) - 0x100000 + 1), (
unsigned int)nk__in2(3)+1), i += 5;
13225 else if (*i >= 0x08) nk__lit(i+2, (
unsigned int)nk__in2(0) - 0x0800 + 1), i += 2 + (nk__in2(0) - 0x0800 + 1);
13226 else if (*i == 0x07) nk__lit(i+3, (
unsigned int)nk__in2(1) + 1), i += 3 + (nk__in2(1) + 1);
13227 else if (*i == 0x06) nk__match(nk__dout-(
unsigned int)(nk__in3(1)+1), i[4]+1u), i += 5;
13228 else if (*i == 0x04) nk__match(nk__dout-(
unsigned int)(nk__in3(1)+1), (
unsigned int)nk__in2(4)+1u), i += 6;
13233 nk_adler32(
unsigned int adler32,
unsigned char *buffer,
unsigned int buflen)
13235 const unsigned long ADLER_MOD = 65521;
13236 unsigned long s1 = adler32 & 0xffff, s2 = adler32 >> 16;
13237 unsigned long blocklen,
i;
13239 blocklen = buflen % 5552;
13241 for (i=0; i + 7 < blocklen; i += 8) {
13242 s1 += buffer[0]; s2 +=
s1;
13243 s1 += buffer[1]; s2 +=
s1;
13244 s1 += buffer[2]; s2 +=
s1;
13245 s1 += buffer[3]; s2 +=
s1;
13246 s1 += buffer[4]; s2 +=
s1;
13247 s1 += buffer[5]; s2 +=
s1;
13248 s1 += buffer[6]; s2 +=
s1;
13249 s1 += buffer[7]; s2 +=
s1;
13252 for (; i < blocklen; ++
i) {
13253 s1 += *buffer++; s2 +=
s1;
13256 s1 %= ADLER_MOD; s2 %= ADLER_MOD;
13257 buflen -= (
unsigned int)blocklen;
13260 return (
unsigned int)(s2 << 16) + (
unsigned int)
s1;
13263 nk_decompress(
unsigned char *output,
unsigned char *i,
unsigned int length)
13266 if (nk__in4(0) != 0x57bC0000)
return 0;
13267 if (nk__in4(4) != 0)
return 0;
13268 olen = nk_decompress_length(i);
13270 nk__barrier3 = i+
length;
13271 nk__barrier = output + olen;
13272 nk__barrier4 = output;
13277 unsigned char *old_i =
i;
13278 i = nk_decompress_token(i);
13280 if (*i == 0x05 && i[1] == 0xfa) {
13281 NK_ASSERT(nk__dout == output + olen);
13282 if (nk__dout != output + olen)
return 0;
13283 if (nk_adler32(1, output, olen) != (
unsigned int) nk__in4(2))
13291 NK_ASSERT(nk__dout <= output + olen);
13292 if (nk__dout > output + olen)
13297 nk_decode_85_byte(
char c)
13299 return (
unsigned int)((c >=
'\\') ? c-36 : c-35);
13302 nk_decode_85(
unsigned char* dst,
const unsigned char* src)
13307 nk_decode_85_byte((
char)src[0]) +
13308 85 * (nk_decode_85_byte((
char)src[1]) +
13309 85 * (nk_decode_85_byte((
char)src[2]) +
13310 85 * (nk_decode_85_byte((
char)src[3]) +
13311 85 * nk_decode_85_byte((
char)src[4]))));
13314 dst[0] = (
unsigned char)((tmp >> 0) & 0xFF);
13315 dst[1] = (
unsigned char)((tmp >> 8) & 0xFF);
13316 dst[2] = (
unsigned char)((tmp >> 16) & 0xFF);
13317 dst[3] = (
unsigned char)((tmp >> 24) & 0xFF);
13329 NK_API struct nk_font_config
13330 nk_font_config(float pixel_height)
13332 struct nk_font_config cfg;
13336 cfg.ttf_data_owned_by_atlas = 0;
13337 cfg.size = pixel_height;
13338 cfg.oversample_h = 3;
13339 cfg.oversample_v = 1;
13340 cfg.pixel_snap = 0;
13341 cfg.coord_type = NK_COORD_UV;
13343 cfg.range = nk_font_default_glyph_ranges();
13344 cfg.merge_mode = 0;
13345 cfg.fallback_glyph =
'?';
13350 #ifdef NK_INCLUDE_DEFAULT_ALLOCATOR 13352 nk_font_atlas_init_default(
struct nk_font_atlas *atlas)
13355 if (!atlas)
return;
13357 atlas->temporary.userdata.ptr = 0;
13358 atlas->temporary.alloc = nk_malloc;
13359 atlas->temporary.free = nk_mfree;
13360 atlas->permanent.userdata.ptr = 0;
13361 atlas->permanent.alloc = nk_malloc;
13362 atlas->permanent.free = nk_mfree;
13366 nk_font_atlas_init(
struct nk_font_atlas *atlas,
struct nk_allocator *alloc)
13370 if (!atlas || !alloc)
return;
13372 atlas->permanent = *alloc;
13373 atlas->temporary = *alloc;
13376 nk_font_atlas_init_custom(
struct nk_font_atlas *atlas,
13380 NK_ASSERT(permanent);
13381 NK_ASSERT(temporary);
13382 if (!atlas || !permanent || !temporary)
return;
13384 atlas->permanent = *permanent;
13385 atlas->temporary = *temporary;
13388 nk_font_atlas_begin(
struct nk_font_atlas *atlas)
13391 NK_ASSERT(atlas->temporary.alloc && atlas->temporary.free);
13392 NK_ASSERT(atlas->permanent.alloc && atlas->permanent.free);
13393 if (!atlas || !atlas->permanent.alloc || !atlas->permanent.free ||
13394 !atlas->temporary.alloc || !atlas->temporary.free)
return;
13395 if (atlas->glyphs) {
13396 atlas->permanent.free(atlas->permanent.userdata, atlas->glyphs);
13399 if (atlas->pixel) {
13400 atlas->permanent.free(atlas->permanent.userdata, atlas->pixel);
13405 nk_font_atlas_add(
struct nk_font_atlas *atlas,
const struct nk_font_config *config)
13407 struct nk_font *font = 0;
13408 struct nk_font_config *
cfg;
13411 NK_ASSERT(atlas->permanent.alloc);
13412 NK_ASSERT(atlas->permanent.free);
13413 NK_ASSERT(atlas->temporary.alloc);
13414 NK_ASSERT(atlas->temporary.free);
13417 NK_ASSERT(config->ttf_blob);
13418 NK_ASSERT(config->ttf_size);
13419 NK_ASSERT(config->size > 0.0f);
13421 if (!atlas || !config || !config->ttf_blob || !config->ttf_size || config->size <= 0.0f||
13422 !atlas->permanent.alloc || !atlas->permanent.free ||
13423 !atlas->temporary.alloc || !atlas->temporary.free)
13427 cfg = (
struct nk_font_config*)
13428 atlas->permanent.alloc(atlas->permanent.userdata,0,
sizeof(
struct nk_font_config));
13429 NK_MEMCPY(cfg, config,
sizeof(*config));
13433 if (!config->merge_mode) {
13435 if (!atlas->config) {
13436 atlas->config =
cfg;
13439 struct nk_font_config *i = atlas->config;
13440 while (i->next) i = i->next;
13445 font = (
struct nk_font*)
13446 atlas->permanent.alloc(atlas->permanent.userdata,0,
sizeof(
struct nk_font));
13448 nk_zero(font,
sizeof(*font));
13449 if (!font)
return 0;
13450 font->config =
cfg;
13453 if (!atlas->fonts) {
13454 atlas->fonts =
font;
13457 struct nk_font *i = atlas->fonts;
13458 while (i->next) i = i->next;
13462 cfg->font = &font->info;
13465 struct nk_font *f = 0;
13466 struct nk_font_config *c = 0;
13467 NK_ASSERT(atlas->font_num);
13470 cfg->font = &f->info;
13478 if (!config->ttf_data_owned_by_atlas) {
13479 cfg->ttf_blob = atlas->permanent.alloc(atlas->permanent.userdata,0, cfg->ttf_size);
13480 NK_ASSERT(cfg->ttf_blob);
13481 if (!cfg->ttf_blob) {
13485 NK_MEMCPY(cfg->ttf_blob, config->ttf_blob, cfg->ttf_size);
13486 cfg->ttf_data_owned_by_atlas = 1;
13492 nk_font_atlas_add_from_memory(
struct nk_font_atlas *atlas,
void *memory,
13493 nk_size size,
float height,
const struct nk_font_config *config)
13495 struct nk_font_config cfg;
13500 NK_ASSERT(atlas->temporary.alloc);
13501 NK_ASSERT(atlas->temporary.free);
13502 NK_ASSERT(atlas->permanent.alloc);
13503 NK_ASSERT(atlas->permanent.free);
13504 if (!atlas || !atlas->temporary.alloc || !atlas->temporary.free || !memory || !size ||
13505 !atlas->permanent.alloc || !atlas->permanent.free)
13508 cfg = (
config) ? *config: nk_font_config(height);
13510 cfg.ttf_size =
size;
13512 cfg.ttf_data_owned_by_atlas = 0;
13513 return nk_font_atlas_add(atlas, &cfg);
13515 #ifdef NK_INCLUDE_STANDARD_IO 13517 nk_font_atlas_add_from_file(
struct nk_font_atlas *atlas,
const char *
file_path,
13518 float height,
const struct nk_font_config *config)
13522 struct nk_font_config cfg;
13525 NK_ASSERT(atlas->temporary.alloc);
13526 NK_ASSERT(atlas->temporary.free);
13527 NK_ASSERT(atlas->permanent.alloc);
13528 NK_ASSERT(atlas->permanent.free);
13530 if (!atlas || !file_path)
return 0;
13531 memory = nk_file_load(file_path, &size, &atlas->permanent);
13532 if (!memory)
return 0;
13534 cfg = (
config) ? *config: nk_font_config(height);
13536 cfg.ttf_size =
size;
13538 cfg.ttf_data_owned_by_atlas = 1;
13539 return nk_font_atlas_add(atlas, &cfg);
13543 nk_font_atlas_add_compressed(
struct nk_font_atlas *atlas,
13544 void *compressed_data, nk_size compressed_size,
float height,
13545 const struct nk_font_config *config)
13547 unsigned int decompressed_size;
13548 void *decompressed_data;
13549 struct nk_font_config cfg;
13552 NK_ASSERT(atlas->temporary.alloc);
13553 NK_ASSERT(atlas->temporary.free);
13554 NK_ASSERT(atlas->permanent.alloc);
13555 NK_ASSERT(atlas->permanent.free);
13557 NK_ASSERT(compressed_data);
13558 NK_ASSERT(compressed_size);
13559 if (!atlas || !compressed_data || !atlas->temporary.alloc || !atlas->temporary.free ||
13560 !atlas->permanent.alloc || !atlas->permanent.free)
13563 decompressed_size = nk_decompress_length((
unsigned char*)compressed_data);
13564 decompressed_data = atlas->permanent.alloc(atlas->permanent.userdata,0,decompressed_size);
13565 NK_ASSERT(decompressed_data);
13566 if (!decompressed_data)
return 0;
13567 nk_decompress((
unsigned char*)decompressed_data, (
unsigned char*)compressed_data,
13568 (
unsigned int)compressed_size);
13570 cfg = (
config) ? *config: nk_font_config(height);
13571 cfg.ttf_blob = decompressed_data;
13572 cfg.ttf_size = decompressed_size;
13574 cfg.ttf_data_owned_by_atlas = 1;
13575 return nk_font_atlas_add(atlas, &cfg);
13578 nk_font_atlas_add_compressed_base85(
struct nk_font_atlas *atlas,
13579 const char *data_base85,
float height,
const struct nk_font_config *config)
13581 int compressed_size;
13582 void *compressed_data;
13583 struct nk_font *
font;
13586 NK_ASSERT(atlas->temporary.alloc);
13587 NK_ASSERT(atlas->temporary.free);
13588 NK_ASSERT(atlas->permanent.alloc);
13589 NK_ASSERT(atlas->permanent.free);
13591 NK_ASSERT(data_base85);
13592 if (!atlas || !data_base85 || !atlas->temporary.alloc || !atlas->temporary.free ||
13593 !atlas->permanent.alloc || !atlas->permanent.free)
13596 compressed_size = (((int)
nk_strlen(data_base85) + 4) / 5) * 4;
13597 compressed_data = atlas->temporary.alloc(atlas->temporary.userdata,0, (nk_size)compressed_size);
13598 NK_ASSERT(compressed_data);
13599 if (!compressed_data)
return 0;
13600 nk_decode_85((
unsigned char*)compressed_data, (
const unsigned char*)data_base85);
13601 font = nk_font_atlas_add_compressed(atlas, compressed_data,
13602 (nk_size)compressed_size, height, config);
13603 atlas->temporary.free(atlas->temporary.userdata, compressed_data);
13607 #ifdef NK_INCLUDE_DEFAULT_FONT 13609 nk_font_atlas_add_default(
struct nk_font_atlas *atlas,
13610 float pixel_height,
const struct nk_font_config *config)
13613 NK_ASSERT(atlas->temporary.alloc);
13614 NK_ASSERT(atlas->temporary.free);
13615 NK_ASSERT(atlas->permanent.alloc);
13616 NK_ASSERT(atlas->permanent.free);
13617 return nk_font_atlas_add_compressed_base85(atlas,
13618 nk_proggy_clean_ttf_compressed_data_base85, pixel_height, config);
13622 nk_font_atlas_bake(
struct nk_font_atlas *atlas,
int *width,
int *height,
13623 enum nk_font_atlas_format fmt)
13627 nk_size tmp_size, img_size;
13628 struct nk_font *font_iter;
13629 struct nk_font_baker *baker;
13632 NK_ASSERT(atlas->temporary.alloc);
13633 NK_ASSERT(atlas->temporary.free);
13634 NK_ASSERT(atlas->permanent.alloc);
13635 NK_ASSERT(atlas->permanent.free);
13639 if (!atlas || !width || !height ||
13640 !atlas->temporary.alloc || !atlas->temporary.free ||
13641 !atlas->permanent.alloc || !atlas->permanent.free)
13644 #ifdef NK_INCLUDE_DEFAULT_FONT 13646 if (!atlas->font_num)
13647 atlas->default_font = nk_font_atlas_add_default(atlas, 13.0f, 0);
13649 NK_ASSERT(atlas->font_num);
13650 if (!atlas->font_num)
return 0;
13653 nk_font_baker_memory(&tmp_size, &atlas->glyph_count, atlas->config, atlas->font_num);
13654 tmp = atlas->temporary.alloc(atlas->temporary.userdata,0, tmp_size);
13659 baker = nk_font_baker(tmp, atlas->glyph_count, atlas->font_num, &atlas->temporary);
13660 atlas->glyphs = (
struct nk_font_glyph*)atlas->permanent.alloc(
13661 atlas->permanent.userdata,0,
sizeof(
struct nk_font_glyph)*(nk_size)atlas->glyph_count);
13662 NK_ASSERT(atlas->glyphs);
13663 if (!atlas->glyphs)
13667 atlas->custom.w = (NK_CURSOR_DATA_W*2)+1;
13668 atlas->custom.h = NK_CURSOR_DATA_H + 1;
13669 if (!nk_font_bake_pack(baker, &img_size, width, height, &atlas->custom,
13670 atlas->config, atlas->font_num, &atlas->temporary))
13674 atlas->pixel = atlas->temporary.alloc(atlas->temporary.userdata,0, img_size);
13675 NK_ASSERT(atlas->pixel);
13680 nk_font_bake(baker, atlas->pixel, *width, *height,
13681 atlas->glyphs, atlas->glyph_count, atlas->config, atlas->font_num);
13682 nk_font_bake_custom_data(atlas->pixel, *width, *height, atlas->custom,
13683 nk_custom_cursor_data, NK_CURSOR_DATA_W, NK_CURSOR_DATA_H,
'.',
'X');
13685 if (fmt == NK_FONT_ATLAS_RGBA32) {
13687 void *img_rgba = atlas->temporary.alloc(atlas->temporary.userdata,0,
13688 (nk_size)(*width * *height * 4));
13689 NK_ASSERT(img_rgba);
13690 if (!img_rgba)
goto failed;
13691 nk_font_bake_convert(img_rgba, *width, *height, atlas->pixel);
13692 atlas->temporary.free(atlas->temporary.userdata, atlas->pixel);
13693 atlas->pixel = img_rgba;
13695 atlas->tex_width = *
width;
13696 atlas->tex_height = *
height;
13699 for (font_iter = atlas->fonts; font_iter; font_iter = font_iter->next) {
13700 struct nk_font *font = font_iter;
13701 struct nk_font_config *config = font->config;
13702 nk_font_init(font, config->size, config->fallback_glyph, atlas->glyphs,
13709 {{ 0, 3}, {12,19}, { 0, 0}},
13710 {{13, 0}, { 7,16}, { 4, 8}},
13711 {{31, 0}, {23,23}, {11,11}},
13712 {{21, 0}, { 9, 23}, { 5,11}},
13713 {{55,18}, {23, 9}, {11, 5}},
13714 {{73, 0}, {17,17}, { 9, 9}},
13715 {{55, 0}, {17,17}, { 9, 9}}
13718 struct nk_cursor *cursor = &atlas->cursors[
i];
13719 cursor->
img.
w = (
unsigned short)*width;
13720 cursor->
img.
h = (
unsigned short)*height;
13721 cursor->
img.
region[0] = (
unsigned short)(atlas->custom.x + nk_cursor_data[i][0].
x);
13722 cursor->
img.
region[1] = (
unsigned short)(atlas->custom.y + nk_cursor_data[i][0].
y);
13723 cursor->
img.
region[2] = (
unsigned short)nk_cursor_data[i][1].x;
13724 cursor->
img.
region[3] = (
unsigned short)nk_cursor_data[i][1].y;
13725 cursor->size = nk_cursor_data[
i][1];
13726 cursor->
offset = nk_cursor_data[
i][2];
13729 atlas->temporary.free(atlas->temporary.userdata, tmp);
13730 return atlas->pixel;
13734 if (tmp) atlas->temporary.free(atlas->temporary.userdata, tmp);
13735 if (atlas->glyphs) {
13736 atlas->permanent.free(atlas->permanent.userdata, atlas->glyphs);
13739 if (atlas->pixel) {
13740 atlas->temporary.free(atlas->temporary.userdata, atlas->pixel);
13746 nk_font_atlas_end(
struct nk_font_atlas *atlas, nk_handle texture,
13750 struct nk_font *font_iter;
13759 null->
uv.
x = (atlas->custom.x + 0.5f)/(
float)atlas->tex_width;
13760 null->
uv.
y = (atlas->custom.y + 0.5f)/(
float)atlas->tex_height;
13762 for (font_iter = atlas->fonts; font_iter; font_iter = font_iter->next) {
13763 font_iter->texture =
texture;
13764 #ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT 13765 font_iter->handle.texture =
texture;
13769 atlas->cursors[i].img.handle = texture;
13771 atlas->temporary.free(atlas->temporary.userdata, atlas->pixel);
13773 atlas->tex_width = 0;
13774 atlas->tex_height = 0;
13775 atlas->custom.x = 0;
13776 atlas->custom.y = 0;
13777 atlas->custom.w = 0;
13778 atlas->custom.h = 0;
13781 nk_font_atlas_cleanup(
struct nk_font_atlas *atlas)
13784 NK_ASSERT(atlas->temporary.alloc);
13785 NK_ASSERT(atlas->temporary.free);
13786 NK_ASSERT(atlas->permanent.alloc);
13787 NK_ASSERT(atlas->permanent.free);
13788 if (!atlas || !atlas->permanent.alloc || !atlas->permanent.free)
return;
13789 if (atlas->config) {
13790 struct nk_font_config *iter;
13791 for (iter = atlas->config; iter; iter = iter->next) {
13792 struct nk_font_config *
i;
13793 for (i = iter->n; i != iter; i = i->n) {
13794 atlas->permanent.free(atlas->permanent.userdata, i->ttf_blob);
13797 atlas->permanent.free(atlas->permanent.userdata, iter->ttf_blob);
13798 iter->ttf_blob = 0;
13803 nk_font_atlas_clear(
struct nk_font_atlas *atlas)
13806 NK_ASSERT(atlas->temporary.alloc);
13807 NK_ASSERT(atlas->temporary.free);
13808 NK_ASSERT(atlas->permanent.alloc);
13809 NK_ASSERT(atlas->permanent.free);
13810 if (!atlas || !atlas->permanent.alloc || !atlas->permanent.free)
return;
13812 if (atlas->config) {
13813 struct nk_font_config *iter, *
next;
13814 for (iter = atlas->config; iter; iter = next) {
13815 struct nk_font_config *
i, *
n;
13816 for (i = iter->n; i != iter; i = n) {
13819 atlas->permanent.free(atlas->permanent.userdata, i->ttf_blob);
13820 atlas->permanent.free(atlas->permanent.userdata, i);
13824 atlas->permanent.free(atlas->permanent.userdata, iter->ttf_blob);
13825 atlas->permanent.free(atlas->permanent.userdata, iter);
13829 if (atlas->fonts) {
13830 struct nk_font *iter, *
next;
13831 for (iter = atlas->fonts; iter; iter = next) {
13833 atlas->permanent.free(atlas->permanent.userdata, iter);
13838 atlas->permanent.free(atlas->permanent.userdata, atlas->glyphs);
14107 #define NK_COLOR_MAP(NK_COLOR)\ 14108 NK_COLOR(NK_COLOR_TEXT, 175,175,175,255) \ 14109 NK_COLOR(NK_COLOR_WINDOW, 45, 45, 45, 255) \ 14110 NK_COLOR(NK_COLOR_HEADER, 40, 40, 40, 255) \ 14111 NK_COLOR(NK_COLOR_BORDER, 65, 65, 65, 255) \ 14112 NK_COLOR(NK_COLOR_BUTTON, 50, 50, 50, 255) \ 14113 NK_COLOR(NK_COLOR_BUTTON_HOVER, 40, 40, 40, 255) \ 14114 NK_COLOR(NK_COLOR_BUTTON_ACTIVE, 35, 35, 35, 255) \ 14115 NK_COLOR(NK_COLOR_TOGGLE, 100,100,100,255) \ 14116 NK_COLOR(NK_COLOR_TOGGLE_HOVER, 120,120,120,255) \ 14117 NK_COLOR(NK_COLOR_TOGGLE_CURSOR, 45, 45, 45, 255) \ 14118 NK_COLOR(NK_COLOR_SELECT, 45, 45, 45, 255) \ 14119 NK_COLOR(NK_COLOR_SELECT_ACTIVE, 35, 35, 35,255) \ 14120 NK_COLOR(NK_COLOR_SLIDER, 38, 38, 38, 255) \ 14121 NK_COLOR(NK_COLOR_SLIDER_CURSOR, 100,100,100,255) \ 14122 NK_COLOR(NK_COLOR_SLIDER_CURSOR_HOVER, 120,120,120,255) \ 14123 NK_COLOR(NK_COLOR_SLIDER_CURSOR_ACTIVE, 150,150,150,255) \ 14124 NK_COLOR(NK_COLOR_PROPERTY, 38, 38, 38, 255) \ 14125 NK_COLOR(NK_COLOR_EDIT, 38, 38, 38, 255) \ 14126 NK_COLOR(NK_COLOR_EDIT_CURSOR, 175,175,175,255) \ 14127 NK_COLOR(NK_COLOR_COMBO, 45, 45, 45, 255) \ 14128 NK_COLOR(NK_COLOR_CHART, 120,120,120,255) \ 14129 NK_COLOR(NK_COLOR_CHART_COLOR, 45, 45, 45, 255) \ 14130 NK_COLOR(NK_COLOR_CHART_COLOR_HIGHLIGHT, 255, 0, 0, 255) \ 14131 NK_COLOR(NK_COLOR_SCROLLBAR, 40, 40, 40, 255) \ 14132 NK_COLOR(NK_COLOR_SCROLLBAR_CURSOR, 100,100,100,255) \ 14133 NK_COLOR(NK_COLOR_SCROLLBAR_CURSOR_HOVER, 120,120,120,255) \ 14134 NK_COLOR(NK_COLOR_SCROLLBAR_CURSOR_ACTIVE, 150,150,150,255) \ 14135 NK_COLOR(NK_COLOR_TAB_HEADER, 40, 40, 40,255) 14139 #define NK_COLOR(a,b,c,d,e) {b,c,d,e}, 14140 NK_COLOR_MAP(NK_COLOR)
14144 #define NK_COLOR(a,b,c,d,e) #a, 14145 NK_COLOR_MAP(NK_COLOR)
14152 return nk_color_names[
c];
14159 i.data.image =
img;
14167 i.data.color =
col;
14175 i.data.color =
nk_rgba(0,0,0,0);
14198 style = &ctx->
style;
14199 table = (!
table) ? nk_default_color_style: table;
14202 text = &style->
text;
14207 button = &style->
button;
14287 toggle = &style->
option;
14329 slider = &style->
slider;
14440 edit = &style->
edit;
14478 property->padding =
nk_vec2(4,4);
14479 property->border = 1;
14480 property->rounding = 10;
14481 property->draw_begin = 0;
14482 property->draw_end = 0;
14529 chart = &style->
chart;
14540 combo = &style->
combo;
14729 style = &ctx->
style;
14738 struct nk_config_stack_user_font *font_stack;
14739 struct nk_config_stack_user_font_element *element;
14742 if (!ctx)
return 0;
14745 NK_ASSERT(font_stack->head < (
int)
NK_LEN(font_stack->elements));
14746 if (font_stack->head >= (
int)
NK_LEN(font_stack->elements))
14749 element = &font_stack->elements[font_stack->head++];
14758 struct nk_config_stack_user_font *font_stack;
14759 struct nk_config_stack_user_font_element *element;
14762 if (!ctx)
return 0;
14765 NK_ASSERT(font_stack->head > 0);
14766 if (font_stack->head < 1)
14769 element = &font_stack->elements[--font_stack->head];
14770 *element->address = element->old_value;
14773 #define NK_STYLE_PUSH_IMPLEMENATION(prefix, type, stack) \ 14774 nk_style_push_##type(struct nk_context *ctx, prefix##_##type *address, prefix##_##type value)\ 14776 struct nk_config_stack_##type * type_stack;\ 14777 struct nk_config_stack_##type##_element *element;\ 14779 if (!ctx) return 0;\ 14780 type_stack = &ctx->stacks.stack;\ 14781 NK_ASSERT(type_stack->head < (int)NK_LEN(type_stack->elements));\ 14782 if (type_stack->head >= (int)NK_LEN(type_stack->elements))\ 14784 element = &type_stack->elements[type_stack->head++];\ 14785 element->address = address;\ 14786 element->old_value = *address;\ 14790 #define NK_STYLE_POP_IMPLEMENATION(type, stack) \ 14791 nk_style_pop_##type(struct nk_context *ctx)\ 14793 struct nk_config_stack_##type *type_stack;\ 14794 struct nk_config_stack_##type##_element *element;\ 14796 if (!ctx) return 0;\ 14797 type_stack = &ctx->stacks.stack;\ 14798 NK_ASSERT(type_stack->head > 0);\ 14799 if (type_stack->head < 1)\ 14801 element = &type_stack->elements[--type_stack->head];\ 14802 *element->address = element->old_value;\ 14805 NK_API int NK_STYLE_PUSH_IMPLEMENATION(
struct nk, style_item, style_items)
14806 NK_API int NK_STYLE_PUSH_IMPLEMENATION(nk,
float, floats)
14807 NK_API int NK_STYLE_PUSH_IMPLEMENATION(struct nk, vec2, vectors)
14808 NK_API int NK_STYLE_PUSH_IMPLEMENATION(nk,flags, flags)
14809 NK_API int NK_STYLE_PUSH_IMPLEMENATION(struct nk,color,
colors)
14811 NK_API int NK_STYLE_POP_IMPLEMENATION(style_item, style_items)
14812 NK_API int NK_STYLE_POP_IMPLEMENATION(
float,floats)
14813 NK_API int NK_STYLE_POP_IMPLEMENATION(vec2, vectors)
14814 NK_API int NK_STYLE_POP_IMPLEMENATION(flags,flags)
14822 if (!ctx)
return 0;
14823 style = &ctx->style;
14847 style = &ctx->
style;
14857 style = &ctx->
style;
14859 style->
cursors[i] = &cursors[i];
14873 nk_setup(
struct nk_context *ctx,
const struct nk_user_font *font)
14881 #ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT 14882 nk_draw_list_init(&ctx->draw_list);
14885 #ifdef NK_INCLUDE_DEFAULT_ALLOCATOR 14887 nk_init_default(
struct nk_context *ctx,
const struct nk_user_font *font)
14891 alloc.
alloc = nk_malloc;
14892 alloc.
free = nk_mfree;
14893 return nk_init(ctx, &alloc, font);
14897 nk_init_fixed(
struct nk_context *ctx,
void *memory, nk_size size,
14901 if (!memory)
return 0;
14902 nk_setup(ctx, font);
14913 if (!cmds || !pool)
return 0;
14915 nk_setup(ctx, font);
14923 nk_pool_init(&ctx->
pool, alloc, NK_POOL_DEFAULT_CAPACITY);
14933 if (!alloc)
return 0;
14934 nk_setup(ctx, font);
14936 nk_pool_init(&ctx->
pool, alloc, NK_POOL_DEFAULT_CAPACITY);
14940 #ifdef NK_INCLUDE_COMMAND_USERDATA 14942 nk_set_user_data(
struct nk_context *ctx, nk_handle handle)
14951 nk_free(
struct nk_context *ctx)
14957 nk_pool_free(&ctx->
pool);
14996 iter->
seq == ctx->
seq) {
15013 nk_free_window(ctx, iter->
popup.
win);
15020 if (it->
seq != ctx->
seq) {
15021 nk_remove_table(iter, it);
15023 nk_free_table(ctx, it);
15031 nk_remove_window(ctx, iter);
15032 nk_free_window(ctx, iter);
15034 }
else iter = iter->
next;
15043 if (!ctx || !buffer)
return;
15047 buffer->
clip = nk_null_rect;
15050 nk_start(
struct nk_context *ctx,
struct nk_window *win)
15054 nk_start_buffer(ctx, &win->
buffer);
15057 nk_start_popup(
struct nk_context *ctx,
struct nk_window *win)
15062 if (!ctx || !win)
return;
15073 nk_finish_popup(
struct nk_context *ctx,
struct nk_window *win)
15078 if (!ctx || !win)
return;
15089 if (!ctx || !buffer)
return;
15093 nk_finish(
struct nk_context *ctx,
struct nk_window *win)
15101 if (!ctx || !win)
return;
15102 nk_finish_buffer(ctx, &win->
buffer);
15108 parent_last->
next = buf->
end;
15111 nk_build(
struct nk_context *ctx)
15115 nk_byte *buffer = 0;
15124 nk_start_buffer(ctx, &ctx->
overlay);
15128 mouse_bounds.w = cursor->size.x;
15129 mouse_bounds.h = cursor->size.y;
15132 nk_finish_buffer(ctx, &ctx->
overlay);
15178 if (!ctx)
return 0;
15179 if (!ctx->
count)
return 0;
15190 if (!iter)
return 0;
15200 if (!ctx || !cmd || !ctx->
count)
return 0;
15219 unsigned int capacity)
15221 nk_zero(pool,
sizeof(*pool));
15222 pool->
alloc = *alloc;
15228 nk_pool_free(
struct nk_pool *pool)
15240 nk_pool_init_fixed(
struct nk_pool *pool,
void *memory, nk_size size)
15242 nk_zero(pool,
sizeof(*pool));
15243 NK_ASSERT(size >=
sizeof(
struct nk_page));
15244 if (size <
sizeof(
struct nk_page))
return;
15251 nk_pool_alloc(
struct nk_pool *pool)
15257 NK_ASSERT(pool->
pages);
15258 if (!pool->
pages)
return 0;
15262 nk_size size =
sizeof(
struct nk_page);
15263 size += NK_POOL_DEFAULT_CAPACITY *
sizeof(
union nk_page_data);
15265 page->next = pool->
pages;
15266 pool->
pages = page;
15282 nk_create_page_element(
struct nk_context *ctx)
15291 elem = nk_pool_alloc(&ctx->
pool);
15293 if (!elem)
return 0;
15300 if (!elem)
return 0;
15308 nk_link_page_element_into_freelist(
struct nk_context *ctx,
15320 nk_free_page_element(
struct nk_context *ctx,
struct nk_page_element *elem)
15324 nk_link_page_element_into_freelist(ctx, elem);
15328 {
void *elem_end = (
void*)(elem + 1);
15330 if (elem_end == buffer_end)
15332 else nk_link_page_element_into_freelist(ctx, elem);}
15345 nk_create_table(
struct nk_context *ctx)
15348 elem = nk_create_page_element(ctx);
15349 if (!elem)
return 0;
15354 nk_free_table(
struct nk_context *ctx,
struct nk_table *tbl)
15358 nk_free_page_element(ctx, pe);
15391 nk_add_value(
struct nk_context *ctx,
struct nk_window *win,
15392 nk_hash
name, nk_uint value)
15396 if (!win || !ctx)
return 0;
15398 struct nk_table *tbl = nk_create_table(ctx);
15400 if (!tbl)
return 0;
15401 nk_push_table(win, tbl);
15409 nk_find_value(
struct nk_window *win, nk_hash name)
15413 unsigned int i = 0;
15414 unsigned int size = iter->
size;
15415 for (i = 0; i <
size; ++
i) {
15416 if (iter->
keys[i] == name) {
15436 nk_create_panel(
struct nk_context *ctx)
15439 elem = nk_create_page_element(ctx);
15440 if (!elem)
return 0;
15445 nk_free_panel(
struct nk_context *ctx,
struct nk_panel *pan)
15449 nk_free_page_element(ctx, pe);
15452 nk_panel_has_header(nk_flags flags,
const char *title)
15474 nk_panel_get_border(
const struct nk_style *style, nk_flags flags,
15499 case NK_PANEL_MENU:
return style->window.menu_border_color;
15513 nk_panel_begin(
struct nk_context *ctx,
const char *title,
enum nk_panel_type panel_type)
15522 struct nk_vec2 scrollbar_size;
15523 struct nk_vec2 panel_padding;
15536 style = &ctx->
style;
15537 font = style->
font;
15542 #ifdef NK_INCLUDE_COMMAND_USERDATA
15547 panel_padding = nk_panel_get_padding(style, panel_type);
15551 int left_mouse_down;
15552 int left_mouse_clicked;
15553 int left_mouse_click_in_cursor;
15560 if (nk_panel_has_header(win->
flags, title)) {
15563 }
else header.h = panel_padding.y;
15570 if (left_mouse_down && left_mouse_click_in_cursor && !left_mouse_clicked) {
15580 layout->
type = panel_type;
15583 layout->
bounds.
x += panel_padding.x;
15584 layout->
bounds.
w -= 2*panel_padding.x;
15585 if (win->
flags & NK_WINDOW_BORDER) {
15586 layout->
border = nk_panel_get_border(style, win->
flags, panel_type);
15588 }
else layout->
border = 0;
15603 layout->
bounds.
w -= scrollbar_size.x;
15604 if (!nk_panel_is_nonblock(panel_type)) {
15612 if (nk_panel_has_header(win->
flags, title))
15632 if (ctx->
active == win) {
15646 text.background =
nk_rgba(0,0,0,0);
15649 text.background = background->
data.
color;
15657 button.w = button.h;
15668 if (nk_do_button_symbol(&ws, &win->
buffer, button,
15711 nk_widget_text(out, label,(
const char*)title, text_len, &text,
NK_TEXT_LEFT, font);}
15732 layout->
clip = clip;}
15736 nk_panel_end(
struct nk_context *ctx)
15744 struct nk_vec2 scrollbar_size;
15745 struct nk_vec2 panel_padding;
15754 layout = window->
layout;
15755 style = &ctx->
style;
15758 if (!nk_panel_is_sub(layout->
type))
15763 panel_padding = nk_panel_get_padding(style, layout->
type);
15777 empty_space.x = window->
bounds.
x;
15778 empty_space.y = layout->
bounds.
y;
15779 empty_space.h = panel_padding.y;
15780 empty_space.w = window->
bounds.
w;
15784 empty_space.x = window->
bounds.
x;
15785 empty_space.y = layout->
bounds.
y;
15786 empty_space.w = panel_padding.x + layout->
border;
15787 empty_space.h = layout->
bounds.
h;
15792 empty_space.y = layout->
bounds.
y;
15793 empty_space.w = panel_padding.x + layout->
border;
15794 empty_space.h = layout->
bounds.
h;
15796 empty_space.w += scrollbar_size.x;
15801 empty_space.x = window->
bounds.
x;
15803 empty_space.w = window->
bounds.
w;
15804 empty_space.h = scrollbar_size.y;
15815 int scroll_has_scrolling;
15816 float scroll_target;
15817 float scroll_offset;
15822 if (nk_panel_is_sub(layout->
type))
15827 while (root_panel->
parent)
15828 root_panel = root_panel->
parent;
15829 while (root_window->
parent)
15830 root_window = root_window->
parent;
15833 scroll_has_scrolling = 0;
15841 root_panel = window->
layout;
15842 while (root_panel->
parent) {
15844 root_panel = root_panel->
parent;
15847 scroll_has_scrolling =
nk_true;
15850 }
else if (!nk_panel_is_sub(layout->
type)) {
15856 }
else scroll_has_scrolling =
nk_false;
15860 nk_flags
state = 0;
15861 scroll.x = layout->
bounds.
x + layout->
bounds.
w + panel_padding.x;
15863 scroll.w = scrollbar_size.x;
15866 scroll_offset = (float)*layout->
offset_y;
15867 scroll_step = scroll.h * 0.10f;
15868 scroll_inc = scroll.h * 0.01f;
15869 scroll_target = (
float)(int)(layout->
at_y - scroll.y);
15870 scroll_offset = nk_do_scrollbarv(&state, out, scroll, scroll_has_scrolling,
15871 scroll_offset, scroll_target, scroll_step, scroll_inc,
15874 if (in && scroll_has_scrolling)
15879 nk_flags state = 0;
15883 scroll.h = scrollbar_size.y;
15885 scroll_offset = (float)*layout->
offset_x;
15886 scroll_target = (
float)(int)(layout->
max_x - scroll.x);
15887 scroll_step = layout->
max_x * 0.05f;
15888 scroll_inc = layout->
max_x * 0.005f;
15889 scroll_offset = nk_do_scrollbarh(&state, out, scroll, scroll_has_scrolling,
15890 scroll_offset, scroll_target, scroll_step, scroll_inc,
15901 if ((!has_input && is_window_hovered) || (!is_window_hovered && !any_item_active))
15907 if (layout->
flags & NK_WINDOW_BORDER)
15909 struct nk_color border_color = nk_panel_get_border_color(style, layout->
type);
15916 b.
h = padding_y - window->
bounds.
y;
15925 scaler.
w = scrollbar_size.x;
15926 scaler.h = scrollbar_size.y;
15929 scaler.x = layout->
bounds.
x - panel_padding.x * 0.5f;
15930 else scaler.x = layout->
bounds.
x + layout->
bounds.
w + panel_padding.x;
15932 scaler.x -= scaler.w;
15941 scaler.y + scaler.h, scaler.x + scaler.w,
15942 scaler.y + scaler.h, item->
data.
color);
15945 scaler.y + scaler.h, scaler.x, scaler.y + scaler.h, item->
data.
color);
15956 if (left_mouse_down && left_mouse_click_in_scaler) {
15959 delta_x = -delta_x;
15963 if (window->
bounds.
w + delta_x >= window_size.
x) {
15964 if ((delta_x < 0) || (delta_x > 0 && in->
mouse.
pos.
x >= scaler.x)) {
15984 if (!nk_panel_is_sub(layout->
type)) {
15987 nk_command_buffer_reset(&window->
buffer);
15989 else nk_finish(ctx, window);
16011 nk_zero(&window->
edit,
sizeof(window->
edit));
16041 nk_create_window(
struct nk_context *ctx)
16044 elem = nk_create_page_element(ctx);
16045 if (!elem)
return 0;
16050 nk_free_window(
struct nk_context *ctx,
struct nk_window *win)
16055 nk_free_window(ctx, win->
popup.
win);
16064 nk_remove_table(win, it);
16065 nk_free_table(ctx, it);
16074 nk_free_page_element(ctx, pe);}
16077 nk_find_window(
struct nk_context *ctx, nk_hash hash,
const char *name)
16082 NK_ASSERT(iter != iter->
next);
16083 if (iter->
name == hash) {
16093 nk_insert_window(
struct nk_context *ctx,
struct nk_window *win,
16094 enum nk_window_insert_location loc)
16099 if (!win || !ctx)
return;
16103 NK_ASSERT(iter != iter->
next);
16104 NK_ASSERT(iter != win);
16105 if (iter == win)
return;
16117 if (loc == NK_INSERT_BACK) {
16138 nk_remove_window(
struct nk_context *ctx,
struct nk_window *win)
16140 if (win == ctx->
begin || win == ctx->
end) {
16141 if (win == ctx->
begin) {
16146 if (win == ctx->
end) {
16167 nk_begin(
struct nk_context *ctx,
const char *title,
16173 nk_begin_titled(
struct nk_context *ctx,
const char *name,
const char *title,
16178 nk_hash title_hash;
16186 NK_ASSERT(!ctx->
current &&
"if this triggers you missed a `nk_end` call");
16187 if (!ctx || ctx->
current || !title || !name)
16191 style = &ctx->
style;
16194 win = nk_find_window(ctx, title_hash, name);
16198 win = (
struct nk_window*)nk_create_window(ctx);
16200 if (!win)
return 0;
16203 nk_insert_window(ctx, win, NK_INSERT_FRONT);
16204 else nk_insert_window(ctx, win, NK_INSERT_BACK);
16209 win->
name = title_hash;
16229 NK_ASSERT(win->
seq != ctx->
seq);
16240 }
else nk_start(ctx, win);
16245 int inpanel, ishovered;
16262 iter_bounds.
x, iter_bounds.
y, iter_bounds.
w, iter_bounds.
h) &&
16276 if (iter && inpanel && (win != ctx->
end)) {
16283 iter_bounds.
x, iter_bounds.
y, iter_bounds.
w, iter_bounds.
h) &&
16298 if (!(iter->
flags & NK_WINDOW_BACKGROUND)) {
16301 nk_remove_window(ctx, iter);
16302 nk_insert_window(ctx, iter, NK_INSERT_BACK);
16305 if (!iter && ctx->
end != win) {
16306 if (!(win->
flags & NK_WINDOW_BACKGROUND)) {
16309 nk_remove_window(ctx, win);
16310 nk_insert_window(ctx, win, NK_INSERT_BACK);
16315 if (ctx->
end != win && !(win->
flags & NK_WINDOW_BACKGROUND))
16327 nk_end(
struct nk_context *ctx)
16331 NK_ASSERT(ctx->
current &&
"if this triggers you forgot to call `nk_begin`");
16373 if (!ctx || !ctx->
current)
return 0;
16381 if (!ctx || !ctx->
current)
return 0;
16426 if (!ctx || !ctx->
current)
return 0;
16434 if (!ctx || !ctx->
current)
return 0;
16443 if (!ctx || !ctx->
current)
return 0;
16451 if (!ctx || !ctx->
current)
return 0;
16461 if (!ctx)
return 0;
16488 return any_hovered || any_active;
16494 nk_hash title_hash;
16497 if (!ctx)
return 0;
16501 win = nk_find_window(ctx, title_hash, name);
16502 if (!win)
return 0;
16509 nk_hash title_hash;
16512 if (!ctx)
return 1;
16516 win = nk_find_window(ctx, title_hash, name);
16517 if (!win)
return 1;
16524 nk_hash title_hash;
16527 if (!ctx)
return 1;
16531 win = nk_find_window(ctx, title_hash, name);
16532 if (!win)
return 1;
16539 nk_hash title_hash;
16542 if (!ctx)
return 0;
16546 win = nk_find_window(ctx, title_hash, name);
16547 if (!win)
return 0;
16548 return win == ctx->
active;
16554 nk_hash title_hash;
16557 return nk_find_window(ctx, title_hash, name);
16567 NK_ASSERT(ctx->
current != win &&
"You cannot close a currently active window");
16568 if (ctx->
current == win)
return;
16574 const char *name,
struct nk_rect bounds)
16581 NK_ASSERT(ctx->
current != win &&
"You cannot update a currently in procecss window");
16586 const char *name,
struct nk_vec2 pos)
16595 const char *name,
struct nk_vec2 size)
16607 nk_hash title_hash;
16614 win = nk_find_window(ctx, title_hash, name);
16625 if (!ctx || !cond)
return;
16632 nk_hash title_hash;
16639 win = nk_find_window(ctx, title_hash, name);
16650 if (!ctx || !cond)
return;
16658 nk_hash title_hash;
16665 win = nk_find_window(ctx, title_hash, name);
16666 if (win && ctx->
end != win) {
16667 nk_remove_window(ctx, win);
16668 nk_insert_window(ctx, win, NK_INSERT_BACK);
16684 const char *title, nk_flags flags,
struct nk_rect rect)
16691 nk_hash title_hash;
16710 popup = (
struct nk_window*)nk_create_window(ctx);
16720 nk_zero(popup,
sizeof(*popup));
16739 if (type == NK_POPUP_DYNAMIC)
16743 nk_start_popup(ctx, win);
16773 nk_free_panel(ctx, popup->
layout);
16779 nk_nonblock_begin(
struct nk_context *ctx,
16802 popup = (
struct nk_window*)nk_create_window(ctx);
16809 int pressed, in_body, in_header;
16813 if (pressed && (!in_body || in_header))
16835 NK_ASSERT(popup->
layout);
16837 nk_start_popup(ctx, win);
16842 nk_panel_begin(ctx, 0, panel_type);
16862 if (!ctx || !ctx->
current)
return;
16865 NK_ASSERT(popup->
parent);
16882 if (!popup->
parent)
return;
16897 nk_finish_popup(ctx, win);
16913 struct nk_rect trigger_bounds)
16920 int is_clicked = 0;
16943 if ((!is_open && !is_clicked))
16972 nk_flags alignment)
16988 style = &ctx->
style;
17007 const char *text,
int len, nk_flags align)
17023 style = &ctx->
style;
17037 const char *label, nk_flags align)
17043 const char *text,
int len, nk_flags align)
17059 style = &ctx->
style;
17073 const char *text, nk_flags align)
17093 if (!ctx || !ctx->
current)
return;
17097 NK_ASSERT(popup->
parent);
17105 struct nk_rect body = {0,0,0,0};
17114 if (pressed && in_body)
17202 nk_menu_begin(
struct nk_context *ctx,
struct nk_window *win,
17203 const char *
id,
int is_clicked,
struct nk_rect header,
struct nk_vec2 size)
17219 body.
y = header.
y + header.
h;
17223 is_open = popup ? nk_true :
nk_false;
17225 if ((is_clicked && is_open && !is_active) || (is_open && !is_active) ||
17226 (!is_open && !is_active && !is_clicked))
return 0;
17236 nk_flags align,
struct nk_vec2 size)
17252 if (!state)
return 0;
17256 is_clicked = nk_true;
17257 return nk_menu_begin(ctx, win, title, is_clicked, header, size);
17260 const char *text, nk_flags align,
struct nk_vec2 size)
17282 if (!state)
return 0;
17286 is_clicked = nk_true;
17287 return nk_menu_begin(ctx, win,
id, is_clicked, header, size);
17307 if (!state)
return 0;
17311 is_clicked = nk_true;
17312 return nk_menu_begin(ctx, win,
id, is_clicked, header, size);
17332 if (!state)
return 0;
17337 is_clicked = nk_true;
17338 return nk_menu_begin(ctx, win, title, is_clicked, header, size);
17342 const char *title, nk_flags align,
struct nk_image img,
struct nk_vec2 size)
17364 if (!state)
return 0;
17369 ctx->
style.
font, in)) is_clicked = nk_true;
17370 return nk_menu_begin(ctx, win, title, is_clicked, header, size);
17379 nk_menu_item_text(
struct nk_context *ctx,
const char *title,
int len, nk_flags align)
17390 const char *label, nk_flags align)
17396 const char *text,
int len, nk_flags align)
17401 const char *text,
int len, nk_flags align)
17406 const char *label, nk_flags align)
17465 float total_space,
int columns)
17467 float panel_padding;
17468 float panel_spacing;
17475 padding = nk_panel_get_padding(style, type);
17478 panel_padding = 2 * padding.x;
17479 panel_spacing = (float)
NK_MAX(columns - 1, 0) * spacing.x;
17480 panel_space = total_space - panel_padding - panel_spacing;
17481 return panel_space;
17484 nk_panel_layout(
const struct nk_context *ctx,
struct nk_window *win,
17485 float height,
int cols)
17492 struct nk_color color;
17502 style = &ctx->
style;
17520 if (height == 0.0f)
17522 else layout->
row.
height = height + item_spacing.y;
17528 background.x = win->
bounds.
x;
17529 background.w = win->
bounds.
w;
17530 background.y = layout->
at_y - 1.0f;
17531 background.h = layout->
row.
height + 1.0f;
17537 float height,
int cols,
int width)
17548 nk_panel_layout(ctx, win, height, cols);
17563 NK_ASSERT(pixel_width);
17580 float row_height,
int cols)
17593 nk_panel_layout(ctx, win, row_height, cols);
17623 float ratio = ratio_or_width;
17624 if ((ratio + layout->
row.
filled) > 1.0f)
return;
17652 float height,
int cols,
const float *ratio)
17667 nk_panel_layout(ctx, win, height, cols);
17672 for (i = 0; i < cols; ++
i) {
17673 if (ratio[i] < 0.0f)
17675 else r += ratio[
i];
17679 layout->
row.
item_width = (r > 0 && n_undef > 0) ? (r / (
float)n_undef):0;
17703 nk_panel_layout(ctx, win, height, 1);
17783 int variable_count = 0;
17784 int min_variable_count = 0;
17785 float min_fixed_width = 0.0f;
17786 float total_fixed_width = 0.0f;
17787 float max_variable_width = 0.0f;
17801 if (width >= 0.0f) {
17802 total_fixed_width +=
width;
17803 min_fixed_width +=
width;
17804 }
else if (width < -1.0f) {
17806 total_fixed_width +=
width;
17807 max_variable_width =
NK_MAX(max_variable_width, width);
17810 min_variable_count++;
17814 if (variable_count) {
17815 float space = nk_layout_row_calculate_usable_space(&ctx->
style, layout->
type,
17817 float var_width = (
NK_MAX(space-min_fixed_width,0.0f)) / (
float)variable_count;
17818 int enough_space = var_width >= max_variable_width;
17820 var_width = (
NK_MAX(space-total_fixed_width,0)) / (
float)min_variable_count;
17823 *width = (*width >= 0.0f)? *width: (*width < -1.0f && !enough_space)? -(*width): var_width;
17829 float height,
int widget_count)
17842 nk_panel_layout(ctx, win, height, widget_count);
17843 if (fmt == NK_STATIC)
17900 ret.x = layout->
clip.
x;
17901 ret.y = layout->
clip.
y;
17902 ret.w = layout->
clip.
w;
17919 ret.x = layout->
at_x;
17920 ret.y = layout->
at_y;
17932 NK_ASSERT(ctx->current);
17933 NK_ASSERT(ctx->current->layout);
17934 win = ctx->current;
17948 NK_ASSERT(ctx->current);
17949 NK_ASSERT(ctx->current->layout);
17950 win = ctx->current;
17964 NK_ASSERT(ctx->current);
17965 NK_ASSERT(ctx->current->layout);
17966 win = ctx->current;
17980 NK_ASSERT(ctx->current);
17981 NK_ASSERT(ctx->current->layout);
17982 win = ctx->current;
17990 nk_panel_alloc_row(
const struct nk_context *ctx,
struct nk_window *win)
17994 const float row_height = layout->
row.
height - spacing.
y;
17995 nk_panel_layout(ctx, win, row_height, layout->
row.
columns);
17998 nk_layout_widget_space(
struct nk_rect *bounds,
const struct nk_context *ctx,
18007 float item_offset = 0;
18008 float item_width = 0;
18009 float item_spacing = 0;
18010 float panel_space = 0;
18020 style = &ctx->
style;
18024 padding = nk_panel_get_padding(style, layout->
type);
18025 panel_space = nk_layout_row_calculate_usable_space(&ctx->
style, layout->
type,
18033 item_offset = (
float)layout->
row.
index * item_width;
18034 item_spacing = (float)layout->
row.
index * spacing.x;
18065 item_spacing = (
float)layout->
row.
index * spacing.x;
18066 item_width = (ratio * panel_space);
18077 item_offset = (float)layout->
row.
index * item_width;
18078 item_spacing = (
float)layout->
row.
index * spacing.x;
18084 item_spacing = (float)layout->
row.
index * spacing.x;
18091 if (((bounds->
x + bounds->
w) > layout->
max_x) && modify)
18092 layout->
max_x = (bounds->
x + bounds->
w);
18101 item_spacing = (float)layout->
row.
index * spacing.x;
18112 item_spacing = (float)layout->
row.
index * spacing.x;
18115 default: NK_ASSERT(0);
break;
18119 bounds->
w = item_width;
18122 bounds->
x = layout->
at_x + item_offset + item_spacing + padding.x;
18123 if (((bounds->
x + bounds->
w) > layout->
max_x) && modify)
18124 layout->
max_x = bounds->
x + bounds->
w;
18128 nk_panel_alloc_space(
struct nk_rect *bounds,
const struct nk_context *ctx)
18143 nk_panel_alloc_row(ctx, win);
18146 nk_layout_widget_space(bounds, ctx, win, nk_true);
18150 nk_layout_peek(
struct nk_rect *bounds,
struct nk_context *ctx)
18171 nk_layout_widget_space(bounds, ctx, win,
nk_false);
18189 nk_tree_state_base(
struct nk_context *ctx,
enum nk_tree_type type,
18202 struct nk_rect header = {0,0,0,0};
18203 struct nk_rect sym = {0,0,0,0};
18219 style = &ctx->
style;
18228 widget_state =
nk_widget(&header, ctx);
18229 if (type == NK_TREE_TAB) {
18233 text.background =
nk_rgba(0,0,0,0);
18235 text.background = background->
data.
color;
18251 if (type == NK_TREE_TAB)
18256 if (type == NK_TREE_TAB)
18266 button, 0, style->
font);
18270 sym.
x = sym.
x + sym.
w + 4 * item_spacing.x;
18277 header.
w =
NK_MAX(header.
w, sym.
w + item_spacing.x);
18278 label.x = sym.
x + sym.
w + item_spacing.x;
18280 label.w = header.
w - (sym.
w + item_spacing.y + style->
tab.
indent);
18284 nk_widget_text(out, label, title,
nk_strlen(title), &text,
18297 nk_tree_base(
struct nk_context *ctx,
enum nk_tree_type type,
18299 const char *hash,
int len,
int line)
18303 nk_hash tree_hash = 0;
18304 nk_uint *state = 0;
18309 tree_hash =
nk_murmur_hash(title, (
int)title_len, (nk_hash)line);
18311 state = nk_find_value(win, tree_hash);
18313 state = nk_add_value(ctx, win, tree_hash, 0);
18314 *state = initial_state;
18322 return nk_tree_state_base(ctx, type, 0, title, state);
18328 return nk_tree_state_base(ctx, type, &img, title, state);
18352 const char *hash,
int len,
int line)
18354 return nk_tree_base(ctx, type, 0, title, initial_state, hash, len, line);
18359 const char *hash,
int len,
int seed)
18361 return nk_tree_base(ctx, type, &img, title, initial_state, hash, len, seed);
18369 nk_tree_element_image_push_hashed_base(
struct nk_context *ctx,
enum nk_tree_type type,
18370 struct nk_image *img,
const char *title,
int title_len,
18387 struct nk_rect header = {0,0,0,0};
18388 struct nk_rect sym = {0,0,0,0};
18404 style = &ctx->
style;
18414 widget_state =
nk_widget(&header, ctx);
18415 if (type == NK_TREE_TAB) {
18419 text.background =
nk_rgba(0,0,0,0);
18421 text.background = background->
data.
color;
18434 if (type == NK_TREE_TAB)
18439 if (type == NK_TREE_TAB)
18451 {nk_flags dummy = 0;
18456 text_width += (4 * padding.x);
18458 header.
w =
NK_MAX(header.
w, sym.
w + item_spacing.x);
18459 label.x = sym.
x + sym.
w + item_spacing.x;
18461 label.w =
NK_MIN(header.
w - (sym.
w + item_spacing.y + style->
tab.
indent), text_width);
18467 }
else nk_do_selectable(&dummy, &win->
buffer, label, title, title_len,
NK_TEXT_LEFT,
18480 nk_tree_element_base(
struct nk_context *ctx,
enum nk_tree_type type,
18482 int *selected,
const char *hash,
int len,
int line)
18486 nk_hash tree_hash = 0;
18487 nk_uint *state = 0;
18492 tree_hash =
nk_murmur_hash(title, (
int)title_len, (nk_hash)line);
18494 state = nk_find_value(win, tree_hash);
18496 state = nk_add_value(ctx, win, tree_hash, 0);
18497 *state = initial_state;
18498 }
return nk_tree_element_image_push_hashed_base(ctx, type, img, title,
18504 int *selected,
const char *hash,
int len,
int seed)
18506 return nk_tree_element_base(ctx, type, 0, title, initial_state, selected, hash, len, seed);
18511 int *selected,
const char *hash,
int len,
int seed)
18513 return nk_tree_element_base(ctx, type, &img, title, initial_state, selected, hash, len, seed);
18532 nk_uint *x_offset, nk_uint *y_offset,
const char *title, nk_flags flags)
18539 nk_panel_alloc_space(&bounds, ctx);
18549 nk_zero(&panel,
sizeof(panel));
18552 panel.scrollbar.x = *x_offset;
18553 panel.scrollbar.y = *y_offset;
18555 panel.layout = (
struct nk_panel*)nk_create_panel(ctx);
18561 panel.layout->
offset_x = x_offset;
18562 panel.layout->
offset_y = y_offset;
18564 win->
layout = panel.layout;
18570 nk_flags f = panel.layout->
flags;
18588 struct nk_vec2 panel_padding;
18607 pan.bounds.x = g->
bounds.
x - panel_padding.x;
18608 pan.bounds.w = g->
bounds.
w + 2 * panel_padding.x;
18610 if (g->
flags & NK_WINDOW_BORDER) {
18611 pan.bounds.x -= g->
border;
18612 pan.bounds.y -= g->
border;
18613 pan.bounds.w += 2*g->
border;
18614 pan.bounds.h += 2*g->
border;
18622 pan.flags = g->
flags;
18623 pan.buffer = win->
buffer;
18629 nk_unify(&clip, &parent->
clip, pan.bounds.
x, pan.bounds.y,
18630 pan.bounds.x + pan.bounds.w, pan.bounds.y + pan.bounds.h + panel_padding.x);
18634 win->
buffer = pan.buffer;
18643 struct nk_scroll *scroll,
const char *title, nk_flags flags)
18649 const char *title, nk_flags flags)
18668 x_offset = nk_find_value(win, id_hash);
18670 x_offset = nk_add_value(ctx, win, id_hash, 0);
18671 y_offset = nk_add_value(ctx, win, id_hash+1, 0);
18673 NK_ASSERT(x_offset);
18674 NK_ASSERT(y_offset);
18675 if (!x_offset || !y_offset)
return 0;
18676 *x_offset = *y_offset = 0;
18677 }
else y_offset = nk_find_value(win, id_hash+1);
18681 nk_group_begin(
struct nk_context *ctx,
const char *title, nk_flags flags)
18702 const char *title, nk_flags flags,
int row_height,
int row_count)
18705 nk_hash title_hash;
18718 if (!ctx || !view || !title)
return 0;
18721 style = &ctx->
style;
18723 row_height +=
NK_MAX(0, (
int)item_spacing.y);
18728 x_offset = nk_find_value(win, title_hash);
18730 x_offset = nk_add_value(ctx, win, title_hash, 0);
18731 y_offset = nk_add_value(ctx, win, title_hash+1, 0);
18733 NK_ASSERT(x_offset);
18734 NK_ASSERT(y_offset);
18735 if (!x_offset || !y_offset)
return 0;
18736 *x_offset = *y_offset = 0;
18737 }
else y_offset = nk_find_value(win, title_hash+1);
18748 view->
count = (int)
NK_MAX(nk_iceilf((layout->
clip.
h)/(float)row_height),0);
18757 struct nk_context *
ctx;
18762 NK_ASSERT(view->
ctx);
18764 if (!view || !view->
ctx)
return;
18791 nk_layout_peek(&bounds, ctx);
18803 nk_layout_peek(&bounds, ctx);
18815 nk_layout_peek(&bounds, ctx);
18827 nk_layout_peek(&bounds, ctx);
18839 nk_layout_peek(&bounds, ctx);
18853 c.
x = (float)((
int)c.
x);
18854 c.
y = (float)((
int)c.
y);
18855 c.
w = (float)((
int)c.
w);
18856 c.
h = (float)((
int)c.
h);
18858 nk_layout_peek(&bounds, ctx);
18859 nk_unify(&v, &c, bounds.
x, bounds.
y, bounds.
x + bounds.
w, bounds.
y + bounds.
h);
18875 c.
x = (float)((
int)c.
x);
18876 c.
y = (float)((
int)c.
y);
18877 c.
w = (float)((
int)c.
w);
18878 c.
h = (float)((
int)c.
h);
18880 nk_layout_peek(&bounds, ctx);
18881 nk_unify(&v, &c, bounds.
x, bounds.
y, bounds.
x + bounds.
w, bounds.
y + bounds.
h);
18897 c.
x = (float)((
int)c.
x);
18898 c.
y = (float)((
int)c.
y);
18899 c.
w = (float)((
int)c.
w);
18900 c.
h = (float)((
int)c.
h);
18902 nk_layout_peek(&bounds, ctx);
18903 nk_unify(&v, &c, bounds.
x, bounds.
y, bounds.
x + bounds.
w, bounds.
y + bounds.
h);
18923 nk_panel_alloc_space(bounds, ctx);
18939 bounds->
x = (float)((
int)bounds->
x);
18940 bounds->
y = (float)((
int)bounds->
y);
18941 bounds->
w = (float)((
int)bounds->
w);
18942 bounds->
h = (float)((
int)bounds->
h);
18944 c.
x = (float)((
int)c.
x);
18945 c.
y = (float)((
int)c.
y);
18946 c.
w = (float)((
int)c.
w);
18947 c.
h = (float)((
int)c.
h);
18949 nk_unify(&v, &c, bounds->
x, bounds->
y, bounds->
x + bounds->
w, bounds->
y + bounds->
h);
18965 struct nk_vec2 panel_padding;
18974 style = &ctx->
style;
18978 panel_padding = nk_panel_get_padding(style, layout->
type);
18980 bounds->
w += panel_padding.x;
18981 bounds->
x -= panel_padding.x;
18982 }
else bounds->
x -= item_padding.
x;
18985 bounds->
w += panel_padding.x;
18986 else bounds->
w += item_padding.
x;
18990 nk_spacing(
struct nk_context *ctx,
int cols)
19009 for (i = 0; i < rows; ++
i)
19010 nk_panel_alloc_row(ctx, win);
19016 for (i = 0; i < cols; ++
i)
19017 nk_panel_alloc_space(&none, ctx);
19032 const char *
string,
int len,
const struct nk_text *t,
19040 if (!o || !t)
return;
19042 b.
h =
NK_MAX(b.
h, 2 * t->padding.y);
19043 label.x = 0; label.w = 0;
19044 label.y = b.
y + t->padding.y;
19048 text_width += (2.0f * t->padding.x);
19052 label.x = b.
x + t->padding.x;
19053 label.w =
NK_MAX(0, b.
w - 2 * t->padding.x);
19055 label.w =
NK_MAX(1, 2 * t->padding.x + (
float)text_width);
19056 label.x = (b.
x + t->padding.x + ((b.
w - 2 * t->padding.x) - label.w) / 2);
19057 label.x =
NK_MAX(b.
x + t->padding.x, label.x);
19058 label.w =
NK_MIN(b.
x + b.
w, label.x + label.w);
19059 if (label.w >= label.x) label.w -= label.x;
19061 label.x =
NK_MAX(b.
x + t->padding.x, (b.
x + b.
w) - (2 * t->padding.x + (
float)text_width));
19062 label.w = (float)text_width + 2 * t->padding.x;
19067 label.y = b.
y + b.
h/2.0f - (float)f->
height/2.0f;
19073 nk_draw_text(o, label, (
const char*)
string, len, f, t->background, t->text);
19077 const char *
string,
int len,
const struct nk_text *t,
19090 if (!o || !t)
return;
19093 text.background = t->background;
19094 text.text = t->text;
19096 b.
w =
NK_MAX(b.
w, 2 * t->padding.x);
19097 b.
h =
NK_MAX(b.
h, 2 * t->padding.y);
19098 b.
h = b.
h - 2 * t->padding.y;
19100 line.x = b.
x + t->padding.x;
19101 line.y = b.
y + t->padding.y;
19102 line.w = b.
w - 2 * t->padding.x;
19103 line.h = 2 * t->padding.y + f->
height;
19105 fitting = nk_text_clamp(f,
string, len, line.w, &glyphs, &width, seperator,
NK_LEN(seperator));
19106 while (done < len) {
19107 if (!fitting || line.y + line.h >= (b.
y + b.
h))
break;
19108 nk_widget_text(o, line, &
string[done], fitting, &text,
NK_TEXT_LEFT, f);
19110 line.y += f->
height + 2 * t->padding.y;
19111 fitting = nk_text_clamp(f, &
string[done], len - done, line.w, &glyphs, &width, seperator,
NK_LEN(seperator));
19116 nk_flags alignment,
struct nk_color color)
19131 style = &ctx->
style;
19132 nk_panel_alloc_space(&bounds, ctx);
19135 text.padding.
x = item_padding.
x;
19136 text.padding.y = item_padding.
y;
19139 nk_widget_text(&win->
buffer, bounds, str, len, &text, alignment, style->
font);
19143 int len,
struct nk_color color)
19158 style = &ctx->
style;
19159 nk_panel_alloc_space(&bounds, ctx);
19162 text.padding.
x = item_padding.
x;
19163 text.padding.y = item_padding.
y;
19166 nk_widget_text_wrap(&win->
buffer, bounds, str, len, &text, style->
font);
19168 #ifdef NK_INCLUDE_STANDARD_VARARGS 19170 nk_labelf_colored(
struct nk_context *ctx, nk_flags flags,
19171 struct nk_color color,
const char *fmt, ...)
19174 va_start(args, fmt);
19175 nk_labelfv_colored(ctx, flags, color, fmt, args);
19179 nk_labelf_colored_wrap(
struct nk_context *ctx,
struct nk_color color,
19180 const char *fmt, ...)
19183 va_start(args, fmt);
19184 nk_labelfv_colored_wrap(ctx, color, fmt, args);
19188 nk_labelf(
struct nk_context *ctx, nk_flags flags,
const char *fmt, ...)
19191 va_start(args, fmt);
19192 nk_labelfv(ctx, flags, fmt, args);
19196 nk_labelf_wrap(
struct nk_context *ctx,
const char *fmt,...)
19199 va_start(args, fmt);
19200 nk_labelfv_wrap(ctx, fmt, args);
19204 nk_labelfv_colored(
struct nk_context *ctx, nk_flags flags,
19205 struct nk_color color,
const char *fmt, va_list args)
19208 nk_strfmt(buf,
NK_LEN(buf), fmt, args);
19213 nk_labelfv_colored_wrap(
struct nk_context *ctx,
struct nk_color color,
19214 const char *fmt, va_list args)
19217 nk_strfmt(buf,
NK_LEN(buf), fmt, args);
19222 nk_labelfv(
struct nk_context *ctx, nk_flags flags,
const char *fmt, va_list args)
19225 nk_strfmt(buf,
NK_LEN(buf), fmt, args);
19230 nk_labelfv_wrap(
struct nk_context *ctx,
const char *fmt, va_list args)
19233 nk_strfmt(buf,
NK_LEN(buf), fmt, args);
19238 nk_value_bool(
struct nk_context *ctx,
const char *prefix,
int value)
19240 nk_labelf(ctx,
NK_TEXT_LEFT,
"%s: %s", prefix, ((value) ?
"true":
"false"));
19243 nk_value_int(
struct nk_context *ctx,
const char *prefix,
int value)
19245 nk_labelf(ctx,
NK_TEXT_LEFT,
"%s: %d", prefix, value);
19248 nk_value_uint(
struct nk_context *ctx,
const char *prefix,
unsigned int value)
19250 nk_labelf(ctx,
NK_TEXT_LEFT,
"%s: %u", prefix, value);
19253 nk_value_float(
struct nk_context *ctx,
const char *prefix,
float value)
19255 double double_value = (double)value;
19256 nk_labelf(ctx,
NK_TEXT_LEFT,
"%s: %.3f", prefix, double_value);
19259 nk_value_color_byte(
struct nk_context *ctx,
const char *p,
struct nk_color c)
19261 nk_labelf(ctx,
NK_TEXT_LEFT,
"%s: (%d, %d, %d, %d)", p, c.
r, c.
g, c.
b, c.
a);
19264 nk_value_color_float(
struct nk_context *ctx,
const char *p,
struct nk_color color)
19267 nk_labelf(ctx,
NK_TEXT_LEFT,
"%s: (%.2f, %.2f, %.2f, %.2f)",
19268 p, c[0], c[1], c[2], c[3]);
19271 nk_value_color_hex(
struct nk_context *ctx,
const char *prefix,
struct nk_color color)
19279 nk_text(
struct nk_context *ctx,
const char *str,
int len, nk_flags alignment)
19286 nk_text_wrap(
struct nk_context *ctx,
const char *str,
int len)
19293 nk_label(
struct nk_context *ctx,
const char *str, nk_flags alignment)
19299 struct nk_color color)
19326 nk_handle handle = {0};
19342 nk_zero(&s,
sizeof(s));
19343 s.handle.ptr = ptr;
19345 s.region[0] = (
unsigned short)r.x;
19346 s.region[1] = (
unsigned short)r.y;
19347 s.region[2] = (
unsigned short)r.w;
19348 s.region[3] = (
unsigned short)r.h;
19355 nk_zero(&s,
sizeof(s));
19358 s.region[0] = (
unsigned short)r.x;
19359 s.region[1] = (
unsigned short)r.y;
19360 s.region[2] = (
unsigned short)r.w;
19361 s.region[3] = (
unsigned short)r.h;
19369 nk_zero(&s,
sizeof(s));
19372 s.region[0] = (
unsigned short)r.x;
19373 s.region[1] = (
unsigned short)r.y;
19374 s.region[2] = (
unsigned short)r.w;
19375 s.region[3] = (
unsigned short)r.h;
19382 nk_zero(&s,
sizeof(s));
19395 nk_zero(&s,
sizeof(s));
19397 s.handle.ptr = ptr;
19409 nk_zero(&s,
sizeof(s));
19422 return !(img->
w == 0 && img->
h == 0);
19466 struct nk_rect content,
struct nk_color background,
struct nk_color foreground,
19480 text.background = background;
19481 text.text = foreground;
19492 nk_fill_rect(out, nk_shrink_rect(content, border_width), 0, background);
19510 points[2].x, points[2].y, foreground);
19522 nk_widget_state_reset(state);
19531 #ifdef NK_BUTTON_TRIGGER_ON_RELEASE 19546 const struct nk_rect *bounds, nk_flags state,
19551 background = &style->
hover;
19553 background = &style->
active;
19554 else background = &style->
normal;
19573 if (!out || !style)
19591 const struct nk_rect *bounds,
const struct nk_rect *content, nk_flags state,
19593 nk_flags text_alignment,
const struct nk_user_font *font)
19597 background = nk_draw_button(out, bounds, state, style);
19601 text.background = background->
data.
color;
19603 if (state & NK_WIDGET_STATE_HOVER)
19605 else if (state & NK_WIDGET_STATE_ACTIVED)
19610 nk_widget_text(out, *content, txt, len, &text, text_alignment, font);
19613 nk_do_button_text(nk_flags *state,
19627 if (!out || !style || !font || !
string)
19630 ret = nk_do_button(state, out, bounds, style, in, behavior, &content);
19632 nk_draw_button_text(out, &bounds, &content, *state, style,
string, len, align, font);
19642 struct nk_color sym, bg;
19646 background = nk_draw_button(out, bounds, state, style);
19651 if (state & NK_WIDGET_STATE_HOVER)
19653 else if (state & NK_WIDGET_STATE_ACTIVED)
19656 nk_draw_symbol(out, type, *content, bg, sym, 1, font);
19659 nk_do_button_symbol(nk_flags *state,
19672 if (!out || !style || !font || !state)
19675 ret = nk_do_button(state, out, bounds, style, in, behavior, &content);
19677 nk_draw_button_symbol(out, &bounds, &content, *state, style, symbol, font);
19686 nk_draw_button(out, bounds, state, style);
19690 nk_do_button_image(nk_flags *state,
19701 if (!out || !style || !state)
19704 ret = nk_do_button(state, out, bounds, style, in, b, &content);
19711 nk_draw_button_image(out, &bounds, &content, *state, style, &img);
19722 struct nk_color sym;
19727 background = nk_draw_button(out, bounds, state, style);
19729 text.background = background->
data.
color;
19733 if (state & NK_WIDGET_STATE_HOVER) {
19736 }
else if (state & NK_WIDGET_STATE_ACTIVED) {
19745 nk_draw_symbol(out, type, *symbol, style->
text_background, sym, 0, font);
19749 nk_do_button_text_symbol(nk_flags *state,
19751 enum nk_symbol_type symbol,
const char *str,
int len, nk_flags align,
19756 struct nk_rect tri = {0,0,0,0};
19762 if (!out || !style || !font)
19765 ret = nk_do_button(state, out, bounds, style, in, behavior, &content);
19766 tri.
y = content.
y + (content.
h/2) - font->
height/2;
19768 if (align & NK_TEXT_ALIGN_LEFT) {
19769 tri.
x = (content.
x + content.
w) - (2 * style->
padding.
x + tri.
w);
19771 }
else tri.
x = content.
x + 2 * style->
padding.
x;
19775 nk_draw_button_text_symbol(out, &bounds, &content, &tri,
19776 *state, style, str, len, symbol, font);
19784 const char *str,
int len,
const struct nk_user_font *font,
19789 background = nk_draw_button(out, bounds, state, style);
19793 text.background = background->
data.
color;
19795 if (state & NK_WIDGET_STATE_HOVER)
19797 else if (state & NK_WIDGET_STATE_ACTIVED)
19806 nk_do_button_text_image(nk_flags *state,
19808 struct nk_image img,
const char* str,
int len, nk_flags align,
19820 if (!out || !font || !style || !str)
19823 ret = nk_do_button(state, out, bounds, style, in, behavior, &content);
19825 icon.w = icon.h = bounds.
h - 2 * style->
padding.
y;
19826 if (align & NK_TEXT_ALIGN_LEFT) {
19827 icon.x = (bounds.
x + bounds.
w) - (2 * style->
padding.
x + icon.w);
19828 icon.x =
NK_MAX(icon.x, 0);
19829 }
else icon.x = bounds.
x + 2 * style->
padding.
x;
19837 nk_draw_button_text_image(out, &bounds, &content, &icon, *state, style, str, len, font, &img);
19851 struct nk_config_stack_button_behavior *button_stack;
19852 struct nk_config_stack_button_behavior_element *element;
19855 if (!ctx)
return 0;
19858 NK_ASSERT(button_stack->head < (
int)
NK_LEN(button_stack->elements));
19859 if (button_stack->head >= (
int)
NK_LEN(button_stack->elements))
19862 element = &button_stack->elements[button_stack->head++];
19871 struct nk_config_stack_button_behavior *button_stack;
19872 struct nk_config_stack_button_behavior_element *element;
19875 if (!ctx)
return 0;
19878 NK_ASSERT(button_stack->head > 0);
19879 if (button_stack->head < 1)
19882 element = &button_stack->elements[--button_stack->head];
19883 *element->address = element->old_value;
19907 if (!state)
return 0;
19914 nk_button_text(
struct nk_context *ctx,
const char *title,
int len)
19917 if (!ctx)
return 0;
19952 if (!state)
return 0;
19984 if (!state)
return 0;
19993 if (!ctx)
return 0;
20017 if (!state)
return 0;
20026 if (!ctx)
return 0;
20032 const char *text,
int len, nk_flags align)
20051 if (!state)
return 0;
20059 const char* text,
int len, nk_flags align)
20062 if (!ctx)
return 0;
20066 const char *label, nk_flags align)
20072 const char *title, nk_flags align)
20079 int len, nk_flags align)
20098 if (!state)
return 0;
20106 const char *text,
int len, nk_flags align)
20111 const char *label, nk_flags align)
20117 const char *label, nk_flags text_alignment)
20133 nk_flags *state,
int active)
20135 nk_widget_state_reset(state);
20150 const struct nk_rect *cursors,
const char *
string,
int len,
20158 if (state & NK_WIDGET_STATE_HOVER) {
20159 background = &style->
hover;
20162 }
else if (state & NK_WIDGET_STATE_ACTIVED) {
20163 background = &style->
hover;
20167 background = &style->
normal;
20183 text.padding.x = 0;
20184 text.padding.y = 0;
20186 nk_widget_text(out, *label,
string, len, &text,
NK_TEXT_LEFT, font);
20192 const struct nk_rect *cursors,
const char *
string,
int len,
20200 if (state & NK_WIDGET_STATE_HOVER) {
20201 background = &style->
hover;
20204 }
else if (state & NK_WIDGET_STATE_ACTIVED) {
20205 background = &style->
hover;
20209 background = &style->
normal;
20225 text.padding.x = 0;
20226 text.padding.y = 0;
20228 nk_widget_text(out, *label,
string, len, &text,
NK_TEXT_LEFT, font);
20231 nk_do_toggle(nk_flags *state,
20233 int *active,
const char *str,
int len,
enum nk_toggle_type type,
20246 if (!out || !style || !font || !active)
20260 select.
h = select.
w;
20261 select.
y = r.
y + r.
h/2.0f - select.
h/2.0f;
20271 label.
x = select.
x + select.
w + style->
spacing;
20272 label.
y = select.
y;
20274 label.
h = select.
w;
20277 was_active = *active;
20278 *active = nk_toggle_behavior(in, bounds, state, *active);
20283 if (type == NK_TOGGLE_CHECK) {
20284 nk_draw_checkbox(out, *state, style, *active, &label, &select, &cursor, str, len, font);
20286 nk_draw_option(out, *state, style, *active, &label, &select, &cursor, str, len, font);
20290 return (was_active != *active);
20298 nk_check_text(
struct nk_context *ctx,
const char *text,
int len,
int active)
20315 style = &ctx->
style;
20319 if (!state)
return active;
20322 text, len, NK_TOGGLE_CHECK, &style->
checkbox, in, style->
font);
20327 unsigned int flags,
unsigned int value)
20332 if (!ctx || !text)
return flags;
20333 old_active = (int)((flags & value) &
value);
20336 else flags &= ~value;
20340 nk_checkbox_text(
struct nk_context *ctx,
const char *text,
int len,
int *active)
20346 if (!ctx || !text || !active)
return 0;
20349 return old_val != *active;
20353 unsigned int *flags,
unsigned int value)
20359 if (!ctx || !text || !flags)
return 0;
20361 active = (int)((*flags & value) &
value);
20363 if (active) *flags |=
value;
20364 else *flags &= ~value;
20374 unsigned int flags,
unsigned int value)
20383 unsigned int *flags,
unsigned int value)
20393 nk_option_text(
struct nk_context *ctx,
const char *text,
int len,
int is_active)
20410 style = &ctx->
style;
20414 if (!state)
return (
int)
state;
20417 text, len, NK_TOGGLE_OPTION, &style->
option, in, style->
font);
20421 nk_radio_text(
struct nk_context *ctx,
const char *text,
int len,
int *active)
20427 if (!ctx || !text || !active)
return 0;
20428 old_value = *active;
20430 return old_value != *active;
20433 nk_option_label(
struct nk_context *ctx,
const char *label,
int active)
20438 nk_radio_label(
struct nk_context *ctx,
const char *label,
int *active)
20455 const struct nk_rect *bounds,
20457 const char *
string,
int len, nk_flags align,
const struct nk_user_font *font)
20461 text.padding = style->
padding;
20465 if (state & NK_WIDGET_STATE_ACTIVED) {
20466 background = &style->
pressed;
20468 }
else if (state & NK_WIDGET_STATE_HOVER) {
20469 background = &style->
hover;
20472 background = &style->
normal;
20476 if (state & NK_WIDGET_STATE_ACTIVED) {
20479 }
else if (state & NK_WIDGET_STATE_HOVER) {
20490 text.background =
nk_rgba(0,0,0,0);
20493 text.background = background->
data.
color;
20497 else nk_draw_symbol(out, sym, *icon, text.background, text.text, 1, font);
20499 nk_widget_text(out, *bounds,
string, len, &text, align, font);
20503 struct nk_rect bounds,
const char *str,
int len, nk_flags align,
int *value,
20518 if (!state || !out || !str || !len || !value || !style || !font)
return 0;
20519 old_value = *
value;
20529 *value = !(*value);
20533 nk_draw_selectable(out, *state, style, *value, &bounds, 0,0,
NK_SYMBOL_NONE, str, len, align, font);
20535 return old_value != *
value;
20539 struct nk_rect bounds,
const char *str,
int len, nk_flags align,
int *value,
20555 if (!state || !out || !str || !len || !value || !style || !font)
return 0;
20556 old_value = *
value;
20564 *value = !(*value);
20567 icon.
w = icon.
h = bounds.
h - 2 * style->
padding.
y;
20568 if (align & NK_TEXT_ALIGN_LEFT) {
20569 icon.
x = (bounds.
x + bounds.
w) - (2 * style->
padding.
x + icon.
w);
20571 }
else icon.
x = bounds.
x + 2 * style->
padding.
x;
20580 nk_draw_selectable(out, *state, style, *value, &bounds, &icon, img,
NK_SYMBOL_NONE, str, len, align, font);
20582 return old_value != *
value;
20586 struct nk_rect bounds,
const char *str,
int len, nk_flags align,
int *value,
20602 if (!state || !out || !str || !len || !value || !style || !font)
return 0;
20603 old_value = *
value;
20611 *value = !(*value);
20614 icon.
w = icon.
h = bounds.
h - 2 * style->
padding.
y;
20615 if (align & NK_TEXT_ALIGN_LEFT) {
20616 icon.
x = (bounds.
x + bounds.
w) - (2 * style->
padding.
x + icon.
w);
20618 }
else icon.
x = bounds.
x + 2 * style->
padding.
x;
20627 nk_draw_selectable(out, *state, style, *value, &bounds, &icon, 0, sym, str, len, align, font);
20629 return old_value != *
value;
20634 nk_flags align,
int *value)
20653 style = &ctx->
style;
20656 if (!state)
return 0;
20663 const char *str,
int len, nk_flags align,
int *value)
20682 style = &ctx->
style;
20685 if (!state)
return 0;
20688 str, len, align, value, &img, &style->
selectable, in, style->
font);
20692 const char *str,
int len, nk_flags align,
int *value)
20711 style = &ctx->
style;
20714 if (!state)
return 0;
20717 str, len, align, value, sym, &style->
selectable, in, style->
font);
20721 const char *title, nk_flags align,
int *value)
20726 nk_flags align,
int value)
20735 const char *str, nk_flags align,
int *value)
20744 const char *str, nk_flags align,
int value)
20749 const char *str,
int len, nk_flags align,
int value)
20755 const char *title,
int title_len, nk_flags align,
int value)
20761 const char *title, nk_flags align,
int value)
20776 nk_slider_behavior(nk_flags *state,
struct nk_rect *logical_cursor,
20778 struct nk_rect bounds,
float slider_min,
float slider_max,
float slider_value,
20779 float slider_step,
float slider_steps)
20781 int left_mouse_down;
20782 int left_mouse_click_in_cursor;
20785 nk_widget_state_reset(state);
20790 if (left_mouse_down && left_mouse_click_in_cursor) {
20792 const float d = in->
mouse.
pos.
x - (visual_cursor->
x+visual_cursor->
w*0.5f);
20793 const float pxstep = bounds.
w / slider_steps;
20797 if (
NK_ABS(d) >= pxstep) {
20798 const float steps = (float)((
int)(
NK_ABS(d) / pxstep));
20799 slider_value += (d > 0) ? (slider_step*steps) : -(slider_step*steps);
20800 slider_value =
NK_CLAMP(slider_min, slider_value, slider_max);
20801 ratio = (slider_value - slider_min)/slider_step;
20802 logical_cursor->
x = bounds.
x + (logical_cursor->
w * ratio);
20810 if (*state & NK_WIDGET_STATE_HOVER &&
20815 return slider_value;
20820 const struct nk_rect *visual_cursor,
float min,
float value,
float max)
20827 struct nk_color bar_color;
20834 if (state & NK_WIDGET_STATE_ACTIVED) {
20835 background = &style->
active;
20838 }
else if (state & NK_WIDGET_STATE_HOVER) {
20839 background = &style->
hover;
20843 background = &style->
normal;
20849 bar.y = (visual_cursor->
y + visual_cursor->
h/2) - bounds->
h/12;
20851 bar.h = bounds->
h/6;
20854 fill.w = (visual_cursor->
x + (visual_cursor->
w/2.0f)) - bar.x;
20877 nk_do_slider(nk_flags *state,
20879 float min,
float val,
float max,
float step,
20883 float slider_range;
20886 float slider_value;
20887 float slider_steps;
20888 float cursor_offset;
20890 struct nk_rect visual_cursor;
20891 struct nk_rect logical_cursor;
20895 if (!out || !style)
20910 button.y = bounds.
y;
20911 button.w = bounds.
h;
20912 button.h = bounds.
h;
20915 button.x = bounds.
x;
20921 button.x = (bounds.
x + bounds.
w) - button.w;
20926 bounds.
x = bounds.
x + button.w + style->
spacing.
x;
20927 bounds.
w = bounds.
w - (2*button.w + 2*style->
spacing.
x);
20935 slider_max =
NK_MAX(min, max);
20936 slider_min =
NK_MIN(min, max);
20937 slider_value =
NK_CLAMP(slider_min, val, slider_max);
20938 slider_range = slider_max - slider_min;
20939 slider_steps = slider_range / step;
20940 cursor_offset = (slider_value - slider_min) / step;
20945 logical_cursor.
h = bounds.
h;
20946 logical_cursor.
w = bounds.
w / slider_steps;
20947 logical_cursor.
x = bounds.
x + (logical_cursor.
w * cursor_offset);
20948 logical_cursor.
y = bounds.
y;
20952 visual_cursor.
y = (bounds.
y + bounds.
h*0.5f) - visual_cursor.
h*0.5f;
20953 visual_cursor.
x = logical_cursor.
x - visual_cursor.
w*0.5f;
20955 slider_value = nk_slider_behavior(state, &logical_cursor, &visual_cursor,
20956 in, bounds, slider_min, slider_max, slider_value, step, slider_steps);
20957 visual_cursor.
x = logical_cursor.
x - visual_cursor.
w*0.5f;
20961 nk_draw_slider(out, *state, style, &bounds, &visual_cursor, slider_min, slider_value, slider_max);
20963 return slider_value;
20966 nk_slider_float(
struct nk_context *ctx,
float min_value,
float *value,
float max_value,
20987 style = &ctx->
style;
20991 if (!state)
return ret;
20994 old_value = *value;
20996 old_value, max_value, value_step, &style->
slider, in, style->
font);
20997 return (old_value > *value || old_value < *value);
21000 nk_slide_float(
struct nk_context *ctx,
float min,
float val,
float max,
float step)
21005 nk_slide_int(
struct nk_context *ctx,
int min,
int val,
int max,
int step)
21007 float value = (float)val;
21012 nk_slider_int(
struct nk_context *ctx,
int min,
int *val,
int max,
int step)
21015 float value = (float)*val;
21016 ret =
nk_slider_float(ctx, (
float)min, &value, (
float)max, (
float)step);
21031 nk_progress_behavior(nk_flags *state,
struct nk_input *in,
21032 struct nk_rect r,
struct nk_rect cursor, nk_size max, nk_size value,
int modifiable)
21034 int left_mouse_down = 0;
21035 int left_mouse_click_in_cursor = 0;
21037 nk_widget_state_reset(state);
21038 if (!in || !modifiable)
return value;
21045 if (in && left_mouse_down && left_mouse_click_in_cursor) {
21046 if (left_mouse_down && left_mouse_click_in_cursor) {
21047 float ratio =
NK_MAX(0, (
float)(in->
mouse.
pos.
x - cursor.
x)) / (float)cursor.
w;
21048 value = (nk_size)
NK_CLAMP(0, (
float)max * ratio, (
float)max);
21063 const struct nk_rect *scursor, nk_size value, nk_size max)
21072 if (state & NK_WIDGET_STATE_ACTIVED) {
21073 background = &style->
active;
21075 }
else if (state & NK_WIDGET_STATE_HOVER){
21076 background = &style->
hover;
21079 background = &style->
normal;
21096 nk_do_progress(nk_flags *state,
21098 nk_size value, nk_size max,
int modifiable,
21102 nk_size prog_value;
21107 if (!out || !style)
return 0;
21113 prog_scale = (float)value / (
float)max;
21116 prog_value =
NK_MIN(value, max);
21117 prog_value = nk_progress_behavior(state, in, bounds, cursor,max, prog_value, modifiable);
21118 cursor.w = cursor.w * prog_scale;
21122 nk_draw_progress(out, *state, style, &bounds, &cursor, value, max);
21127 nk_progress(
struct nk_context *ctx, nk_size *cur, nk_size max,
int is_modifyable)
21146 style = &ctx->
style;
21149 if (!state)
return 0;
21154 *cur, max, is_modifyable, &style->
progress, in);
21155 return (*cur != old_value);
21158 nk_prog(
struct nk_context *ctx, nk_size cur, nk_size max,
int modifyable)
21174 nk_scrollbar_behavior(nk_flags *state,
struct nk_input *in,
21175 int has_scrolling,
const struct nk_rect *scroll,
21177 const struct nk_rect *empty1,
float scroll_offset,
21181 int left_mouse_down;
21182 int left_mouse_click_in_cursor;
21183 float scroll_delta;
21185 nk_widget_state_reset(state);
21186 if (!in)
return scroll_offset;
21195 if (left_mouse_down && left_mouse_click_in_cursor) {
21197 float pixel, delta;
21202 delta = (pixel / scroll->
h) * target;
21203 scroll_offset =
NK_CLAMP(0, scroll_offset + delta, target - scroll->
h);
21204 cursor_y = scroll->
y + ((scroll_offset/
target) * scroll->
h);
21209 delta = (pixel / scroll->
w) * target;
21210 scroll_offset =
NK_CLAMP(0, scroll_offset + delta, target - scroll->
w);
21211 cursor_x = scroll->
x + ((scroll_offset/
target) * scroll->
w);
21218 scroll_offset =
NK_MAX(0, scroll_offset - scroll->
h);
21219 else scroll_offset =
NK_MAX(0, scroll_offset - scroll->
w);
21224 scroll_offset =
NK_MIN(scroll_offset + scroll->
h, target - scroll->
h);
21225 else scroll_offset =
NK_MIN(scroll_offset + scroll->
w, target - scroll->
w);
21226 }
else if (has_scrolling) {
21227 if ((scroll_delta < 0 || (scroll_delta > 0))) {
21229 scroll_offset = scroll_offset + scroll_step * (-scroll_delta);
21231 scroll_offset =
NK_CLAMP(0, scroll_offset, target - scroll->
h);
21232 else scroll_offset =
NK_CLAMP(0, scroll_offset, target - scroll->
w);
21238 if (o ==
NK_VERTICAL) scroll_offset = target - scroll->
h;
21245 return scroll_offset;
21250 const struct nk_rect *scroll)
21256 if (state & NK_WIDGET_STATE_ACTIVED) {
21257 background = &style->
active;
21259 }
else if (state & NK_WIDGET_STATE_HOVER) {
21260 background = &style->
hover;
21263 background = &style->
normal;
21282 nk_do_scrollbarv(nk_flags *state,
21284 float offset,
float target,
float step,
float button_pixel_inc,
21293 float scroll_offset;
21295 float scroll_ratio;
21300 if (!out || !style)
return 0;
21304 if (target <= scroll.
h)
return 0;
21312 button.x = scroll.
x;
21313 button.w = scroll.
w;
21314 button.h = scroll.
w;
21316 scroll_h =
NK_MAX(scroll.
h - 2 * button.h,0);
21317 scroll_step =
NK_MIN(step, button_pixel_inc);
21320 button.y = scroll.
y;
21321 if (nk_do_button_symbol(&ws, out, button, style->
dec_symbol,
21322 NK_BUTTON_REPEATER, &style->
dec_button, in, font))
21323 offset = offset - scroll_step;
21326 button.y = scroll.
y + scroll.
h - button.h;
21327 if (nk_do_button_symbol(&ws, out, button, style->
inc_symbol,
21328 NK_BUTTON_REPEATER, &style->
inc_button, in, font))
21329 offset = offset + scroll_step;
21331 scroll.
y = scroll.
y + button.h;
21332 scroll.
h = scroll_h;
21336 scroll_step =
NK_MIN(step, scroll.
h);
21337 scroll_offset =
NK_CLAMP(0, offset, target - scroll.
h);
21338 scroll_ratio = scroll.
h /
target;
21339 scroll_off = scroll_offset /
target;
21343 cursor.y = scroll.
y + (scroll_off * scroll.
h) + style->
border + style->
padding.
y;
21348 empty_north.x = scroll.
x;
21349 empty_north.y = scroll.
y;
21350 empty_north.w = scroll.
w;
21351 empty_north.h =
NK_MAX(cursor.y - scroll.
y, 0);
21353 empty_south.x = scroll.
x;
21354 empty_south.y = cursor.y + cursor.h;
21355 empty_south.w = scroll.
w;
21356 empty_south.h =
NK_MAX((scroll.
y + scroll.
h) - (cursor.y + cursor.h), 0);
21359 scroll_offset = nk_scrollbar_behavior(state, in, has_scrolling, &scroll, &cursor,
21360 &empty_north, &empty_south, scroll_offset, target, scroll_step,
NK_VERTICAL);
21361 scroll_off = scroll_offset /
target;
21366 nk_draw_scrollbar(out, *state, style, &scroll, &cursor);
21368 return scroll_offset;
21371 nk_do_scrollbarh(nk_flags *state,
21373 float offset,
float target,
float step,
float button_pixel_inc,
21382 float scroll_offset;
21384 float scroll_ratio;
21388 if (!out || !style)
return 0;
21392 scroll.
w =
NK_MAX(scroll.
w, 2 * scroll.
h);
21393 if (target <= scroll.
w)
return 0;
21400 button.y = scroll.
y;
21401 button.w = scroll.
h;
21402 button.h = scroll.
h;
21404 scroll_w = scroll.
w - 2 * button.w;
21405 scroll_step =
NK_MIN(step, button_pixel_inc);
21408 button.x = scroll.
x;
21409 if (nk_do_button_symbol(&ws, out, button, style->
dec_symbol,
21410 NK_BUTTON_REPEATER, &style->
dec_button, in, font))
21411 offset = offset - scroll_step;
21414 button.x = scroll.
x + scroll.
w - button.w;
21415 if (nk_do_button_symbol(&ws, out, button, style->
inc_symbol,
21416 NK_BUTTON_REPEATER, &style->
inc_button, in, font))
21417 offset = offset + scroll_step;
21419 scroll.
x = scroll.
x + button.w;
21420 scroll.
w = scroll_w;
21424 scroll_step =
NK_MIN(step, scroll.
w);
21425 scroll_offset =
NK_CLAMP(0, offset, target - scroll.
w);
21426 scroll_ratio = scroll.
w /
target;
21427 scroll_off = scroll_offset /
target;
21430 cursor.w = (scroll_ratio * scroll.
w) - (2*style->
border + 2*style->
padding.
x);
21431 cursor.x = scroll.
x + (scroll_off * scroll.
w) + style->
border + style->
padding.
x;
21436 empty_west.x = scroll.
x;
21437 empty_west.y = scroll.
y;
21438 empty_west.w = cursor.x - scroll.
x;
21439 empty_west.h = scroll.
h;
21441 empty_east.x = cursor.x + cursor.w;
21442 empty_east.y = scroll.
y;
21443 empty_east.w = (scroll.
x + scroll.
w) - (cursor.x + cursor.w);
21444 empty_east.h = scroll.
h;
21447 scroll_offset = nk_scrollbar_behavior(state, in, has_scrolling, &scroll, &cursor,
21448 &empty_west, &empty_east, scroll_offset, target, scroll_step, NK_HORIZONTAL);
21449 scroll_off = scroll_offset /
target;
21450 cursor.x = scroll.
x + (scroll_off * scroll.
w);
21454 nk_draw_scrollbar(out, *state, style, &scroll, &cursor);
21456 return scroll_offset;
21469 struct nk_text_find {
21476 struct nk_text_edit_row {
21479 float baseline_y_delta;
21490 #define NK_TEXT_HAS_SELECTION(s) ((s)->select_start != (s)->select_end) 21493 nk_textedit_get_width(
const struct nk_text_edit *edit,
int line_start,
int char_id,
21497 nk_rune unicode = 0;
21502 nk_textedit_layout_row(
struct nk_text_edit_row *r,
struct nk_text_edit *edit,
21503 int line_start_id,
float row_height,
const struct nk_user_font *font)
21508 const char *remaining;
21512 const struct nk_vec2 size = nk_text_calculate_text_bounds(font,
21513 text, (
int)(end - text), row_height, &remaining, 0, &glyphs, NK_STOP_ON_NEW_LINE);
21517 r->baseline_y_delta = size.
y;
21520 r->num_chars = glyphs;
21523 nk_textedit_locate_coord(
struct nk_text_edit *edit,
float x,
float y,
21526 struct nk_text_edit_row r;
21528 float base_y = 0, prev_x;
21532 r.ymin = r.ymax = 0;
21537 nk_textedit_layout_row(&r, edit, i, row_height, font);
21538 if (r.num_chars <= 0)
21541 if (i==0 && y < base_y + r.ymin)
21544 if (y < base_y + r.ymax)
21548 base_y += r.baseline_y_delta;
21564 for (i=0; i < r.num_chars; ++
i) {
21565 float w = nk_textedit_get_width(edit, k, i, font);
21566 if (x < prev_x+w) {
21567 if (x < prev_x+w/2)
21579 return i+r.num_chars-1;
21580 else return i+r.num_chars;
21583 nk_textedit_click(
struct nk_text_edit *state,
float x,
float y,
21588 state->
cursor = nk_textedit_locate_coord(state, x, y, font, row_height);
21594 nk_textedit_drag(
struct nk_text_edit *state,
float x,
float y,
21599 int p = nk_textedit_locate_coord(state, x, y, font, row_height);
21605 nk_textedit_find_charpos(
struct nk_text_find *
find,
struct nk_text_edit *state,
21606 int n,
int single_line,
const struct nk_user_font *font,
float row_height)
21610 struct nk_text_edit_row r;
21611 int prev_start = 0;
21619 nk_textedit_layout_row(&r, state, 0, row_height, font);
21621 find->first_char = 0;
21627 nk_textedit_layout_row(&r, state, i, row_height, font);
21630 find->first_char =
i;
21631 find->length = r.num_chars;
21635 find->height = r.ymax - r.ymin;
21636 find->prev_first = prev_start;
21644 nk_textedit_layout_row(&r, state, i, row_height, font);
21645 if (n < i + r.num_chars)
break;
21648 find->y += r.baseline_y_delta;
21651 find->first_char = first =
i;
21652 find->length = r.num_chars;
21653 find->height = r.ymax - r.ymin;
21654 find->prev_first = prev_start;
21658 for (i=0; first+i <
n; ++
i)
21659 find->x += nk_textedit_get_width(state, first, i, font);
21666 if (NK_TEXT_HAS_SELECTION(state)) {
21679 nk_textedit_makeundo_delete(state, where, len);
21687 nk_textedit_clamp(state);
21688 if (NK_TEXT_HAS_SELECTION(state)) {
21715 if (NK_TEXT_HAS_SELECTION(state)) {
21716 nk_textedit_sortselection(state);
21726 if (NK_TEXT_HAS_SELECTION(state)) {
21727 nk_textedit_sortselection(state);
21728 nk_textedit_clamp(state);
21735 nk_is_word_boundary(
struct nk_text_edit *state,
int idx)
21739 if (idx <= 0)
return 1;
21741 return (c ==
' ' || c ==
'\t' ||c == 0x3000 || c ==
',' || c ==
';' ||
21742 c ==
'(' || c ==
')' || c ==
'{' || c ==
'}' || c ==
'[' || c ==
']' ||
21746 nk_textedit_move_to_word_previous(
struct nk_text_edit *state)
21748 int c = state->
cursor - 1;
21749 while( c >= 0 && !nk_is_word_boundary(state, c))
21758 nk_textedit_move_to_word_next(
struct nk_text_edit *state)
21761 int c = state->
cursor+1;
21762 while( c < len && !nk_is_word_boundary(state, c))
21771 nk_textedit_prep_selection_at_cursor(
struct nk_text_edit *state)
21774 if (!NK_TEXT_HAS_SELECTION(state))
21784 if (NK_TEXT_HAS_SELECTION(state)) {
21796 const char *text = (
const char *) ctext;
21800 nk_textedit_clamp(state);
21806 nk_textedit_makeundo_insert(state, state->
cursor, glyphs);
21828 while ((text_len < total_len) && glyph_len)
21831 if (unicode == 127)
goto next;
21835 if (state->
filter && !state->
filter(state, unicode))
goto next;
21837 if (!NK_TEXT_HAS_SELECTION(state) &&
21841 nk_textedit_makeundo_replace(state, state->
cursor, 1, 1);
21855 nk_textedit_makeundo_insert(state, state->
cursor, 1);
21861 text_len += glyph_len;
21862 glyph_len =
nk_utf_decode(text + text_len, &unicode, total_len-text_len);
21913 nk_textedit_clamp(state);
21914 nk_textedit_prep_selection_at_cursor(state);
21923 if (NK_TEXT_HAS_SELECTION(state))
21924 nk_textedit_move_to_first(state);
21925 else if (state->
cursor > 0)
21932 nk_textedit_prep_selection_at_cursor(state);
21935 nk_textedit_clamp(state);
21941 if (NK_TEXT_HAS_SELECTION(state))
21942 nk_textedit_move_to_last(state);
21944 nk_textedit_clamp(state);
21950 if( !NK_TEXT_HAS_SELECTION( state ) )
21951 nk_textedit_prep_selection_at_cursor(state);
21952 state->
cursor = nk_textedit_move_to_word_previous(state);
21954 nk_textedit_clamp(state );
21956 if (NK_TEXT_HAS_SELECTION(state))
21957 nk_textedit_move_to_first(state);
21959 state->
cursor = nk_textedit_move_to_word_previous(state);
21960 nk_textedit_clamp(state );
21966 if( !NK_TEXT_HAS_SELECTION( state ) )
21967 nk_textedit_prep_selection_at_cursor(state);
21968 state->
cursor = nk_textedit_move_to_word_next(state);
21970 nk_textedit_clamp(state);
21972 if (NK_TEXT_HAS_SELECTION(state))
21973 nk_textedit_move_to_last(state);
21975 state->
cursor = nk_textedit_move_to_word_next(state);
21976 nk_textedit_clamp(state );
21981 struct nk_text_find find;
21982 struct nk_text_edit_row
row;
21983 int i, sel = shift_mod;
21992 nk_textedit_prep_selection_at_cursor(state);
21993 else if (NK_TEXT_HAS_SELECTION(state))
21994 nk_textedit_move_to_last(state);
21997 nk_textedit_clamp(state);
22006 int start = find.first_char + find.length;
22009 nk_textedit_layout_row(&
row, state, state->
cursor, row_height, font);
22012 for (i=0; i <
row.num_chars && x <
row.x1; ++
i) {
22013 float dx = nk_textedit_get_width(state, start, i, font);
22019 nk_textedit_clamp(state);
22029 struct nk_text_find find;
22030 struct nk_text_edit_row
row;
22031 int i, sel = shift_mod;
22040 nk_textedit_prep_selection_at_cursor(state);
22041 else if (NK_TEXT_HAS_SELECTION(state))
22042 nk_textedit_move_to_first(state);
22045 nk_textedit_clamp(state);
22050 if (find.prev_first != find.first_char) {
22055 state->
cursor = find.prev_first;
22056 nk_textedit_layout_row(&
row, state, state->
cursor, row_height, font);
22059 for (i=0; i <
row.num_chars && x <
row.x1; ++
i) {
22060 float dx = nk_textedit_get_width(state, find.prev_first, i, font);
22066 nk_textedit_clamp(state);
22077 if (NK_TEXT_HAS_SELECTION(state))
22090 if (NK_TEXT_HAS_SELECTION(state))
22093 nk_textedit_clamp(state);
22094 if (state->
cursor > 0) {
22104 nk_textedit_prep_selection_at_cursor(state);
22115 nk_textedit_prep_selection_at_cursor(state);
22127 struct nk_text_find find;
22128 nk_textedit_clamp(state);
22129 nk_textedit_prep_selection_at_cursor(state);
22137 struct nk_text_find find;
22140 nk_textedit_clamp(state);
22141 nk_textedit_move_to_first(state);
22144 state->
cursor = find.first_char;
22151 struct nk_text_find find;
22152 nk_textedit_clamp(state);
22153 nk_textedit_prep_selection_at_cursor(state);
22157 state->
cursor = find.first_char + find.length;
22162 struct nk_text_find find;
22163 nk_textedit_clamp(state);
22164 nk_textedit_move_to_first(state);
22169 state->
cursor = find.first_char + find.length;
22239 nk_textedit_flush_redo(state);
22244 nk_textedit_discard_undo(state);
22257 nk_textedit_discard_undo(state);
22262 int insert_len,
int delete_len)
22272 if (insert_len == 0) {
22296 r->
where = u.where;
22298 if (u.delete_length)
22317 nk_textedit_discard_redo(s);
22328 for (i=0; i < u.delete_length; ++
i)
22337 if (u.insert_length) {
22340 &s->
undo_char[u.char_storage], u.insert_length);
22343 state->
cursor = (short)(u.where + u.insert_length);
22400 nk_textedit_createundo(&state->
undo, where, 0, length);
22406 nk_rune *p = nk_textedit_createundo(&state->
undo, where, length, 0);
22413 nk_textedit_makeundo_replace(
struct nk_text_edit *state,
int where,
22414 int old_length,
int new_length)
22417 nk_rune *p = nk_textedit_createundo(&state->
undo, where, old_length, new_length);
22419 for (i=0; i < old_length; ++
i)
22448 if (!state || !memory || !size)
return;
22458 if (!state || !alloc)
return;
22463 #ifdef NK_INCLUDE_DEFAULT_ALLOCATOR 22468 if (!state)
return;
22471 nk_str_init_default(&state->
string);
22485 if (!state)
return;
22509 if (unicode > 128)
return nk_false;
22516 if ((unicode < '0' || unicode >
'9') && unicode !=
'.' && unicode !=
'-')
22524 if ((unicode < '0' || unicode >
'9') && unicode !=
'-')
22532 if ((unicode < '0' || unicode >
'9') &&
22533 (unicode < 'a' || unicode >
'f') &&
22534 (unicode < 'A' || unicode >
'F'))
22542 if (unicode < '0' || unicode >
'7')
22550 if (unicode !=
'0' && unicode !=
'1')
22562 const struct nk_style_edit *style,
float pos_x,
float pos_y,
22563 float x_offset,
const char *text,
int byte_len,
float row_height,
22564 const struct nk_user_font *font,
struct nk_color background,
22565 struct nk_color foreground,
int is_selected)
22570 if (!text || !byte_len || !out || !style)
return;
22572 {
int glyph_len = 0;
22573 nk_rune unicode = 0;
22575 float line_width = 0;
22577 const char *line = text;
22578 float line_offset = 0;
22579 int line_count = 0;
22583 txt.background = background;
22584 txt.text = foreground;
22586 glyph_len =
nk_utf_decode(text+text_len, &unicode, byte_len-text_len);
22587 if (!glyph_len)
return;
22588 while ((text_len < byte_len) && glyph_len)
22590 if (unicode ==
'\n') {
22593 label.
y = pos_y + line_offset;
22594 label.h = row_height;
22595 label.w = line_width;
22598 label.x += x_offset;
22602 nk_widget_text(out, label, line, (
int)((text + text_len) - line),
22608 line = text + text_len;
22609 line_offset += row_height;
22610 glyph_len =
nk_utf_decode(text + text_len, &unicode, (
int)(byte_len-text_len));
22613 if (unicode ==
'\r') {
22615 glyph_len =
nk_utf_decode(text + text_len, &unicode, byte_len-text_len);
22619 line_width += (float)glyph_width;
22620 text_len += glyph_len;
22621 glyph_len =
nk_utf_decode(text + text_len, &unicode, byte_len-text_len);
22624 if (line_width > 0) {
22627 label.
y = pos_y + line_offset;
22628 label.h = row_height;
22629 label.w = line_width;
22632 label.x += x_offset;
22636 nk_widget_text(out, label, line, (
int)((text + text_len) - line),
22649 char prev_state = 0;
22650 char is_hovered = 0;
22651 char select_all = 0;
22652 char cursor_follow = 0;
22659 if (!state || !out || !style)
22672 old_clip = out->
clip;
22673 nk_unify(&clip, &old_clip, area.
x, area.y, area.x + area.w, area.y + area.h);
22676 prev_state = (char)edit->
active;
22680 bounds.
x, bounds.
y, bounds.
w, bounds.
h);
22684 if (!prev_state && edit->
active) {
22687 nk_textedit_clear_state(edit, type, filter);
22701 if (prev_state != edit->
active)
22717 nk_textedit_click(edit, mouse_x, mouse_y, font, row_height);
22720 nk_textedit_drag(edit, mouse_x, mouse_y, font, row_height);
22730 int old_mode = edit->
mode;
22734 nk_textedit_key(edit, (
enum nk_keys)i, shift_mod, font, row_height);
22738 if (old_mode != edit->
mode) {
22771 int begin =
NK_MIN(b, e);
22776 if (cut && !(flags & NK_EDIT_READ_ONLY)){
22784 if (paste && (flags & NK_EDIT_CLIPBOARD) && edit->
clip.
paste) {
22800 else nk_widget_state_reset(state);
22811 if (*state & NK_WIDGET_STATE_ACTIVED)
22812 background = &style->
active;
22813 else if (*state & NK_WIDGET_STATE_HOVER)
22814 background = &style->
hover;
22815 else background = &style->
normal;
22826 int total_lines = 1;
22830 const char *cursor_ptr = 0;
22831 const char *select_begin_ptr = 0;
22832 const char *select_end_ptr = 0;
22843 float line_width = 0.0f;
22849 nk_rune unicode = 0;
22859 while ((text_len < len) && glyph_len)
22862 if (!cursor_ptr && glyphs == edit->
cursor)
22867 const char *remaining;
22870 cursor_pos.
y = (float)(total_lines-1) * row_height;
22871 row_size = nk_text_calculate_text_bounds(font, text+row_begin,
22872 text_len-row_begin, row_height, &remaining,
22873 &out_offset, &glyph_offset, NK_STOP_ON_NEW_LINE);
22874 cursor_pos.
x = row_size.x;
22875 cursor_ptr = text + text_len;
22880 glyphs == selection_begin)
22885 const char *remaining;
22888 selection_offset_start.
y = (float)(
NK_MAX(total_lines-1,0)) * row_height;
22889 row_size = nk_text_calculate_text_bounds(font, text+row_begin,
22890 text_len-row_begin, row_height, &remaining,
22891 &out_offset, &glyph_offset, NK_STOP_ON_NEW_LINE);
22892 selection_offset_start.
x = row_size.x;
22893 select_begin_ptr = text + text_len;
22898 glyphs == selection_end)
22903 const char *remaining;
22906 selection_offset_end.
y = (float)(total_lines-1) * row_height;
22907 row_size = nk_text_calculate_text_bounds(font, text+row_begin,
22908 text_len-row_begin, row_height, &remaining,
22909 &out_offset, &glyph_offset, NK_STOP_ON_NEW_LINE);
22910 selection_offset_end.
x = row_size.x;
22911 select_end_ptr = text + text_len;
22913 if (unicode ==
'\n') {
22914 text_size.
x =
NK_MAX(text_size.
x, line_width);
22919 row_begin = text_len;
22920 glyph_len =
nk_utf_decode(text + text_len, &unicode, len-text_len);
22926 text_len += glyph_len;
22927 line_width += (float)glyph_width;
22929 glyph_len =
nk_utf_decode(text + text_len, &unicode, len-text_len);
22931 text+text_len, glyph_len);
22934 text_size.
y = (float)total_lines * row_height;
22938 cursor_pos.
x = line_width;
22939 cursor_pos.
y = text_size.
y - row_height;
22949 const float scroll_increment = area.w * 0.25f;
22956 if (flags & NK_EDIT_MULTILINE) {
22966 if (flags & NK_EDIT_MULTILINE)
22970 float scroll_target;
22971 float scroll_offset;
22980 scroll_step = scroll.
h * 0.10f;
22981 scroll_inc = scroll.
h * 0.01f;
22982 scroll_target = text_size.
y;
22983 edit->
scrollbar.
y = nk_do_scrollbarv(&ws, out, scroll, 0,
22984 scroll_offset, scroll_target, scroll_step, scroll_inc,
22990 {
struct nk_color background_color;
22991 struct nk_color text_color;
22992 struct nk_color sel_background_color;
22993 struct nk_color sel_text_color;
22994 struct nk_color cursor_color;
22995 struct nk_color cursor_text_color;
23000 if (*state & NK_WIDGET_STATE_ACTIVED) {
23001 background = &style->
active;
23007 }
else if (*state & NK_WIDGET_STATE_HOVER) {
23008 background = &style->
hover;
23015 background = &style->
normal;
23023 background_color =
nk_rgba(0,0,0,0);
23024 else background_color = background->
data.
color;
23031 nk_edit_draw_text(out, style, area.x - edit->
scrollbar.
x,
23032 area.y - edit->
scrollbar.
y, 0, begin, l, row_height, font,
23033 background_color, text_color,
nk_false);
23039 NK_ASSERT(select_begin_ptr);
23040 nk_edit_draw_text(out, style, area.x - edit->
scrollbar.
x,
23041 area.y - edit->
scrollbar.
y, 0, begin, (
int)(select_begin_ptr - begin),
23042 row_height, font, background_color, text_color,
nk_false);
23046 NK_ASSERT(select_begin_ptr);
23047 if (!select_end_ptr) {
23051 nk_edit_draw_text(out, style,
23053 area.y + selection_offset_start.
y - edit->
scrollbar.
y,
23054 selection_offset_start.
x,
23055 select_begin_ptr, (
int)(select_end_ptr - select_begin_ptr),
23056 row_height, font, sel_background_color, sel_text_color, nk_true);
23059 selection_end < edit->
string.len))
23062 const char *begin = select_end_ptr;
23065 NK_ASSERT(select_end_ptr);
23066 nk_edit_draw_text(out, style,
23068 area.y + selection_offset_end.
y - edit->
scrollbar.
y,
23069 selection_offset_end.
x,
23070 begin, (
int)(end - begin), row_height, font,
23071 background_color, text_color, nk_true);
23079 (cursor_ptr && *cursor_ptr ==
'\n')) {
23083 cursor.h = font->
height;
23084 cursor.x = area.x + cursor_pos.
x - edit->
scrollbar.
x;
23085 cursor.y = area.y + cursor_pos.
y + row_height/2.0f - cursor.h/2.0f;
23095 NK_ASSERT(cursor_ptr);
23098 label.x = area.x + cursor_pos.
x - edit->
scrollbar.
x;
23099 label.y = area.y + cursor_pos.
y - edit->
scrollbar.
y;
23101 label.h = row_height;
23104 txt.background = cursor_color;;
23105 txt.text = cursor_text_color;
23107 nk_widget_text(out, label, cursor_ptr, glyph_len, &txt,
NK_TEXT_LEFT, font);
23116 struct nk_color background_color;
23117 struct nk_color text_color;
23119 if (*state & NK_WIDGET_STATE_ACTIVED) {
23120 background = &style->
active;
23122 }
else if (*state & NK_WIDGET_STATE_HOVER) {
23123 background = &style->
hover;
23126 background = &style->
normal;
23130 background_color =
nk_rgba(0,0,0,0);
23131 else background_color = background->
data.
color;
23132 nk_edit_draw_text(out, style, area.x - edit->
scrollbar.
x,
23133 area.y - edit->
scrollbar.
y, 0, begin, l, row_height, font,
23134 background_color, text_color,
nk_false);
23147 if (!ctx || !ctx->
current)
return;
23153 if (flags & NK_EDIT_ALWAYS_INSERT_MODE)
23162 if (!ctx || !ctx->
current)
return;
23180 if (!ctx || !memory || !len)
23187 nk_textedit_clear_state(&ctx->
text_edit, (flags & NK_EDIT_MULTILINE)?
23208 *len =
NK_MIN(*len, max-1);
23235 nk_flags ret_flags = 0;
23236 unsigned char prev_state;
23248 style = &ctx->
style;
23250 if (!state)
return state;
23256 if (flags & NK_EDIT_NO_CURSOR)
23262 if (flags & NK_EDIT_CLIPBOARD)
23269 prev_state = (
unsigned char)edit->
active;
23270 in = (flags & NK_EDIT_READ_ONLY) ? 0:
in;
23272 filter, edit, &style->
edit, in, style->
font);
23280 }
else if (prev_state && !edit->
active) {
23283 }
return ret_flags;
23306 nk_drag_behavior(nk_flags *state,
const struct nk_input *in,
23307 struct nk_rect drag,
struct nk_property_variant *variant,
23308 float inc_per_pixel)
23311 int left_mouse_click_in_cursor = in &&
23314 nk_widget_state_reset(state);
23318 if (left_mouse_down && left_mouse_click_in_cursor) {
23321 delta = pixels * inc_per_pixel;
23322 switch (variant->kind) {
23324 case NK_PROPERTY_INT:
23325 variant->value.i = variant->value.i + (int)delta;
23326 variant->value.i =
NK_CLAMP(variant->min_value.i, variant->value.i, variant->max_value.i);
23328 case NK_PROPERTY_FLOAT:
23329 variant->value.f = variant->value.f + (float)delta;
23330 variant->value.f =
NK_CLAMP(variant->min_value.f, variant->value.f, variant->max_value.f);
23332 case NK_PROPERTY_DOUBLE:
23333 variant->value.d = variant->value.d + (double)delta;
23334 variant->value.d =
NK_CLAMP(variant->min_value.d, variant->value.d, variant->max_value.d);
23345 nk_property_behavior(nk_flags *ws,
const struct nk_input *in,
23347 struct nk_rect empty,
int *state,
struct nk_property_variant *variant,
23348 float inc_per_pixel)
23350 if (in && *state == NK_PROPERTY_DEFAULT) {
23352 *state = NK_PROPERTY_EDIT;
23354 *state = NK_PROPERTY_DRAG;
23356 *state = NK_PROPERTY_DRAG;
23358 if (*state == NK_PROPERTY_DRAG) {
23359 nk_drag_behavior(ws, in, property, variant, inc_per_pixel);
23360 if (!(*ws & NK_WIDGET_STATE_ACTIVED)) *state = NK_PROPERTY_DEFAULT;
23365 const struct nk_rect *bounds,
const struct nk_rect *label, nk_flags state,
23366 const char *name,
int len,
const struct nk_user_font *font)
23372 if (state & NK_WIDGET_STATE_ACTIVED) {
23373 background = &style->
active;
23375 }
else if (state & NK_WIDGET_STATE_HOVER) {
23376 background = &style->
hover;
23379 background = &style->
normal;
23386 text.background =
nk_rgba(0,0,0,0);
23388 text.background = background->
data.
color;
23398 nk_do_property(nk_flags *ws,
23400 const char *name,
struct nk_property_variant *variant,
23401 float inc_per_pixel,
char *buffer,
int *len,
23402 int *state,
int *cursor,
int *select_begin,
int *select_end,
23404 enum nk_property_filter filter,
struct nk_input *in,
23413 int num_len, name_len;
23430 left.y =
property.y + style->
border +
property.h/2.0f - left.h/2;
23435 label.
x = left.x + left.w + style->
padding.
x;
23436 label.
w = (float)size + 2 * style->
padding.
x;
23444 right.x =
property.x +
property.w - (right.w + style->
padding.
x);
23447 if (*state == NK_PROPERTY_EDIT) {
23453 switch (variant->kind) {
23455 case NK_PROPERTY_INT:
23456 nk_itoa(
string, variant->value.i);
23459 case NK_PROPERTY_FLOAT:
23460 NK_DTOA(
string, (
double)variant->value.f);
23463 case NK_PROPERTY_DOUBLE:
23464 NK_DTOA(
string, variant->value.d);
23473 edit.
w = (float)size + 2 * style->
padding.
x;
23474 edit.
w =
NK_MIN(edit.
w, right.x - (label.
x + label.
w));
23475 edit.
x = right.x - (edit.
w + style->
padding.
x);
23476 edit.
y =
property.y + style->
border;
23477 edit.
h =
property.h - (2 * style->
border);
23480 empty.
w = edit.
x - (label.
x + label.
w);
23481 empty.
x = label.
x + label.
w;
23482 empty.
y =
property.y;
23483 empty.
h =
property.h;
23486 old = (*state == NK_PROPERTY_EDIT);
23487 nk_property_behavior(ws, in, property, label, edit, empty, state, variant, inc_per_pixel);
23491 nk_draw_property(out, style, &property, &label, *ws, name, name_len, font);
23495 if (nk_do_button_symbol(ws, out, left, style->
sym_left, behavior, &style->
dec_button, in, font)) {
23496 switch (variant->kind) {
23498 case NK_PROPERTY_INT:
23499 variant->value.i =
NK_CLAMP(variant->min_value.i, variant->value.i - variant->step.i, variant->max_value.i);
break;
23500 case NK_PROPERTY_FLOAT:
23501 variant->value.f =
NK_CLAMP(variant->min_value.f, variant->value.f - variant->step.f, variant->max_value.f);
break;
23502 case NK_PROPERTY_DOUBLE:
23503 variant->value.d =
NK_CLAMP(variant->min_value.d, variant->value.d - variant->step.d, variant->max_value.d);
break;
23507 if (nk_do_button_symbol(ws, out, right, style->
sym_right, behavior, &style->
inc_button, in, font)) {
23508 switch (variant->kind) {
23510 case NK_PROPERTY_INT:
23511 variant->value.i =
NK_CLAMP(variant->min_value.i, variant->value.i + variant->step.i, variant->max_value.i);
break;
23512 case NK_PROPERTY_FLOAT:
23513 variant->value.f =
NK_CLAMP(variant->min_value.f, variant->value.f + variant->step.f, variant->max_value.f);
break;
23514 case NK_PROPERTY_DOUBLE:
23515 variant->value.d =
NK_CLAMP(variant->min_value.d, variant->value.d + variant->step.d, variant->max_value.d);
break;
23518 if (old != NK_PROPERTY_EDIT && (*state == NK_PROPERTY_EDIT)) {
23520 NK_MEMCPY(buffer, dst, (nk_size)*length);
23526 }
else active = (*state == NK_PROPERTY_EDIT);
23530 text_edit->
active = (
unsigned char)active;
23540 nk_do_edit(ws, out, edit,
NK_EDIT_FIELD|NK_EDIT_AUTO_SELECT,
23541 filters[filter], text_edit, &style->
edit, (*state == NK_PROPERTY_EDIT) ? in: 0, font);
23544 *cursor = text_edit->
cursor;
23550 if (active && !text_edit->
active) {
23552 *state = NK_PROPERTY_DEFAULT;
23553 buffer[*
len] =
'\0';
23554 switch (variant->kind) {
23556 case NK_PROPERTY_INT:
23557 variant->value.i =
nk_strtoi(buffer, 0);
23558 variant->value.i =
NK_CLAMP(variant->min_value.i, variant->value.i, variant->max_value.i);
23560 case NK_PROPERTY_FLOAT:
23562 variant->value.f =
nk_strtof(buffer, 0);
23563 variant->value.f =
NK_CLAMP(variant->min_value.f, variant->value.f, variant->max_value.f);
23565 case NK_PROPERTY_DOUBLE:
23567 variant->value.d =
nk_strtod(buffer, 0);
23568 variant->value.d =
NK_CLAMP(variant->min_value.d, variant->value.d, variant->max_value.d);
23573 NK_LIB struct nk_property_variant
23574 nk_property_variant_int(int value, int min_value, int max_value, int step)
23576 struct nk_property_variant result;
23577 result.kind = NK_PROPERTY_INT;
23578 result.value.i =
value;
23579 result.min_value.i = min_value;
23580 result.max_value.i = max_value;
23581 result.step.i = step;
23584 NK_LIB struct nk_property_variant
23585 nk_property_variant_float(float value, float min_value, float max_value, float step)
23587 struct nk_property_variant result;
23588 result.kind = NK_PROPERTY_FLOAT;
23589 result.value.f =
value;
23590 result.min_value.f = min_value;
23591 result.max_value.f = max_value;
23592 result.step.f = step;
23595 NK_LIB struct nk_property_variant
23596 nk_property_variant_double(double value, double min_value, double max_value,
23599 struct nk_property_variant result;
23600 result.kind = NK_PROPERTY_DOUBLE;
23601 result.value.d =
value;
23602 result.min_value.d = min_value;
23603 result.max_value.d = max_value;
23604 result.step.d = step;
23608 nk_property(
struct nk_context *ctx,
const char *name,
struct nk_property_variant *variant,
23609 float inc_per_pixel,
const enum nk_property_filter filter)
23624 int *select_begin = 0;
23625 int *select_end = 0;
23629 int dummy_state = NK_PROPERTY_DEFAULT;
23630 int dummy_length = 0;
23631 int dummy_cursor = 0;
23632 int dummy_select_begin = 0;
23633 int dummy_select_end = 0;
23643 style = &ctx->
style;
23648 if (name[0] ==
'#') {
23662 buffer = dummy_buffer;
23663 len = &dummy_length;
23664 cursor = &dummy_cursor;
23665 state = &dummy_state;
23666 select_begin = &dummy_select_begin;
23667 select_end = &dummy_select_end;
23671 old_state = *
state;
23676 variant, inc_per_pixel, buffer, len, state, cursor, select_begin,
23680 if (in && *state != NK_PROPERTY_DEFAULT && !win->
property.
active) {
23690 if (*state == NK_PROPERTY_DRAG) {
23696 if (*state == NK_PROPERTY_DEFAULT && old_state != NK_PROPERTY_DEFAULT) {
23697 if (old_state == NK_PROPERTY_DRAG) {
23709 int min,
int *val,
int max,
int step,
float inc_per_pixel)
23711 struct nk_property_variant variant;
23716 if (!ctx || !ctx->
current || !name || !val)
return;
23717 variant = nk_property_variant_int(*val, min, max, step);
23718 nk_property(ctx, name, &variant, inc_per_pixel, NK_FILTER_INT);
23719 *val = variant.value.i;
23723 float min,
float *val,
float max,
float step,
float inc_per_pixel)
23725 struct nk_property_variant variant;
23730 if (!ctx || !ctx->
current || !name || !val)
return;
23731 variant = nk_property_variant_float(*val, min, max, step);
23732 nk_property(ctx, name, &variant, inc_per_pixel, NK_FILTER_FLOAT);
23733 *val = variant.value.f;
23737 double min,
double *val,
double max,
double step,
float inc_per_pixel)
23739 struct nk_property_variant variant;
23744 if (!ctx || !ctx->
current || !name || !val)
return;
23745 variant = nk_property_variant_double(*val, min, max, step);
23746 nk_property(ctx, name, &variant, inc_per_pixel, NK_FILTER_FLOAT);
23747 *val = variant.value.d;
23750 nk_propertyi(
struct nk_context *ctx,
const char *name,
int min,
int val,
23751 int max,
int step,
float inc_per_pixel)
23753 struct nk_property_variant variant;
23757 if (!ctx || !ctx->
current || !name)
return val;
23758 variant = nk_property_variant_int(val, min, max, step);
23759 nk_property(ctx, name, &variant, inc_per_pixel, NK_FILTER_INT);
23760 val = variant.value.i;
23764 nk_propertyf(
struct nk_context *ctx,
const char *name,
float min,
23765 float val,
float max,
float step,
float inc_per_pixel)
23767 struct nk_property_variant variant;
23771 if (!ctx || !ctx->
current || !name)
return val;
23772 variant = nk_property_variant_float(val, min, max, step);
23773 nk_property(ctx, name, &variant, inc_per_pixel, NK_FILTER_FLOAT);
23774 val = variant.value.f;
23778 nk_propertyd(
struct nk_context *ctx,
const char *name,
double min,
23779 double val,
double max,
double step,
float inc_per_pixel)
23781 struct nk_property_variant variant;
23785 if (!ctx || !ctx->
current || !name)
return val;
23786 variant = nk_property_variant_double(val, min, max, step);
23787 nk_property(ctx, name, &variant, inc_per_pixel, NK_FILTER_FLOAT);
23788 val = variant.value.d;
23803 struct nk_color color,
struct nk_color highlight,
23804 int count,
float min_value,
float max_value)
23812 struct nk_rect bounds = {0, 0, 0, 0};
23821 nk_zero(chart,
sizeof(*chart));
23826 config = &ctx->
style;
23828 style = &config->
chart;
23831 nk_zero(chart,
sizeof(*chart));
23845 slot->
min =
NK_MIN(min_value, max_value);
23846 slot->
max =
NK_MAX(min_value, max_value);
23862 int count,
float min_value,
float max_value)
23869 struct nk_color color,
struct nk_color highlight,
23870 int count,
float min_value,
float max_value)
23886 slot->
min =
NK_MIN(min_value, max_value);
23887 slot->
max =
NK_MAX(min_value, max_value);
23892 int count,
float min_value,
float max_value)
23898 nk_chart_push_line(
struct nk_context *ctx,
struct nk_window *win,
23899 struct nk_chart *g,
float value,
int slot)
23908 struct nk_color color;
23921 g->
slots[slot].
last.
y = (g->
y + g->
h) - ratio * (
float)g->
h;
23925 bounds.
w = bounds.
h = 4;
23942 cur.x = g->
x + (float)(step * (
float)g->
slots[slot].
index);
23943 cur.y = (g->
y + g->
h) - (ratio * (
float)g->
h);
23946 bounds.
x = cur.x - 3;
23947 bounds.
y = cur.y - 3;
23948 bounds.
w = bounds.
h = 6;
23968 nk_chart_push_column(
const struct nk_context *ctx,
struct nk_window *win,
23969 struct nk_chart *chart,
float value,
int slot)
23977 struct nk_color color;
23978 struct nk_rect item = {0,0,0,0};
23984 float padding = (float)(chart->
slots[slot].
count-1);
23985 item.
w = (chart->
w - padding) / (
float)(chart->
slots[slot].
count);
23993 item.
y = (chart->
y + chart->
h) - chart->
h * ratio;
23996 item.
y = chart->
y + (chart->
h *
NK_ABS(ratio)) - item.
h;
23998 item.
x = chart->
x + ((float)chart->
slots[slot].
index * item.
w);
24022 NK_ASSERT(slot < ctx->current->layout->chart.slot);
24030 flags = nk_chart_push_line(ctx, win, &win->
layout->
chart, value, slot);
break;
24032 flags = nk_chart_push_column(ctx, win, &win->
layout->
chart, value, slot);
break;
24057 NK_MEMSET(chart, 0,
sizeof(*chart));
24062 int count,
int offset)
24070 if (!ctx || !values || !count)
return;
24072 min_value = values[
offset];
24073 max_value = values[
offset];
24074 for (i = 0; i <
count; ++
i) {
24075 min_value =
NK_MIN(values[i + offset], min_value);
24076 max_value =
NK_MAX(values[i + offset], max_value);
24080 for (i = 0; i <
count; ++
i)
24087 float(*value_getter)(
void* user,
int index),
int count,
int offset)
24094 NK_ASSERT(value_getter);
24095 if (!ctx || !value_getter || !count)
return;
24097 max_value = min_value = value_getter(userdata, offset);
24098 for (i = 0; i <
count; ++
i) {
24099 float value = value_getter(userdata, i + offset);
24100 min_value =
NK_MIN(value, min_value);
24101 max_value =
NK_MAX(value, max_value);
24105 for (i = 0; i <
count; ++
i)
24121 nk_color_picker_behavior(nk_flags *state,
24127 int value_changed = 0;
24128 int hsv_changed = 0;
24132 NK_ASSERT(hue_bar);
24140 value_changed = hsv_changed = 1;
24145 value_changed = hsv_changed = 1;
24154 nk_widget_state_reset(state);
24159 if (value_changed) {
24160 color->
a = hsva[3];
24170 return value_changed;
24177 NK_STORAGE const struct nk_color black = {0,0,0,255};
24178 NK_STORAGE const struct nk_color white = {255, 255, 255, 255};
24179 NK_STORAGE const struct nk_color black_trans = {0,0,0,0};
24181 const float crosshair_size = 7.0f;
24182 struct nk_color temp;
24189 NK_ASSERT(hue_bar);
24193 for (i = 0; i < 6; ++
i) {
24194 NK_GLOBAL const struct nk_color hue_colors[] = {
24195 {255, 0, 0, 255}, {255,255,0,255}, {0,255,0,255}, {0, 255,255,255},
24196 {0,0,255,255}, {255, 0, 255, 255}, {255, 0, 0, 255}
24199 nk_rect(hue_bar->
x, hue_bar->
y + (
float)i * (hue_bar->
h/6.0f) + 0.5f,
24200 hue_bar->
w, (hue_bar->
h/6.0f) + 0.5f), hue_colors[i], hue_colors[i],
24201 hue_colors[i+1], hue_colors[i+1]);
24203 line_y = (float)(
int)(hue_bar->
y + hsva[0] * matrix->
h + 0.5f);
24205 line_y, 1,
nk_rgb(255,255,255));
24210 line_y = (float)(
int)(alpha_bar->
y + (1.0f -
alpha) * matrix->
h + 0.5f);
24214 line_y, 1,
nk_rgb(255,255,255));
24218 temp =
nk_hsv_f(hsva[0], 1.0f, 1.0f);
24223 {
struct nk_vec2 p;
float S = hsva[1];
float V = hsva[2];
24224 p.x = (float)(
int)(matrix->
x + S * matrix->
w);
24225 p.y = (float)(
int)(matrix->
y + (1.0f -
V) * matrix->
h);
24226 nk_stroke_line(o, p.x - crosshair_size, p.y, p.x-2, p.y, 1.0f, white);
24227 nk_stroke_line(o, p.x + crosshair_size + 1, p.y, p.x+3, p.y, 1.0f, white);
24228 nk_stroke_line(o, p.x, p.y + crosshair_size + 1, p.x, p.y+3, 1.0f, white);
24229 nk_stroke_line(o, p.x, p.y - crosshair_size, p.x, p.y-2, 1.0f, white);}
24232 nk_do_color_picker(nk_flags *state,
24248 if (!out || !col || !state || !font)
24252 bounds.
x += padding.
x;
24253 bounds.
y += padding.
x;
24254 bounds.
w -= 2 * padding.
x;
24255 bounds.
h -= 2 * padding.
y;
24257 matrix.
x = bounds.
x;
24258 matrix.
y = bounds.
y;
24259 matrix.
h = bounds.
h;
24260 matrix.
w = bounds.
w - (3 * padding.
x + 2 * bar_w);
24263 hue_bar.
y = bounds.
y;
24264 hue_bar.
h = matrix.
h;
24265 hue_bar.
x = matrix.
x + matrix.
w + padding.
x;
24267 alpha_bar.
x = hue_bar.
x + hue_bar.
w + padding.
x;
24268 alpha_bar.
y = bounds.
y;
24269 alpha_bar.
w = bar_w;
24270 alpha_bar.
h = matrix.
h;
24272 ret = nk_color_picker_behavior(state, &bounds, &matrix, &hue_bar,
24273 (fmt == NK_RGBA) ? &alpha_bar:0, col, in);
24274 nk_draw_color_picker(out, &matrix, &hue_bar, (fmt == NK_RGBA) ? &alpha_bar:0, *col);
24297 config = &ctx->
style;
24300 if (!state)
return 0;
24323 nk_combo_begin(
struct nk_context *ctx,
struct nk_window *win,
24345 is_open = (popup) ? nk_true:
nk_false;
24347 if ((is_clicked && is_open && !is_active) || (is_open && !is_active) ||
24348 (!is_open && !is_active && !is_clicked))
return 0;
24349 if (!nk_nonblock_begin(ctx, 0, body,
24371 NK_ASSERT(selected);
24378 style = &ctx->
style;
24385 is_clicked = nk_true;
24399 text.background =
nk_rgba(0,0,0,0);
24402 text.background = background->
data.
color;
24415 else if (is_clicked)
24423 button.h = button.w;
24436 nk_widget_text(&win->
buffer, label, selected, len, &text,
24443 return nk_combo_begin(ctx, win, size, is_clicked, header);
24469 style = &ctx->
style;
24476 is_clicked = nk_true;
24499 else if (is_clicked)
24507 button.h = button.w;
24525 return nk_combo_begin(ctx, win, size, is_clicked, header);
24538 struct nk_color sym_background;
24539 struct nk_color symbol_color;
24548 style = &ctx->
style;
24555 is_clicked = nk_true;
24570 sym_background =
nk_rgba(0,0,0,0);
24573 sym_background = background->
data.
color;
24578 struct nk_rect bounds = {0,0,0,0};
24585 else if (is_clicked)
24593 button.h = button.w;
24605 nk_draw_symbol(&win->
buffer, symbol, bounds, sym_background, symbol_color,
24606 1.0f, style->
font);
24612 return nk_combo_begin(ctx, win, size, is_clicked, header);
24626 struct nk_color symbol_color;
24636 style = &ctx->
style;
24642 is_clicked = nk_true;
24659 text.background =
nk_rgba(0,0,0,0);
24662 text.background = background->
data.
color;
24675 else if (is_clicked)
24683 button.h = button.w;
24697 nk_draw_symbol(&win->
buffer, symbol, image, text.background, symbol_color,
24698 1.0f, style->
font);
24708 return nk_combo_begin(ctx, win, size, is_clicked, header);
24729 style = &ctx->
style;
24736 is_clicked = nk_true;
24752 struct nk_rect bounds = {0,0,0,0};
24759 else if (is_clicked)
24767 button.h = button.w;
24785 return nk_combo_begin(ctx, win, size, is_clicked, header);
24808 style = &ctx->
style;
24814 is_clicked = nk_true;
24828 text.background =
nk_rgba(0,0,0,0);
24831 text.background = background->
data.
color;
24844 else if (is_clicked)
24852 button.h = button.w;
24876 return nk_combo_begin(ctx, win, size, is_clicked, header);
24891 nk_combo_item_text(
struct nk_context *ctx,
const char *text,
int len,nk_flags align)
24902 int len, nk_flags alignment)
24908 const char *text, nk_flags alignment)
24914 const char *text,
int len, nk_flags alignment)
24920 const char *label, nk_flags alignment)
24933 nk_combo(
struct nk_context *ctx,
const char **items,
int count,
24934 int selected,
int item_height,
struct nk_vec2 size)
24939 struct nk_vec2 window_padding;
24944 if (!ctx || !items ||!count)
24949 max_height = count * item_height + count * (int)item_spacing.y;
24950 max_height += (
int)item_spacing.y * 2 + (int)window_padding.y * 2;
24951 size.
y =
NK_MIN(size.
y, (
float)max_height);
24954 for (i = 0; i <
count; ++
i) {
24963 nk_combo_separator(
struct nk_context *ctx,
const char *items_separated_by_separator,
24964 int separator,
int selected,
int count,
int item_height,
struct nk_vec2 size)
24969 struct nk_vec2 window_padding;
24970 const char *current_item;
24975 NK_ASSERT(items_separated_by_separator);
24976 if (!ctx || !items_separated_by_separator)
24982 max_height = count * item_height + count * (int)item_spacing.y;
24983 max_height += (
int)item_spacing.y * 2 + (int)window_padding.y * 2;
24984 size.
y =
NK_MIN(size.
y, (
float)max_height);
24987 current_item = items_separated_by_separator;
24988 for (i = 0; i <
count; ++
i) {
24989 iter = current_item;
24990 while (*iter && *iter != separator) iter++;
24991 length = (int)(iter - current_item);
24992 if (i == selected)
break;
24993 current_item = iter + 1;
24997 current_item = items_separated_by_separator;
24999 for (i = 0; i <
count; ++
i) {
25000 iter = current_item;
25001 while (*iter && *iter != separator) iter++;
25002 length = (int)(iter - current_item);
25005 current_item = current_item + length + 1;
25012 nk_combo_string(
struct nk_context *ctx,
const char *items_separated_by_zeros,
25013 int selected,
int count,
int item_height,
struct nk_vec2 size)
25015 return nk_combo_separator(ctx, items_separated_by_zeros,
'\0', selected, count, item_height, size);
25018 nk_combo_callback(
struct nk_context *ctx,
void(*item_getter)(
void*,
int,
const char**),
25019 void *userdata,
int selected,
int count,
int item_height,
struct nk_vec2 size)
25024 struct nk_vec2 window_padding;
25028 NK_ASSERT(item_getter);
25029 if (!ctx || !item_getter)
25035 max_height = count * item_height + count * (int)item_spacing.y;
25036 max_height += (
int)item_spacing.y * 2 + (int)window_padding.y * 2;
25037 size.
y =
NK_MIN(size.
y, (
float)max_height);
25039 item_getter(userdata, selected, &item);
25042 for (i = 0; i <
count; ++
i) {
25043 item_getter(userdata, i, &item);
25051 nk_combobox(
struct nk_context *ctx,
const char **items,
int count,
25052 int *selected,
int item_height,
struct nk_vec2 size)
25054 *selected =
nk_combo(ctx, items, count, *selected, item_height, size);
25058 int *selected,
int count,
int item_height,
struct nk_vec2 size)
25060 *selected =
nk_combo_string(ctx, items_separated_by_zeros, *selected, count, item_height, size);
25064 int separator,
int *selected,
int count,
int item_height,
struct nk_vec2 size)
25067 *selected, count, item_height, size);
25071 void(*item_getter)(
void* data,
int id,
const char **out_text),
25072 void *userdata,
int *selected,
int count,
int item_height,
struct nk_vec2 size)
25074 *selected =
nk_combo_callback(ctx, item_getter, userdata, *selected, count, item_height, size);
25107 w = nk_iceilf(width);
25108 h = nk_iceilf(nk_null_rect.h);
25112 bounds.
x = (
float)
x;
25113 bounds.
y = (float)y;
25114 bounds.
w = (float)w;
25115 bounds.
h = (float)h;
25130 if (!ctx || !ctx->
current)
return;
25136 nk_tooltip(
struct nk_context *ctx,
const char *text)
25153 style = &ctx->
style;
25160 text_width += (4 * padding.
x);
25161 text_height = (style->
font->
height + 2 * padding.
y);
25170 #ifdef NK_INCLUDE_STANDARD_VARARGS 25172 nk_tooltipf(
struct nk_context *ctx,
const char *fmt, ...)
25175 va_start(args, fmt);
25176 nk_tooltipfv(ctx, fmt, args);
25180 nk_tooltipfv(
struct nk_context *ctx,
const char *fmt, va_list args)
25183 nk_strfmt(buf,
NK_LEN(buf), fmt, args);
void(* draw_begin)(struct nk_command_buffer *, nk_handle)
NK_API struct nk_color nk_rgb_iv(const int *rgb)
NK_API int nk_menu_item_text(struct nk_context *, const char *, int, nk_flags align)
struct nk_style_item hover
struct nk_style_item hover_active
NK_API int nk_window_has_focus(const struct nk_context *)
NK_API int nk_menu_item_symbol_text(struct nk_context *, enum nk_symbol_type, const char *, int, nk_flags alignment)
struct nk_style_button dec_button
NK_API struct nk_rect nk_rectv(const float *xywh)
#define NK_CONFIG_STACK(type, size)
struct nk_style_item cursor_hover
NK_API int nk_input_mouse_clicked(const struct nk_input *, enum nk_buttons, struct nk_rect)
struct nk_style_item active
NK_API int nk_select_text(struct nk_context *, const char *, int, nk_flags align, int value)
NK_API int nk_tree_state_image_push(struct nk_context *, enum nk_tree_type, struct nk_image, const char *title, enum nk_collapse_states *state)
NK_API struct nk_color nk_rgba_bv(const nk_byte *rgba)
NK_API int nk_contextual_item_image_text(struct nk_context *, struct nk_image, const char *, int len, nk_flags alignment)
NK_API void nk_textedit_select_all(struct nk_text_edit *)
NK_API int nk_button_symbol_label_styled(struct nk_context *ctx, const struct nk_style_button *style, enum nk_symbol_type symbol, const char *title, nk_flags align)
NK_API int nk_contextual_begin(struct nk_context *, nk_flags, struct nk_vec2, struct nk_rect trigger_bounds)
struct nk_color text_hover
static const ImVec4 white
struct nk_style_item cursor_normal
NK_API void nk_color_hex_rgb(char *output, struct nk_color)
NK_API struct nk_rect nk_get_null_rect(void)
nk_buffer_allocation_type
NK_API int nk_begin(struct nk_context *ctx, const char *title, struct nk_rect bounds, nk_flags flags)
GLboolean GLboolean GLboolean b
NK_API int nk_contextual_item_symbol_text(struct nk_context *, enum nk_symbol_type, const char *, int, nk_flags alignment)
NK_API int nk_filter_default(const struct nk_text_edit *, nk_rune unicode)
NK_API void nk_stroke_circle(struct nk_command_buffer *, struct nk_rect, float line_thickness, struct nk_color)
NK_API struct nk_vec2 nk_vec2i(int x, int y)
struct nk_vec2 contextual_padding
NK_API int nk_utf_decode(const char *, nk_rune *, int)
struct nk_style_button menu_button
NK_API struct nk_color nk_rgba_u32(nk_uint)
float(* nk_text_width_f)(nk_handle, float h, const char *, int len)
NK_API int nk_filter_hex(const struct nk_text_edit *, nk_rune unicode)
NK_API int nk_menu_item_image_text(struct nk_context *, struct nk_image, const char *, int len, nk_flags alignment)
NK_API void nk_buffer_init(struct nk_buffer *, const struct nk_allocator *, nk_size size)
NK_API int nk_button_color(struct nk_context *, struct nk_color)
NK_API int nk_select_image_text(struct nk_context *, struct nk_image, const char *, int, nk_flags align, int value)
NK_API struct nk_window * nk_window_find(struct nk_context *ctx, const char *name)
NK_API void nk_str_remove_chars(struct nk_str *, int len)
NK_API int nk_widget_is_hovered(struct nk_context *)
#define NK_FLAGS_STACK_SIZE
NK_API void nk_layout_row_end(struct nk_context *)
NK_API void nk_fill_circle(struct nk_command_buffer *, struct nk_rect, struct nk_color)
#define nk_zero_struct(s)
boost_foreach_argument_dependent_lookup_hack tag
GLenum GLenum GLsizei void * row
enum nk_symbol_type sym_left
struct nk_config_stack_button_behavior button_behaviors
typedef void(APIENTRY *GLDEBUGPROC)(GLenum source
struct nk_color selected_text_hover
NK_API int nk_combo_callback(struct nk_context *, void(*item_getter)(void *, int, const char **), void *userdata, int selected, int count, int item_height, struct nk_vec2 size)
NK_API int nk_input_is_mouse_click_down_in_rect(const struct nk_input *i, enum nk_buttons id, struct nk_rect b, int down)
NK_API void nk_colorf_hsva_fv(float *hsva, struct nk_colorf in)
GLuint const GLchar * name
NK_API void nk_str_init_fixed(struct nk_str *, void *memory, nk_size size)
NK_API int nk_popup_begin(struct nk_context *, enum nk_popup_type, const char *, nk_flags, struct nk_rect bounds)
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_API void nk_layout_row_template_push_variable(struct nk_context *, float min_width)
struct nk_vec2 touch_padding
NK_API int nk_button_text_styled(struct nk_context *, const struct nk_style_button *, const char *title, int len)
unsigned short line_thickness
struct nk_style_button node_maximize_button
NK_API void nk_layout_row_template_push_static(struct nk_context *, float width)
NK_API void nk_color_hsv_iv(int *hsv_out, struct nk_color)
struct nk_vec2 tooltip_padding
NK_API void nk_combobox_callback(struct nk_context *, void(*item_getter)(void *, int, const char **), void *, int *selected, int count, int item_height, struct nk_vec2 size)
NK_API int nk_combo_item_text(struct nk_context *, const char *, int, nk_flags alignment)
NK_API nk_flags nk_edit_string_zero_terminated(struct nk_context *, nk_flags, char *buffer, int max, nk_plugin_filter)
struct nk_window * current
NK_API void nk_text(struct nk_context *, const char *, int, nk_flags)
nk_uint values[NK_VALUE_PAGE_CAPACITY]
NK_API int nk_select_label(struct nk_context *, const char *, nk_flags align, int value)
NK_API int nk_menu_item_label(struct nk_context *, const char *, nk_flags alignment)
GLdouble GLdouble GLdouble top
NK_API struct nk_rect nk_layout_widget_bounds(struct nk_context *)
struct nk_color selected_text_normal
NK_API int nk_button_symbol_styled(struct nk_context *, const struct nk_style_button *, enum nk_symbol_type)
struct nk_chart_slot slots[NK_CHART_MAX_SLOT]
struct nk_color text_normal_active
char nk_glyph[NK_UTF_SIZE]
NK_API struct nk_rect nk_layout_space_rect_to_local(struct nk_context *, struct nk_rect)
NK_API struct nk_color nk_hsv(int h, int s, int v)
struct nk_color tooltip_border_color
struct nk_vec2 image_padding
struct nk_vec2 cursor_size
struct nk_color group_border_color
struct nk_style_item scaler
NK_API void nk_edit_focus(struct nk_context *, nk_flags flags)
unsigned short point_count
#define NK_MAX_FLOAT_PRECISION
#define NK_MAX_NUMBER_BUFFER
NK_API struct nk_color nk_hsv_fv(const float *hsv)
NK_API struct nk_style_item nk_style_item_image(struct nk_image img)
NK_API int nk_widget_is_mouse_clicked(struct nk_context *, enum nk_buttons)
struct nk_color bar_hover
struct nk_style_progress progress
NK_API void nk_window_collapse(struct nk_context *, const char *name, enum nk_collapse_states state)
NK_API void nk_button_set_behavior(struct nk_context *, enum nk_button_behavior)
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t0
NK_API void nk_group_end(struct nk_context *)
NK_API int nk_input_is_key_pressed(const struct nk_input *, enum nk_keys)
unsigned short point_count
struct nk_style_item normal
GLenum GLenum GLenum GLenum GLenum scale
static GLFWwindow * window
unsigned short line_thickness
struct nk_property_state property
GLdouble GLdouble GLdouble y2
NK_API void nk_layout_space_end(struct nk_context *)
struct nk_style_item active
struct nk_style_item cursor_hover
struct nk_color border_color
struct nk_color text_pressed
NK_API void nk_layout_row_template_push_dynamic(struct nk_context *)
struct nk_page_element * freelist
GLuint64 GLenum void * handle
struct nk_style_selectable selectable
NK_API int nk_str_insert_str_runes(struct nk_str *, int pos, const nk_rune *)
void(* draw_begin)(struct nk_command_buffer *, nk_handle)
GLsizei const GLint * box
enum nk_symbol_type sym_minimize
struct nk_style_button inc_button
struct nk_style_window window
GLsizei const GLchar *const * path
NK_API void nk_stroke_triangle(struct nk_command_buffer *, float, float, float, float, float, float, float line_thichness, struct nk_color)
unsigned short line_thickness
struct nk_color border_color
struct nk_color text_normal
struct nk_style_button contextual_button
NK_API void nk_label_wrap(struct nk_context *, const char *)
NK_API struct nk_color nk_hsv_bv(const nk_byte *hsv)
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat s0
NK_API int nk_strmatch_fuzzy_text(const char *txt, int txt_len, const char *pattern, int *out_score)
NK_API void nk_window_set_focus(struct nk_context *, const char *name)
NK_API void nk_str_delete_runes(struct nk_str *, int pos, int len)
NK_API struct nk_color nk_hsva_bv(const nk_byte *hsva)
NK_API int nk_utf_encode(nk_rune, char *, int)
NK_API void nk_color_hsv_f(float *out_h, float *out_s, float *out_v, struct nk_color)
NK_API int nk_str_append_text_char(struct nk_str *, const char *, int)
struct nk_color border_color
NK_API struct nk_colorf nk_hsva_colorfv(float *c)
NK_API void nk_fill_rect_multi_color(struct nk_command_buffer *, struct nk_rect, struct nk_color left, struct nk_color top, struct nk_color right, struct nk_color bottom)
NK_API void nk_list_view_end(struct nk_list_view *)
NK_API struct nk_vec2 nk_layout_space_to_local(struct nk_context *, struct nk_vec2)
NK_API char * nk_str_at_rune(struct nk_str *, int pos, nk_rune *unicode, int *len)
struct nk_mouse_button buttons[NK_BUTTON_MAX]
unsigned char has_preferred_x
NK_API struct nk_rect nk_layout_space_rect_to_screen(struct nk_context *, struct nk_rect)
struct nk_window * parent
union nk_style_item_data data
NK_API nk_uint nk_color_u32(struct nk_color)
NK_API struct nk_vec2 nk_widget_position(struct nk_context *)
struct nk_color background
NK_API int nk_button_symbol_text(struct nk_context *, enum nk_symbol_type, const char *, int, nk_flags alignment)
NK_API int nk_filter_ascii(const struct nk_text_edit *, nk_rune unicode)
NK_API int nk_contextual_item_text(struct nk_context *, const char *, int, nk_flags align)
struct nk_page_element * next
NK_API int nk_str_insert_text_char(struct nk_str *, int pos, const char *, int)
struct nk_window * active
struct nk_color highlight
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t1
struct nk_style_text text
struct nk_color text_pressed_active
struct nk_color label_normal
struct nk_color combo_border_color
NK_API void nk_textedit_text(struct nk_text_edit *, const char *, int total_len)
NK_API void nk_str_delete_chars(struct nk_str *, int pos, int len)
struct nk_allocator alloc
NK_API int nk_str_append_text_runes(struct nk_str *, const nk_rune *, int)
nk_command_custom_callback callback
NK_API void nk_color_f(float *r, float *g, float *b, float *a, struct nk_color)
NK_API void nk_color_hsv_bv(nk_byte *hsv_out, struct nk_color)
struct nk_vec2 scrollbar_size
NK_API int nk_strtoi(const char *str, const char **endptr)
enum nk_symbol_type sym_normal
struct nk_style_item cursor_hover
struct nk_key keys[NK_KEY_MAX]
NK_API struct nk_style_item nk_style_item_hide(void)
NK_API int nk_combo_item_symbol_text(struct nk_context *, enum nk_symbol_type, const char *, int, nk_flags alignment)
unsigned short line_thickness
NK_API void nk_label(struct nk_context *, const char *, nk_flags align)
NK_API int nk_style_set_cursor(struct nk_context *, enum nk_style_cursor)
NK_API const struct nk_command * nk__next(struct nk_context *, const struct nk_command *)
NK_API int nk_stricmp(const char *s1, const char *s2)
NK_API int nk_str_insert_at_rune(struct nk_str *, int pos, const char *, int)
NK_API void nk_plot(struct nk_context *, enum nk_chart_type, const float *values, int count, int offset)
unsigned curve_segment_count
GLdouble GLdouble GLdouble w
NK_API void nk_contextual_end(struct nk_context *)
GLsizei const GLchar *const * string
NK_API int nk_combo_item_symbol_label(struct nk_context *, enum nk_symbol_type, const char *, nk_flags alignment)
std_msgs::Header * header(M &m)
returns Header<M>::pointer(m);
struct nk_command_buffer overlay
NK_API int nk_progress(struct nk_context *, nk_size *cur, nk_size max, int modifyable)
void checkbox(const char *id, T *val, S T::*f, bool &to_set)
struct nk_style_item normal
struct nk_style_item active
struct nk_style_edit edit
NK_API int nk_window_is_any_hovered(struct nk_context *)
NK_API struct nk_vec2 nk_vec2iv(const int *xy)
unsigned char cursor_at_end_of_line
NK_API int nk_combo_begin_text(struct nk_context *, const char *selected, int, struct nk_vec2 size)
#define NK_BUTTON_BEHAVIOR_STACK_SIZE
struct nk_style_button dec_button
NK_API void nk_input_glyph(struct nk_context *, const nk_glyph)
struct nk_style_item pressed_active
void(* nk_plugin_paste)(nk_handle, struct nk_text_edit *)
GLfloat GLfloat GLfloat GLfloat h
GLuint GLuint GLfloat weight
NK_API struct nk_vec2 nk_layout_space_to_screen(struct nk_context *, struct nk_vec2)
NK_API int nk_style_pop_float(struct nk_context *)
void(* draw_end)(struct nk_command_buffer *, nk_handle)
NK_API struct nk_rect nk_layout_space_bounds(struct nk_context *)
float min_row_height_padding
NK_API int nk_button_image_text_styled(struct nk_context *, const struct nk_style_button *, struct nk_image img, const char *, int, nk_flags alignment)
NK_API int nk_init_custom(struct nk_context *, struct nk_buffer *cmds, struct nk_buffer *pool, const struct nk_user_font *)
struct nk_vec2i points[1]
struct nk_color border_color
NK_API int nk_select_symbol_text(struct nk_context *, enum nk_symbol_type, const char *, int, nk_flags align, int value)
NK_API enum nk_widget_layout_states nk_widget_fitting(struct nk_rect *, struct nk_context *, struct nk_vec2)
NK_API double nk_strtod(const char *str, const char **endptr)
NK_API void nk_window_close(struct nk_context *ctx, const char *name)
int(* nk_plugin_filter)(const struct nk_text_edit *, nk_rune unicode)
NK_API void nk_style_default(struct nk_context *)
NK_API void nk_input_scroll(struct nk_context *, struct nk_vec2 val)
NK_API int nk_input_has_mouse_click_down_in_rect(const struct nk_input *, enum nk_buttons, struct nk_rect, int down)
#define NK_FLOAT_STACK_SIZE
NK_API void nk_free(struct nk_context *)
struct nk_color text_normal
unsigned short point_count
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
NK_API char * nk_str_at_char(struct nk_str *, int pos)
NK_API int nk_button_label_styled(struct nk_context *, const struct nk_style_button *, const char *title)
NK_API struct nk_color nk_rgb(int r, int g, int b)
NK_API int nk_tree_push_hashed(struct nk_context *, enum nk_tree_type, const char *title, enum nk_collapse_states initial_state, const char *hash, int len, int seed)
enum nk_symbol_type sym_active
NK_API void nk_layout_space_push(struct nk_context *, struct nk_rect bounds)
NK_API void nk_combobox_separator(struct nk_context *, const char *items_separated_by_separator, int separator, int *selected, int count, int item_height, struct nk_vec2 size)
unsigned int has_scrolling
NK_API void nk_tree_state_pop(struct nk_context *)
NK_API int nk_combo_begin_label(struct nk_context *, const char *selected, struct nk_vec2 size)
NK_API int nk_stricmpn(const char *s1, const char *s2, int n)
GLenum GLenum GLsizei void * image
NK_API int nk_style_push_flags(struct nk_context *, nk_flags *, nk_flags)
struct nk_style_item active
NK_API void nk_window_collapse_if(struct nk_context *, const char *name, enum nk_collapse_states, int cond)
struct nk_vec2 button_padding
NK_API void nk_layout_reset_min_row_height(struct nk_context *)
NK_API struct nk_colorf nk_color_cf(struct nk_color)
float templates[NK_MAX_LAYOUT_ROW_TEMPLATE_COLUMNS]
NK_API void nk_buffer_push(struct nk_buffer *, enum nk_buffer_allocation_type type, const void *memory, nk_size size, nk_size align)
NK_API struct nk_vec2 nk_window_get_position(const struct nk_context *ctx)
NK_API void nk_color_fv(float *rgba_out, struct nk_color)
NK_API int nk_input_is_mouse_prev_hovering_rect(const struct nk_input *, struct nk_rect)
unsigned arc_segment_count
GLboolean GLboolean GLboolean GLboolean a
void(* draw_end)(struct nk_command_buffer *, nk_handle)
NK_API void nk_layout_row_static(struct nk_context *ctx, float height, int item_width, int cols)
GLenum GLuint GLenum GLsizei const GLchar * buf
const struct nk_cursor * cursor_active
unsigned circle_segment_count
enum nk_symbol_type dec_symbol
def info(name, value, persistent=False)
struct nk_style_button button
struct nk_style_scrollbar scrollh
NK_API int nk_input_is_mouse_click_in_rect(const struct nk_input *, enum nk_buttons, struct nk_rect)
GLenum const void GLbitfield GLsizei numGlyphs
NK_API void nk_group_scrolled_end(struct nk_context *)
NK_API int nk_contextual_item_symbol_label(struct nk_context *, enum nk_symbol_type, const char *, nk_flags alignment)
unsigned char single_line
struct nk_color foreground
NK_API void nk_layout_set_min_row_height(struct nk_context *, float height)
struct nk_style_item normal
NK_API struct nk_vec2 nk_vec2(float x, float y)
NK_API void nk_menubar_end(struct nk_context *)
struct nk_vec2 scrollbar_size
NK_API void nk_buffer_mark(struct nk_buffer *, enum nk_buffer_allocation_type type)
#define NK_WINDOW_MAX_NAME
struct nk_config_stack_user_font fonts
NK_API int nk_combo_begin_symbol(struct nk_context *, enum nk_symbol_type, struct nk_vec2 size)
NK_API void nk_image(struct nk_context *, struct nk_image)
#define NK_VECTOR_STACK_SIZE
NK_API void nk_layout_row_dynamic(struct nk_context *ctx, float height, int cols)
NK_API int nk_strlen(const char *str)
struct nk_style_item normal
NK_API void nk_tree_element_pop(struct nk_context *)
NK_API float nk_strtof(const char *str, const char **endptr)
struct nk_color bar_active
struct nk_color cursor_text_normal
NK_API struct nk_color nk_rgb_fv(const float *rgb)
NK_API int nk_color_pick(struct nk_context *, struct nk_colorf *, enum nk_color_format)
NK_API int nk_window_is_collapsed(struct nk_context *ctx, const char *name)
NK_API void nk_draw_text(struct nk_command_buffer *, struct nk_rect, const char *text, int len, const struct nk_user_font *, struct nk_color, struct nk_color)
enum nk_allocation_type type
GLfloat GLfloat GLfloat alpha
NK_API struct nk_color nk_hsva_iv(const int *hsva)
NK_API void nk_combobox(struct nk_context *, const char **items, int count, int *selected, int item_height, struct nk_vec2 size)
struct nk_scroll scrollbar
NK_API void nk_buffer_reset(struct nk_buffer *, enum nk_buffer_allocation_type type)
NK_API int nk_str_insert_text_runes(struct nk_str *, int pos, const nk_rune *, int)
enum nk_symbol_type sym_maximize
void(* nk_command_custom_callback)(void *canvas, short x, short y, unsigned short w, unsigned short h, nk_handle callback_data)
NK_API void nk_textedit_delete_selection(struct nk_text_edit *)
NK_API void nk_color_hsva_bv(nk_byte *hsva_out, struct nk_color)
NK_API struct nk_color nk_rgba(int r, int g, int b, int a)
NK_API void * nk_buffer_memory(struct nk_buffer *)
NK_API void nk_textedit_init_fixed(struct nk_text_edit *, void *memory, nk_size size)
NK_API int nk_init_fixed(struct nk_context *, void *memory, nk_size size, const struct nk_user_font *)
struct nk_style_slider slider
struct nk_color label_active
NK_API void nk_stroke_curve(struct nk_command_buffer *, float, float, float, float, float, float, float, float, float line_thickness, struct nk_color)
NK_API int nk_button_image(struct nk_context *, struct nk_image img)
NK_API struct nk_image nk_subimage_handle(nk_handle, unsigned short w, unsigned short h, struct nk_rect sub_region)
NK_API int nk_combo(struct nk_context *, const char **items, int count, int selected, int item_height, struct nk_vec2 size)
NK_API struct nk_color nk_rgba_f(float r, float g, float b, float a)
NK_API void nk_str_clear(struct nk_str *)
#define NK_TEXTEDIT_UNDOCHARCOUNT
NK_API const void * nk_buffer_memory_const(const struct nk_buffer *)
#define nk_ptr_add_const(t, p, i)
NK_API void nk_buffer_init_fixed(struct nk_buffer *, void *memory, nk_size size)
NK_API void nk_layout_row_template_begin(struct nk_context *, float row_height)
NK_API void nk_popup_close(struct nk_context *)
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)
struct nk_page_element * freelist
struct nk_vec2 combo_padding
NK_API int nk_str_append_text_utf8(struct nk_str *, const char *, int)
struct nk_color text_hover
NK_API void nk_text_colored(struct nk_context *, const char *, int, nk_flags, struct nk_color)
GLenum GLint GLint * precision
NK_API int nk_checkbox_flags_text(struct nk_context *, const char *, int, unsigned int *flags, unsigned int value)
NK_API int nk_button_image_styled(struct nk_context *, const struct nk_style_button *, struct nk_image img)
unsigned short line_thickness
NK_API struct nk_rect nk_rect(float x, float y, float w, float h)
NK_API void nk_style_show_cursor(struct nk_context *)
struct nk_style_scrollbar scrollv
NK_API void nk_chart_add_slot_colored(struct nk_context *ctx, const enum nk_chart_type, struct nk_color, struct nk_color active, int count, float min_value, float max_value)
NK_API struct nk_colorf nk_color_picker(struct nk_context *, struct nk_colorf, enum nk_color_format)
NK_API int nk_style_push_font(struct nk_context *, const struct nk_user_font *)
enum nk_anti_aliasing line_AA
NK_API int nk_group_scrolled_offset_begin(struct nk_context *, nk_uint *x_offset, nk_uint *y_offset, const char *title, nk_flags flags)
NK_API int nk_tree_element_image_push_hashed(struct nk_context *, enum nk_tree_type, struct nk_image, const char *title, enum nk_collapse_states initial_state, int *selected, const char *hash, int len, int seed)
NK_API const char * nk_utf_at(const char *buffer, int length, int index, nk_rune *unicode, int *len)
NK_API int nk_chart_begin_colored(struct nk_context *, enum nk_chart_type, struct nk_color, struct nk_color active, int num, float min, float max)
NK_API void nk_style_hide_cursor(struct nk_context *)
NK_API int nk_menu_begin_image_text(struct nk_context *, const char *, int, nk_flags align, struct nk_image, struct nk_vec2 size)
struct nk_color border_color
NK_API void nk_str_remove_runes(struct nk_str *str, int len)
#define NK_ALIGN_PTR(x, mask)
NK_API int nk_widget_has_mouse_click_down(struct nk_context *, enum nk_buttons, int down)
#define NK_CLAMP(i, v, x)
struct nk_style_combo combo
struct nk_style_property property
NK_API void nk_input_begin(struct nk_context *)
struct nk_color contextual_border_color
NK_API int nk_option_text(struct nk_context *, const char *, int, int active)
struct nk_menu_state menu
NK_API void nk_stroke_rect(struct nk_command_buffer *, struct nk_rect, float rounding, float line_thickness, struct nk_color)
NK_API int nk_menu_begin_symbol_text(struct nk_context *, const char *, int, nk_flags align, enum nk_symbol_type, struct nk_vec2 size)
NK_API void nk_push_scissor(struct nk_command_buffer *, struct nk_rect)
NK_API const struct nk_command * nk__begin(struct nk_context *)
void(* draw_begin)(struct nk_command_buffer *, nk_handle)
NK_API nk_flags nk_chart_push_slot(struct nk_context *, float, int)
#define NK_INBOX(px, py, x, y, w, h)
#define nk_vec2_sub(a, b)
GLint GLsizei GLsizei height
NK_API int nk_str_append_str_char(struct nk_str *, const char *)
static const textual_icon edit
struct nk_color selected_color
unsigned char initialized
NK_API int nk_input_is_key_down(const struct nk_input *, enum nk_keys)
NK_API int nk_window_is_hovered(struct nk_context *)
GLsizei GLenum GLsizei GLsizei GLuint memory
NK_API double nk_propertyd(struct nk_context *, const char *name, double min, double val, double max, double step, float inc_per_pixel)
struct nk_cursor * cursor_last
GLint GLint GLsizei GLint GLenum format
NK_API int nk_filter_decimal(const struct nk_text_edit *, nk_rune unicode)
NK_API int nk_filter_binary(const struct nk_text_edit *, nk_rune unicode)
NK_API int nk_init(struct nk_context *, struct nk_allocator *, const struct nk_user_font *)
NK_API int nk_radio_label(struct nk_context *, const char *, int *active)
NK_API void nk_contextual_close(struct nk_context *)
NK_API int nk_input_has_mouse_click_in_rect(const struct nk_input *, enum nk_buttons, struct nk_rect)
NK_API void nk_textedit_init(struct nk_text_edit *, struct nk_allocator *, nk_size size)
const struct nk_cursor * cursors[NK_CURSOR_COUNT]
const struct nk_draw_vertex_layout_element * vertex_layout
struct nk_style_chart chart
struct nk_vec2 popup_padding
NK_API void nk_layout_row_begin(struct nk_context *ctx, enum nk_layout_format fmt, float row_height, int cols)
NK_API void nk_fill_arc(struct nk_command_buffer *, float cx, float cy, float radius, float a_min, float a_max, struct nk_color)
NK_API const char * nk_str_get_const(const struct nk_str *)
NK_API int nk_textedit_cut(struct nk_text_edit *)
NK_API void nk_property_double(struct nk_context *, const char *name, double min, double *val, double max, double step, float inc_per_pixel)
struct nk_color cursor_text_hover
NK_API int nk_button_image_label_styled(struct nk_context *, const struct nk_style_button *, struct nk_image img, const char *, nk_flags text_alignment)
NK_API int nk_combo_separator(struct nk_context *, const char *items_separated_by_separator, int separator, int selected, int count, int item_height, struct nk_vec2 size)
NK_API void nk_color_hsva_i(int *h, int *s, int *v, int *a, struct nk_color)
NK_API void nk_stroke_polyline(struct nk_command_buffer *, float *points, int point_count, float line_thickness, struct nk_color col)
NK_API void nk_text_wrap_colored(struct nk_context *, const char *, int, struct nk_color)
NK_API enum nk_widget_layout_states nk_widget(struct nk_rect *, const struct nk_context *)
NK_API struct nk_vec2 nk_rect_pos(struct nk_rect)
struct nk_text_undo_state undo
NK_API int nk_input_is_mouse_released(const struct nk_input *, enum nk_buttons)
NK_API void nk_property_int(struct nk_context *, const char *name, int min, int *val, int max, int step, float inc_per_pixel)
struct nk_style_button button
#define NK_SCROLLBAR_HIDING_TIMEOUT
enum nk_symbol_type sym_right
NK_API struct nk_colorf nk_hsva_colorf(float h, float s, float v, float a)
NK_API void nk_color_hex_rgba(char *output, struct nk_color)
struct nk_vec2 group_padding
NK_API void nk_style_load_cursor(struct nk_context *, enum nk_style_cursor, const struct nk_cursor *)
NK_API int nk_select_symbol_label(struct nk_context *, enum nk_symbol_type, const char *, nk_flags align, int value)
NK_API int nk_input_is_mouse_pressed(const struct nk_input *, enum nk_buttons)
struct nk_style_item cursor_normal
#define NK_VALUE_PAGE_CAPACITY
NK_API void nk_push_custom(struct nk_command_buffer *, struct nk_rect, nk_command_custom_callback, nk_handle usr)
NK_API int nk_str_len_char(struct nk_str *)
NK_API int nk_input_any_mouse_click_in_rect(const struct nk_input *, struct nk_rect)
NK_API const char * nk_style_get_color_by_name(enum nk_style_colors)
NK_API void nk_stroke_arc(struct nk_command_buffer *, float cx, float cy, float radius, float a_min, float a_max, float line_thickness, struct nk_color)
NK_API void nk_tooltip_end(struct nk_context *)
struct nk_color border_color
struct nk_style_item cursor_normal
NK_API void nk_spacing(struct nk_context *, int cols)
GLdouble GLdouble GLint stride
NK_API struct nk_color nk_rgba_hex(const char *rgb)
struct nk_vec2i points[1]
struct nk_style_item active
NK_API int nk_button_symbol_label(struct nk_context *, enum nk_symbol_type, const char *, nk_flags text_alignment)
#define NK_STATIC_ASSERT(exp)
static std::string custom
NK_API struct nk_image nk_subimage_ptr(void *, unsigned short w, unsigned short h, struct nk_rect sub_region)
NK_API void nk_text_wrap(struct nk_context *, const char *, int)
NK_API struct nk_image nk_image_handle(nk_handle)
NK_API struct nk_image nk_image_ptr(void *)
NK_API float nk_window_get_width(const struct nk_context *)
NK_API int nk_image_is_subimage(const struct nk_image *img)
struct nk_style_item hover
NK_API void nk_draw_image(struct nk_command_buffer *, struct nk_rect, const struct nk_image *, struct nk_color)
struct nk_color text_hover_active
NK_API int nk_selectable_label(struct nk_context *, const char *, nk_flags align, int *value)
struct nk_style_button tab_minimize_button
NK_API struct nk_color nk_hsva(int h, int s, int v, int a)
#define NK_STYLE_ITEM_STACK_SIZE
NK_API int nk_str_insert_text_utf8(struct nk_str *, int pos, const char *, int)
NK_API void nk_tooltip(struct nk_context *, const char *)
struct nk_color text_active
#define NK_MAX_LAYOUT_ROW_TEMPLATE_COLUMNS
NK_API void nk_combo_close(struct nk_context *)
struct nk_color text_hover
NK_API int nk_radio_text(struct nk_context *, const char *, int, int *active)
NK_API void nk_buffer_clear(struct nk_buffer *)
enum nk_symbol_type sym_hover
void *(* nk_plugin_alloc)(nk_handle, void *old, nk_size)
NK_API struct nk_vec2 nk_window_get_size(const struct nk_context *)
struct nk_color label_hover
NK_API const char * nk_str_at_char_const(const struct nk_str *, int pos)
struct nk_configuration_stacks stacks
GLint GLint GLsizei GLint GLenum GLenum const void * pixels
NK_API nk_handle nk_handle_id(int)
NK_API int nk_combo_item_image_label(struct nk_context *, struct nk_image, const char *, nk_flags alignment)
NK_API struct nk_color nk_rgb_f(float r, float g, float b)
enum nk_allocation_type type
struct nk_color symbol_hover
NK_API int nk_contextual_item_label(struct nk_context *, const char *, nk_flags align)
#define NK_CONFIGURATION_STACK_TYPE(prefix, name, type)
NK_API int nk_list_view_begin(struct nk_context *, struct nk_list_view *out, const char *id, nk_flags, int row_height, int row_count)
NK_API void nk_stroke_polygon(struct nk_command_buffer *, float *, int point_count, float line_thickness, struct nk_color)
NK_API void nk_popup_end(struct nk_context *)
NK_API void nk_input_motion(struct nk_context *, int x, int y)
NK_API int nk_textedit_paste(struct nk_text_edit *, char const *, int len)
NK_API int nk_utf_len(const char *, int byte_len)
NK_API void nk_triangle_from_direction(struct nk_vec2 *result, struct nk_rect r, float pad_x, float pad_y, enum nk_heading)
NK_API struct nk_color nk_hsva_fv(const float *hsva)
static const ImVec4 black
enum nk_symbol_type inc_symbol
NK_API void nk_color_hsva_b(nk_byte *h, nk_byte *s, nk_byte *v, nk_byte *a, struct nk_color)
#define NK_TEXTEDIT_UNDOSTATECOUNT
float dot(float3 const &a, float3 const &b)
NK_API void nk_chart_add_slot(struct nk_context *ctx, const enum nk_chart_type, int count, float min_value, float max_value)
struct nk_style_scrollbar scrollbar
struct nk_color bar_normal
nk_flags last_widget_state
#define nk_foreach(c, ctx)
struct nk_style_item normal_active
NK_API float nk_window_get_height(const struct nk_context *)
NK_API float nk_widget_height(struct nk_context *)
NK_API int nk_menu_item_image_label(struct nk_context *, struct nk_image, const char *, nk_flags alignment)
NK_API int nk_slide_int(struct nk_context *, int min, int val, int max, int step)
NK_API int nk_filter_oct(const struct nk_text_edit *, nk_rune unicode)
NK_API struct nk_rect nk_recta(struct nk_vec2 pos, struct nk_vec2 size)
NK_API int nk_slider_float(struct nk_context *, float min, float *val, float max, float step)
NK_API int nk_window_is_hidden(struct nk_context *, const char *)
NK_API void nk_fill_triangle(struct nk_command_buffer *, float x0, float y0, float x1, float y1, float x2, float y2, struct nk_color)
GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint GLdouble GLdouble w2
struct nk_command_buffer buffer
NK_API int nk_slider_int(struct nk_context *, int min, int *val, int max, int step)
NK_API int nk_contextual_item_image_label(struct nk_context *, struct nk_image, const char *, nk_flags alignment)
NK_API void nk_input_button(struct nk_context *, enum nk_buttons, int x, int y, int down)
NK_API int nk_item_is_any_active(struct nk_context *)
NK_API void nk_label_colored_wrap(struct nk_context *, const char *, struct nk_color)
struct nk_style_toggle checkbox
NK_API void nk_input_key(struct nk_context *, enum nk_keys, int down)
void(* nk_plugin_free)(nk_handle, void *old)
NK_API struct nk_style_item nk_style_item_color(struct nk_color)
NK_API void nk_fill_rect(struct nk_command_buffer *, struct nk_rect, float rounding, struct nk_color)
GLenum GLenum GLsizei void * table
NK_API int nk_button_push_behavior(struct nk_context *, enum nk_button_behavior)
#define nk_ptr_add(t, p, i)
NK_API float nk_slide_float(struct nk_context *, float min, float val, float max, float step)
NK_API void nk_color_hsva_fv(float *hsva_out, struct nk_color)
GLsizei const GLfloat * values
NK_API void nk_fill_polygon(struct nk_command_buffer *, float *, int point_count, struct nk_color)
NK_API int nk_selectable_symbol_label(struct nk_context *, enum nk_symbol_type, const char *, nk_flags align, int *value)
GLdouble GLdouble GLint GLint GLdouble v1
NK_API float nk_widget_width(struct nk_context *)
struct nk_color border_color
#define nk_vec2_add(a, b)
NK_API int nk_input_is_mouse_hovering_rect(const struct nk_input *, struct nk_rect)
NK_API int nk_chart_begin(struct nk_context *, enum nk_chart_type, int num, float min, float max)
void next(auto_any_t cur, type2type< T, C > *)
NK_API int nk_style_pop_vec2(struct nk_context *)
NK_API nk_size nk_buffer_total(struct nk_buffer *)
NK_API nk_handle nk_handle_ptr(void *)
struct nk_style_item cursor_active
NK_API void nk_window_show(struct nk_context *, const char *name, enum nk_show_states)
NK_API void nk_tree_pop(struct nk_context *)
const struct nk_user_font * font
NK_API void nk_textedit_undo(struct nk_text_edit *)
NK_API unsigned nk_check_flags_text(struct nk_context *, const char *, int, unsigned int flags, unsigned int value)
GLuint GLfloat GLfloat GLfloat x1
struct nk_popup_state popup
NK_API float nk_layout_ratio_from_pixel(struct nk_context *, float pixel_width)
NK_API nk_flags nk_edit_buffer(struct nk_context *, nk_flags, struct nk_text_edit *, nk_plugin_filter)
NK_API int nk_style_pop_style_item(struct nk_context *)
std::pair< T, T > in_range(T begin, T end)
NK_API int nk_checkbox_flags_label(struct nk_context *, const char *, unsigned int *flags, unsigned int value)
struct nk_color symbol_active
nk_rune undo_char[NK_TEXTEDIT_UNDOCHARCOUNT]
float scrollbar_hiding_timer
GLdouble GLdouble GLdouble q
NK_API struct nk_color nk_rgb_cf(struct nk_colorf c)
NK_API int nk_str_append_str_utf8(struct nk_str *, const char *)
NK_API int nk_window_is_active(struct nk_context *, const char *)
void(* draw_begin)(struct nk_command_buffer *, nk_handle)
unsigned short line_thickness
struct nk_style_window_header header
NK_API int nk_style_push_color(struct nk_context *, struct nk_color *, struct nk_color)
NK_API void nk_style_load_all_cursors(struct nk_context *, struct nk_cursor *)
NK_API void nk_window_set_position(struct nk_context *, const char *name, struct nk_vec2 pos)
struct nk_vec2 touch_padding
struct nk_style_item fixed_background
static const struct @18 vertices[3]
NK_API int nk_input_has_mouse_click(const struct nk_input *, enum nk_buttons)
NK_API int nk_combo_begin_color(struct nk_context *, struct nk_color color, struct nk_vec2 size)
NK_API void nk_str_free(struct nk_str *)
NK_API int nk_option_label(struct nk_context *, const char *, int active)
NK_API int nk_combo_begin_image_label(struct nk_context *, const char *selected, struct nk_image, struct nk_vec2 size)
struct nk_style_item background
NK_API void nk_image_color(struct nk_context *, struct nk_image, struct nk_color)
NK_API void nk_textedit_free(struct nk_text_edit *)
struct nk_scroll scrollbar
GLenum GLenum GLenum input
NK_API void nk_color_hsva_iv(int *hsva_out, struct nk_color)
void(* nk_plugin_copy)(nk_handle, const char *, int len)
NK_API struct nk_command_buffer * nk_window_get_canvas(struct nk_context *)
NK_API int nk_checkbox_text(struct nk_context *, const char *, int, int *active)
NK_API int nk_str_len(struct nk_str *)
NK_API nk_flags nk_edit_string(struct nk_context *, nk_flags, char *buffer, int *len, int max, nk_plugin_filter)
NK_API void nk_edit_unfocus(struct nk_context *)
struct nk_style_item hover
void(* nk_query_font_glyph_f)(nk_handle handle, float font_height, struct nk_user_font_glyph *glyph, nk_rune codepoint, nk_rune next_codepoint)
NK_API int nk_combo_item_image_text(struct nk_context *, struct nk_image, const char *, int, nk_flags alignment)
NK_API int nk_combo_begin_symbol_text(struct nk_context *, const char *selected, int, enum nk_symbol_type, struct nk_vec2 size)
GLuint GLsizei const GLchar * label
NK_API int nk_menu_begin_symbol_label(struct nk_context *, const char *, nk_flags align, enum nk_symbol_type, struct nk_vec2 size)
NK_API void nk_buffer_free(struct nk_buffer *)
NK_API struct nk_color nk_hsv_f(float h, float s, float v)
struct nk_style_item cursor_active
struct nk_style_item normal
NK_API int nk_button_symbol(struct nk_context *, enum nk_symbol_type)
NK_API int nk_checkbox_label(struct nk_context *, const char *, int *active)
struct nk_vec2 scroll_delta
NK_API int nk_window_is_closed(struct nk_context *, const char *)
NK_API int nk_selectable_symbol_text(struct nk_context *, enum nk_symbol_type, const char *, int, nk_flags align, int *value)
NK_API int nk_group_begin(struct nk_context *, const char *title, nk_flags)
NK_API void nk_buffer_info(struct nk_memory_status *, struct nk_buffer *)
std::pair< int, int > pixel
NK_API const char * nk_str_at_const(const struct nk_str *, int pos, nk_rune *unicode, int *len)
struct nk_color symbol_normal
#define NK_COLOR_STACK_SIZE
void(* draw_end)(struct nk_command_buffer *, nk_handle)
NK_API int nk_tree_element_push_hashed(struct nk_context *, enum nk_tree_type, const char *title, enum nk_collapse_states initial_state, int *selected, const char *hash, int len, int seed)
struct nk_style_item normal
enum nk_panel_row_layout_type type
NK_API void nk_color_hsv_i(int *out_h, int *out_s, int *out_v, struct nk_color)
#define NK_BETWEEN(x, a, b)
NK_API struct nk_rect nk_window_get_bounds(const struct nk_context *ctx)
NK_API void nk_clear(struct nk_context *)
struct nk_color cursor_border_color
NK_API void nk_menu_end(struct nk_context *)
#define NK_CONTAINER_OF(ptr, type, member)
NK_API void nk_colorf_hsva_f(float *out_h, float *out_s, float *out_v, float *out_a, struct nk_colorf in)
GLuint GLfloat GLfloat y0
struct nk_style_item hover
NK_API int nk_selectable_image_text(struct nk_context *, struct nk_image, const char *, int, nk_flags align, int *value)
NK_API nk_flags nk_chart_push(struct nk_context *, float)
NK_API unsigned nk_check_flags_label(struct nk_context *, const char *, unsigned int flags, unsigned int value)
NK_API int nk_begin_titled(struct nk_context *ctx, const char *name, const char *title, struct nk_rect bounds, nk_flags flags)
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 int nk_input_is_key_released(const struct nk_input *, enum nk_keys)
struct nk_color cursor_hover
struct nk_style_item hover
void(* draw_begin)(struct nk_command_buffer *, nk_handle)
enum nk_command_type type
struct nk_color text_active
NK_API struct nk_rect nk_widget_bounds(struct nk_context *)
GLuint GLuint64EXT address
NK_API void nk_window_show_if(struct nk_context *, const char *name, enum nk_show_states, int cond)
NK_API int nk_tree_image_push_hashed(struct nk_context *, enum nk_tree_type, struct nk_image, const char *title, enum nk_collapse_states initial_state, const char *hash, int len, int seed)
struct nk_color cursor_normal
nk_hash keys[NK_VALUE_PAGE_CAPACITY]
NK_API struct nk_color nk_hsv_iv(const int *hsv)
NK_API int nk_menu_begin_image(struct nk_context *, const char *, struct nk_image, struct nk_vec2 size)
struct nk_color popup_border_color
NK_API int nk_menu_begin_image_label(struct nk_context *, const char *, nk_flags align, struct nk_image, struct nk_vec2 size)
NK_API int nk_str_insert_at_char(struct nk_str *, int pos, const char *, int)
NK_API int nk_selectable_text(struct nk_context *, const char *, int, nk_flags align, int *value)
NK_API void nk_window_set_bounds(struct nk_context *, const char *name, struct nk_rect bounds)
NK_API int nk_input_is_mouse_down(const struct nk_input *, enum nk_buttons)
NK_API nk_size nk_prog(struct nk_context *, nk_size cur, nk_size max, int modifyable)
NK_API int nk_filter_float(const struct nk_text_edit *, nk_rune unicode)
NK_API void nk_input_end(struct nk_context *)
NK_API int nk_button_pop_behavior(struct nk_context *)
struct nk_color selected_normal
NK_API void nk_layout_row(struct nk_context *, enum nk_layout_format, float height, int cols, const float *ratio)
NK_API void nk_layout_row_template_end(struct nk_context *)
NK_API struct nk_color nk_hsva_f(float h, float s, float v, float a)
struct nk_style_edit edit
NK_API int nk_combo_string(struct nk_context *, const char *items_separated_by_zeros, int selected, int count, int item_height, struct nk_vec2 size)
struct nk_style_toggle option
NK_API int nk_strmatch_fuzzy_string(char const *str, char const *pattern, int *out_score)
struct nk_buffer_marker marker[NK_BUFFER_MAX]
NK_API int nk_combo_begin_image_text(struct nk_context *, const char *selected, int, struct nk_image, struct nk_vec2 size)
struct nk_vec2 size offset
struct nk_style_item normal
NK_API int nk_selectable_image_label(struct nk_context *, struct nk_image, const char *, nk_flags align, int *value)
struct nk_style_button node_minimize_button
unsigned short line_thickness
NK_API int nk_check_text(struct nk_context *, const char *, int, int active)
struct nk_text_edit text_edit
NK_API int nk_style_push_style_item(struct nk_context *, struct nk_style_item *, struct nk_style_item)
NK_API void nk_textedit_delete(struct nk_text_edit *, int where, int len)
GLenum GLuint GLenum GLsizei length
NK_API nk_hash nk_murmur_hash(const void *key, int len, nk_hash seed)
struct nk_style_item active
char name_string[NK_WINDOW_MAX_NAME]
struct nk_page_element * prev
enum nk_anti_aliasing shape_AA
std::array< float, 3 > color
NK_API int nk_group_scrolled_begin(struct nk_context *, struct nk_scroll *off, const char *title, nk_flags)
NK_API void nk_style_set_font(struct nk_context *, const struct nk_user_font *)
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat s1
NK_API void nk_color_hsv_b(nk_byte *out_h, nk_byte *out_s, nk_byte *out_v, struct nk_color)
struct nk_vec2 content_padding
unsigned short line_thickness
enum nk_style_item_type type
NK_API void nk_label_colored(struct nk_context *, const char *, nk_flags align, struct nk_color)
struct nk_color text_normal
struct nk_color label_hover
NK_API int nk_check_label(struct nk_context *, const char *, int active)
struct nk_color bar_filled
NK_API struct nk_color nk_rgba_cf(struct nk_colorf c)
NK_API void nk_end(struct nk_context *ctx)
NK_API int nk_menu_begin_symbol(struct nk_context *, const char *, enum nk_symbol_type, struct nk_vec2 size)
NK_API int nk_strfilter(const char *text, const char *regexp)
NK_API void nk_combobox_string(struct nk_context *, const char *items_separated_by_zeros, int *selected, int count, int item_height, struct nk_vec2 size)
char buffer[NK_MAX_NUMBER_BUFFER]
NK_API char * nk_str_get(struct nk_str *)
#define NK_CHART_MAX_SLOT
struct nk_text_undo_record undo_rec[NK_TEXTEDIT_UNDOSTATECOUNT]
void(* draw_end)(struct nk_command_buffer *, nk_handle)
NK_API int nk_str_append_str_runes(struct nk_str *, const nk_rune *)
NK_API struct nk_color nk_rgba_fv(const float *rgba)
struct nk_style_button tab_maximize_button
NK_API struct nk_vec2 nk_window_get_content_region_size(struct nk_context *)
NK_API struct nk_vec2 nk_window_get_content_region_max(struct nk_context *)
NK_API struct nk_rect nk_window_get_content_region(struct nk_context *)
NK_API int nk_select_image_label(struct nk_context *, struct nk_image, const char *, nk_flags align, int value)
NK_API void nk_layout_space_begin(struct nk_context *, enum nk_layout_format, float height, int widget_count)
NK_API int nk_group_begin_titled(struct nk_context *, const char *name, const char *title, nk_flags)
struct nk_edit_state edit
struct nk_color label_active
NK_API void nk_style_from_table(struct nk_context *, const struct nk_color *)
NK_API int nk_button_label(struct nk_context *, const char *title)
const struct nk_user_font * font
enum nk_button_behavior button_behavior
NK_API int nk_button_text(struct nk_context *, const char *title, int len)
NK_API void nk_menubar_begin(struct nk_context *)
NK_API int nk_style_push_float(struct nk_context *, float *, float)
#define NK_PTR_TO_UINT(x)
#define NK_FONT_STACK_SIZE
NK_API int nk_combo_item_label(struct nk_context *, const char *, nk_flags alignment)
NK_API int nk_button_image_label(struct nk_context *, struct nk_image img, const char *, nk_flags text_alignment)
NK_API int nk_button_image_text(struct nk_context *, struct nk_image img, const char *, int, nk_flags alignment)
NK_API void nk_color_hsv_fv(float *hsv_out, struct nk_color)
NK_API int nk_str_insert_str_char(struct nk_str *, int pos, const char *)
struct nk_vec2i points[1]
NK_API int nk_menu_begin_label(struct nk_context *, const char *, nk_flags align, struct nk_vec2 size)
NK_API void nk_color_hsva_f(float *out_h, float *out_s, float *out_v, float *out_a, struct nk_color)
NK_API int nk_style_pop_flags(struct nk_context *)
NK_API int nk_button_symbol_text_styled(struct nk_context *, const struct nk_style_button *, enum nk_symbol_type, const char *, int, nk_flags alignment)
NK_API struct nk_color nk_rgb_hex(const char *rgb)
struct nk_style_item hover
NK_API struct nk_color nk_rgb_bv(const nk_byte *rgb)
NK_API int nk_str_insert_str_utf8(struct nk_str *, int pos, const char *)
NK_API struct nk_image nk_subimage_id(int, unsigned short w, unsigned short h, struct nk_rect sub_region)
struct nk_color text_background
NK_API void nk_plot_function(struct nk_context *, enum nk_chart_type, void *userdata, float(*value_getter)(void *user, int index), int count, int offset)
NK_API nk_rune nk_str_rune_at(const struct nk_str *, int pos)
NK_API int nk_style_pop_font(struct nk_context *)
struct nk_style_item hover
NK_API int nk_tree_state_push(struct nk_context *, enum nk_tree_type, const char *title, enum nk_collapse_states *state)
NK_API void nk_window_set_size(struct nk_context *, const char *name, struct nk_vec2)
NK_API void nk_input_unicode(struct nk_context *, nk_rune)
NK_API void nk_textedit_redo(struct nk_text_edit *)
NK_API void nk_menu_close(struct nk_context *)
NK_API struct nk_vec2 nk_rect_size(struct nk_rect)
struct nk_style_item background
NK_API void nk_str_init(struct nk_str *, const struct nk_allocator *, nk_size size)
NK_API struct nk_image nk_image_id(int)
NK_API int nk_combo_begin_image(struct nk_context *, struct nk_image img, struct nk_vec2 size)
#define nk_vec2_len_sqr(a)
struct nk_style_button inc_button
NK_API void nk_color_d(double *r, double *g, double *b, double *a, struct nk_color)
NK_API void nk_combo_end(struct nk_context *)
NK_API int nk_propertyi(struct nk_context *, const char *name, int min, int val, int max, int step, float inc_per_pixel)
GLdouble GLdouble GLint GLint const GLdouble * points
void(* draw_end)(struct nk_command_buffer *, nk_handle)
NK_API void nk_input_char(struct nk_context *, char)
void copy(void *dst, void const *src, size_t size)
NK_API void nk_color_dv(double *rgba_out, struct nk_color)
struct nk_page_element win[1]
#define NK_INTERSECT(x0, y0, w0, h0, x1, y1, w1, h1)
NK_API struct nk_vec2 nk_vec2v(const float *xy)
NK_API int nk_tooltip_begin(struct nk_context *, float width)
NK_API struct nk_rect nk_recti(int x, int y, int w, int h)
NK_API struct nk_panel * nk_window_get_panel(struct nk_context *)
struct nk_vec2 menu_padding
struct nk_color label_normal
struct nk_style_item pressed
NK_API int nk_style_pop_color(struct nk_context *)
NK_API struct nk_color nk_rgba_iv(const int *rgba)
unsigned char single_line
struct nk_color selected_hover
NK_API void nk_chart_end(struct nk_context *)
struct nk_command_buffer * buffer
struct nk_color menu_border_color
NK_API int nk_menu_item_symbol_label(struct nk_context *, enum nk_symbol_type, const char *, nk_flags alignment)
NK_API int nk_combo_begin_symbol_label(struct nk_context *, const char *selected, enum nk_symbol_type, struct nk_vec2 size)
GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint GLdouble w1
#define NK_ALIGN_PTR_BACK(x, mask)
NK_API int nk_style_push_vec2(struct nk_context *, struct nk_vec2 *, struct nk_vec2)
#define nk_vec2_muls(a, t)
NK_API struct nk_vec2 nk_window_get_content_region_min(struct nk_context *)
NK_API int nk_menu_begin_text(struct nk_context *, const char *title, int title_len, nk_flags align, struct nk_vec2 size)
struct nk_color background
NK_API struct nk_rect nk_rectiv(const int *xywh)
struct nk_color border_color
NK_API struct nk_vec2 nk_widget_size(struct nk_context *)
NK_API void nk_layout_row_push(struct nk_context *, float value)