From 0ccc68daa59251836a0fa38e73a827655c660e50 Mon Sep 17 00:00:00 2001 From: gooosedev <143697261+gooosedev@users.noreply.github.com> Date: Sun, 27 Oct 2024 12:04:10 +0100 Subject: [PATCH 1/7] added support for combo from an array of struct --- clib.json | 2 +- nuklear.h | 36 ++++++++++++++++++++++++++++++++++++ src/nuklear.h | 1 + src/nuklear_combo.c | 35 +++++++++++++++++++++++++++++++++++ 4 files changed, 73 insertions(+), 1 deletion(-) diff --git a/clib.json b/clib.json index bf66e59dc..2586a5c42 100644 --- a/clib.json +++ b/clib.json @@ -1,6 +1,6 @@ { "name": "nuklear", - "version": "4.12.0", + "version": "4.12.1", "repo": "Immediate-Mode-UI/Nuklear", "description": "A small ANSI C gui toolkit", "keywords": ["gl", "ui", "toolkit"], diff --git a/nuklear.h b/nuklear.h index 5091695e1..b011dc085 100644 --- a/nuklear.h +++ b/nuklear.h @@ -3564,6 +3564,7 @@ NK_API int nk_combo(struct nk_context*, const char **items, int count, int selec 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 int nk_combo_string(struct nk_context*, const char *items_separated_by_zeros, int selected, int count, int item_height, struct nk_vec2 size); 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_combo_alt(struct nk_context *ctx, const void *items, int count, int item_sz, int stride, int selected, int item_height, struct nk_vec2 size); NK_API void nk_combobox(struct nk_context*, const char **items, int count, int *selected, int item_height, struct nk_vec2 size); 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); 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); @@ -30347,6 +30348,41 @@ nk_combo_callback(struct nk_context *ctx, void(*item_getter)(void*, int, const c nk_combo_end(ctx); } return selected; } + + +NK_API int nk_combo_alt(struct nk_context *ctx, const void *items, int count, int item_sz, int stride, int selected, int item_height, struct nk_vec2 size) +{ + int i = 0; + int max_height; + struct nk_vec2 item_spacing; + struct nk_vec2 window_padding; + char* sel; + char* name; + NK_ASSERT(ctx); + NK_ASSERT(items); + NK_ASSERT(ctx->current); + if (!ctx || !items ||!count) + return selected; + + item_spacing = ctx->style.window.spacing; + window_padding = nk_panel_get_padding(&ctx->style, ctx->current->layout->type); + max_height = count * item_height + count * (int)item_spacing.y; + max_height += (int)item_spacing.y * 2 + (int)window_padding.y * 2; + size.y = NK_MIN(size.y, (float)max_height); + sel = *(char**)(items + (item_sz*selected) + stride); + if (nk_combo_begin_label(ctx, sel, size)) { + nk_layout_row_dynamic(ctx, (float)item_height, 1); + for (i = 0; i < count; ++i) { + name = *(char**)(items + stride); + if (nk_combo_item_label(ctx, name, NK_TEXT_LEFT)) + selected = i; + items += item_sz; + } + nk_combo_end(ctx); + } + return selected; +} + NK_API void nk_combobox(struct nk_context *ctx, const char **items, int count, int *selected, int item_height, struct nk_vec2 size) diff --git a/src/nuklear.h b/src/nuklear.h index 6a30b3947..c65077358 100644 --- a/src/nuklear.h +++ b/src/nuklear.h @@ -3342,6 +3342,7 @@ NK_API int nk_combo(struct nk_context*, const char **items, int count, int selec 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 int nk_combo_string(struct nk_context*, const char *items_separated_by_zeros, int selected, int count, int item_height, struct nk_vec2 size); 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_combo_alt(struct nk_context *ctx, const void *items, int count, int item_sz, int stride, int selected, int item_height, struct nk_vec2 size); NK_API void nk_combobox(struct nk_context*, const char **items, int count, int *selected, int item_height, struct nk_vec2 size); 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); 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); diff --git a/src/nuklear_combo.c b/src/nuklear_combo.c index 0e403b83c..86b6af5da 100644 --- a/src/nuklear_combo.c +++ b/src/nuklear_combo.c @@ -819,6 +819,41 @@ nk_combo_callback(struct nk_context *ctx, void(*item_getter)(void*, int, const c nk_combo_end(ctx); } return selected; } + + +NK_API int nk_combo_alt(struct nk_context *ctx, const void *items, int count, int item_sz, int stride, int selected, int item_height, struct nk_vec2 size) +{ + int i = 0; + int max_height; + struct nk_vec2 item_spacing; + struct nk_vec2 window_padding; + char* sel; + char* name; + NK_ASSERT(ctx); + NK_ASSERT(items); + NK_ASSERT(ctx->current); + if (!ctx || !items ||!count) + return selected; + + item_spacing = ctx->style.window.spacing; + window_padding = nk_panel_get_padding(&ctx->style, ctx->current->layout->type); + max_height = count * item_height + count * (int)item_spacing.y; + max_height += (int)item_spacing.y * 2 + (int)window_padding.y * 2; + size.y = NK_MIN(size.y, (float)max_height); + sel = *(char**)(items + (item_sz*selected) + stride); + if (nk_combo_begin_label(ctx, sel, size)) { + nk_layout_row_dynamic(ctx, (float)item_height, 1); + for (i = 0; i < count; ++i) { + name = *(char**)(items + stride); + if (nk_combo_item_label(ctx, name, NK_TEXT_LEFT)) + selected = i; + items += item_sz; + } + nk_combo_end(ctx); + } + return selected; +} + NK_API void nk_combobox(struct nk_context *ctx, const char **items, int count, int *selected, int item_height, struct nk_vec2 size) From 501b9e33a5b85e4f095a40b7b1988cc338d6ebb8 Mon Sep 17 00:00:00 2001 From: gooosedev <143697261+gooosedev@users.noreply.github.com> Date: Mon, 28 Oct 2024 10:55:31 +0100 Subject: [PATCH 2/7] renamed the function to nk_combo_from_struct_array fixed pointer arithmetic warnings --- nuklear.h | 10 +++++----- src/nuklear.h | 2 +- src/nuklear_combo.c | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/nuklear.h b/nuklear.h index b011dc085..c5a520e76 100644 --- a/nuklear.h +++ b/nuklear.h @@ -3564,7 +3564,7 @@ NK_API int nk_combo(struct nk_context*, const char **items, int count, int selec 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 int nk_combo_string(struct nk_context*, const char *items_separated_by_zeros, int selected, int count, int item_height, struct nk_vec2 size); 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_combo_alt(struct nk_context *ctx, const void *items, int count, int item_sz, int stride, int selected, int item_height, struct nk_vec2 size); +NK_API int nk_combo_from_struct_array(struct nk_context *ctx, const void *items, int count, int item_sz, int stride, int selected, int item_height, struct nk_vec2 size); NK_API void nk_combobox(struct nk_context*, const char **items, int count, int *selected, int item_height, struct nk_vec2 size); 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); 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); @@ -30350,7 +30350,7 @@ nk_combo_callback(struct nk_context *ctx, void(*item_getter)(void*, int, const c } -NK_API int nk_combo_alt(struct nk_context *ctx, const void *items, int count, int item_sz, int stride, int selected, int item_height, struct nk_vec2 size) +NK_API int nk_combo_from_struct_array(struct nk_context *ctx, const void *items, int count, int item_sz, int stride, int selected, int item_height, struct nk_vec2 size) { int i = 0; int max_height; @@ -30369,14 +30369,14 @@ NK_API int nk_combo_alt(struct nk_context *ctx, const void *items, int count, in max_height = count * item_height + count * (int)item_spacing.y; max_height += (int)item_spacing.y * 2 + (int)window_padding.y * 2; size.y = NK_MIN(size.y, (float)max_height); - sel = *(char**)(items + (item_sz*selected) + stride); + sel = *(char**)((char*)items + (item_sz*selected) + stride); if (nk_combo_begin_label(ctx, sel, size)) { nk_layout_row_dynamic(ctx, (float)item_height, 1); for (i = 0; i < count; ++i) { - name = *(char**)(items + stride); + name = *(char**)((char*)items + stride); if (nk_combo_item_label(ctx, name, NK_TEXT_LEFT)) selected = i; - items += item_sz; + items = (char*)items + item_sz; } nk_combo_end(ctx); } diff --git a/src/nuklear.h b/src/nuklear.h index c65077358..4e45336a5 100644 --- a/src/nuklear.h +++ b/src/nuklear.h @@ -3342,7 +3342,7 @@ NK_API int nk_combo(struct nk_context*, const char **items, int count, int selec 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 int nk_combo_string(struct nk_context*, const char *items_separated_by_zeros, int selected, int count, int item_height, struct nk_vec2 size); 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_combo_alt(struct nk_context *ctx, const void *items, int count, int item_sz, int stride, int selected, int item_height, struct nk_vec2 size); +NK_API int nk_combo_from_struct_array(struct nk_context *ctx, const void *items, int count, int item_sz, int stride, int selected, int item_height, struct nk_vec2 size); NK_API void nk_combobox(struct nk_context*, const char **items, int count, int *selected, int item_height, struct nk_vec2 size); 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); 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); diff --git a/src/nuklear_combo.c b/src/nuklear_combo.c index 86b6af5da..7e500a08a 100644 --- a/src/nuklear_combo.c +++ b/src/nuklear_combo.c @@ -821,7 +821,7 @@ nk_combo_callback(struct nk_context *ctx, void(*item_getter)(void*, int, const c } -NK_API int nk_combo_alt(struct nk_context *ctx, const void *items, int count, int item_sz, int stride, int selected, int item_height, struct nk_vec2 size) +NK_API int nk_combo_from_struct_array(struct nk_context *ctx, const void *items, int count, int item_sz, int stride, int selected, int item_height, struct nk_vec2 size) { int i = 0; int max_height; @@ -840,14 +840,14 @@ NK_API int nk_combo_alt(struct nk_context *ctx, const void *items, int count, in max_height = count * item_height + count * (int)item_spacing.y; max_height += (int)item_spacing.y * 2 + (int)window_padding.y * 2; size.y = NK_MIN(size.y, (float)max_height); - sel = *(char**)(items + (item_sz*selected) + stride); + sel = *(char**)((char*)items + (item_sz*selected) + stride); if (nk_combo_begin_label(ctx, sel, size)) { nk_layout_row_dynamic(ctx, (float)item_height, 1); for (i = 0; i < count; ++i) { - name = *(char**)(items + stride); + name = *(char**)((char*)items + stride); if (nk_combo_item_label(ctx, name, NK_TEXT_LEFT)) selected = i; - items += item_sz; + items = (char*)items + item_sz; } nk_combo_end(ctx); } From 326584e0a8ecbefcbf641ec59089f919643b94ff Mon Sep 17 00:00:00 2001 From: gooosedev <143697261+gooosedev@users.noreply.github.com> Date: Mon, 18 Nov 2024 15:49:10 +0100 Subject: [PATCH 3/7] added small example for combobox_for_struct inside overview example --- demo/common/overview.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/demo/common/overview.c b/demo/common/overview.c index 45458543b..55f3e39da 100644 --- a/demo/common/overview.c +++ b/demo/common/overview.c @@ -18,7 +18,7 @@ overview(struct nk_context *ctx) #ifdef INCLUDE_STYLE /* styles */ - static const char* themes[] = {"Black", "White", "Red", "Blue", "Dark", "Dracula", + static const char* themes[] = {"Black", "White", "Red", "Blue", "Dark", "Dracula", "Catppucin Latte", "Catppucin Frappe", "Catppucin Macchiato", "Catppucin Mocha"}; static int current_theme = 0; #endif @@ -584,6 +584,36 @@ overview(struct nk_context *ctx) nk_combo_end(ctx); } } + { + /* Combobox from array of struct */ + static int sel=0; + struct student { + int id; + char* name; + int age; + char* major; + }; + + static struct student students[4] = { + {0, "----", 0, "----"}, + {1, "Mike", 20, "CS"}, + {2, "Jim", 19, "Maths"}, + {3, "Julia", 20, "Biology"} + }; + sel = nk_combo_from_struct_array(ctx, &students, 4, + sizeof(struct student), + offsetof(struct student, name), + sel, 15, nk_vec2(200,200)); + if(sel>0){ + nk_layout_row_static(ctx, 30,300, 2); + nk_labelf(ctx, NK_TEXT_LEFT, "id:%d | name:%s | age:%d | major:%s", + students[sel].id, + students[sel].name, + students[sel].age, + students[sel].major + ); + } + } nk_tree_pop(ctx); } From 420ac59ea3a1968db45b5743430c1a55938be24c Mon Sep 17 00:00:00 2001 From: gooosedev <143697261+gooosedev@users.noreply.github.com> Date: Wed, 11 Dec 2024 10:07:56 +0100 Subject: [PATCH 4/7] feature/combo_from_struct_array: - Added documentation - Added check for NULL char pointer for the name --- src/nuklear.h | 18 ++++++++++++++++++ src/nuklear_combo.c | 2 ++ 2 files changed, 20 insertions(+) diff --git a/src/nuklear.h b/src/nuklear.h index 0520ebbb3..5a70f5fdd 100644 --- a/src/nuklear.h +++ b/src/nuklear.h @@ -3543,6 +3543,24 @@ NK_API int nk_combo(struct nk_context*, const char *const *items, int count, int 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 int nk_combo_string(struct nk_context*, const char *items_separated_by_zeros, int selected, int count, int item_height, struct nk_vec2 size); 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_combo_from_struct_array(struct nk_context *ctx, const void *items, int count, int item_sz, int stride, int selected, int item_height, struct nk_vec2 size); +/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +/// +/// Parameter | Description +/// --------------------|----------------------------------------------------------- +/// __ctx__ | Must point to an previously initialized `nk_context` struct after calling a layouting function +/// __items__ | `void` pointer to a list of structures +/// __count__ | Number of elements in the array of structs +/// __items_sz__ | Size of an individual structure. +/// __stride__ | Stride to a char* member inside the structure +/// __selected__ | the index of the current selected item +/// __item_height__ | Height of the element +/// __size__ | Size of the element listing, must point to a `nk_vec2` structure +/// Returns the index of the newly selected item. +/// #### Usage +/// The nk_combo_from_struct_array is designed to create a combobox from an array of strct containing a `char*` member that we use as a name +/// this avoids the need to have two arrays (one being for the array of structs, and one for the names) NK_API int nk_combo_from_struct_array(struct nk_context *ctx, const void *items, int count, int item_sz, int stride, int selected, int item_height, struct nk_vec2 size); NK_API void nk_combobox(struct nk_context*, const char **items, int count, int *selected, int item_height, struct nk_vec2 size); 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); diff --git a/src/nuklear_combo.c b/src/nuklear_combo.c index 2fa1149d4..d24ddfcbd 100644 --- a/src/nuklear_combo.c +++ b/src/nuklear_combo.c @@ -845,6 +845,8 @@ NK_API int nk_combo_from_struct_array(struct nk_context *ctx, const void *items, nk_layout_row_dynamic(ctx, (float)item_height, 1); for (i = 0; i < count; ++i) { name = *(char**)((char*)items + stride); + if(!name) + name = ""; if (nk_combo_item_label(ctx, name, NK_TEXT_LEFT)) selected = i; items = (char*)items + item_sz; From 48c2272133fb26abd6e03a2db64383eac472da38 Mon Sep 17 00:00:00 2001 From: gooosedev <143697261+gooosedev@users.noreply.github.com> Date: Wed, 11 Dec 2024 10:25:24 +0100 Subject: [PATCH 5/7] Made the struct array definition more readable --- demo/common/overview.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/demo/common/overview.c b/demo/common/overview.c index 55f3e39da..279fe188d 100644 --- a/demo/common/overview.c +++ b/demo/common/overview.c @@ -594,13 +594,27 @@ overview(struct nk_context *ctx) char* major; }; - static struct student students[4] = { - {0, "----", 0, "----"}, - {1, "Mike", 20, "CS"}, - {2, "Jim", 19, "Maths"}, - {3, "Julia", 20, "Biology"} + static struct student students[3] = { + { + .id = 1, + .name = "Mike", + .age = 20, + .major = "CS" + }, + { + .id = 2, + .name = "Jim", + .age = 19, + .major = "Maths" + }, + { + .id = 3, + .name = "Julia", + .age = 20, + .major = "Biology" + } }; - sel = nk_combo_from_struct_array(ctx, &students, 4, + sel = nk_combo_from_struct_array(ctx, &students, 3, sizeof(struct student), offsetof(struct student, name), sel, 15, nk_vec2(200,200)); From 4a46e6a7fe7122338dc127b9985471fbe0b595b6 Mon Sep 17 00:00:00 2001 From: gooosedev <143697261+gooosedev@users.noreply.github.com> Date: Wed, 11 Dec 2024 11:36:28 +0100 Subject: [PATCH 6/7] feature/combo_from_struct_array fixed comment style. --- src/nuklear.h | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/src/nuklear.h b/src/nuklear.h index 5a70f5fdd..c7e23a297 100644 --- a/src/nuklear.h +++ b/src/nuklear.h @@ -3543,24 +3543,23 @@ NK_API int nk_combo(struct nk_context*, const char *const *items, int count, int 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 int nk_combo_string(struct nk_context*, const char *items_separated_by_zeros, int selected, int count, int item_height, struct nk_vec2 size); 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_combo_from_struct_array(struct nk_context *ctx, const void *items, int count, int item_sz, int stride, int selected, int item_height, struct nk_vec2 size); -/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -/// -/// Parameter | Description -/// --------------------|----------------------------------------------------------- -/// __ctx__ | Must point to an previously initialized `nk_context` struct after calling a layouting function -/// __items__ | `void` pointer to a list of structures -/// __count__ | Number of elements in the array of structs -/// __items_sz__ | Size of an individual structure. -/// __stride__ | Stride to a char* member inside the structure -/// __selected__ | the index of the current selected item -/// __item_height__ | Height of the element -/// __size__ | Size of the element listing, must point to a `nk_vec2` structure -/// Returns the index of the newly selected item. -/// #### Usage -/// The nk_combo_from_struct_array is designed to create a combobox from an array of strct containing a `char*` member that we use as a name -/// this avoids the need to have two arrays (one being for the array of structs, and one for the names) +/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * NK_API int nk_combo_from_struct_array(struct nk_context *ctx, const void *items, int count, int item_sz, int stride, int selected, int item_height, struct nk_vec2 size); + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * Parameter | Description + * --------------------|----------------------------------------------------------- + * __ctx__ | Must point to an previously initialized `nk_context` struct after calling a layouting function + * __items__ | `void` pointer to a list of structures + * __count__ | Number of elements in the array of structs + * __items_sz__ | Size of an individual structure. + * __stride__ | Stride to a char* member inside the structure + * __selected__ | the index of the current selected item + * __item_height__ | Height of the element + * __size__ | Size of the element listing, must point to a `nk_vec2` structure + * Returns the index of the newly selected item. + * #### Usage + * The nk_combo_from_struct_array is designed to create a combobox from an array of strct containing a `char*` member that we use as a name + * this avoids the need to have two arrays (one being for the array of structs, and one for the names) */ NK_API int nk_combo_from_struct_array(struct nk_context *ctx, const void *items, int count, int item_sz, int stride, int selected, int item_height, struct nk_vec2 size); NK_API void nk_combobox(struct nk_context*, const char **items, int count, int *selected, int item_height, struct nk_vec2 size); 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); From da871a8ee0d54d96d6ed1e25c3202cc191b08ac4 Mon Sep 17 00:00:00 2001 From: gooosedev <143697261+gooosedev@users.noreply.github.com> Date: Thu, 12 Dec 2024 10:04:18 +0100 Subject: [PATCH 7/7] fixed doc format --- src/nuklear.h | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/src/nuklear.h b/src/nuklear.h index c7e23a297..eac73c936 100644 --- a/src/nuklear.h +++ b/src/nuklear.h @@ -3543,23 +3543,26 @@ NK_API int nk_combo(struct nk_context*, const char *const *items, int count, int 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 int nk_combo_string(struct nk_context*, const char *items_separated_by_zeros, int selected, int count, int item_height, struct nk_vec2 size); 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_combo_from_struct_array(struct nk_context *ctx, const void *items, int count, int item_sz, int stride, int selected, int item_height, struct nk_vec2 size); - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - * Parameter | Description - * --------------------|----------------------------------------------------------- - * __ctx__ | Must point to an previously initialized `nk_context` struct after calling a layouting function - * __items__ | `void` pointer to a list of structures - * __count__ | Number of elements in the array of structs - * __items_sz__ | Size of an individual structure. - * __stride__ | Stride to a char* member inside the structure - * __selected__ | the index of the current selected item - * __item_height__ | Height of the element - * __size__ | Size of the element listing, must point to a `nk_vec2` structure - * Returns the index of the newly selected item. - * #### Usage - * The nk_combo_from_struct_array is designed to create a combobox from an array of strct containing a `char*` member that we use as a name - * this avoids the need to have two arrays (one being for the array of structs, and one for the names) */ +/* + * \brief create a combobox from an array of strct containing a `char*` member that we use as a name + * this avoids the need to have two arrays (one being for the array of structs, and one for the names) + * + * \details + * ```c + * int nk_combo_from_struct_array(struct nk_context *ctx, const void *items, int count, int item_sz, int stride, int selected, int item_height, struct nk_vec2 size); + * ``` + * + * \param[in] ctx | Must point to an previously initialized `nk_context` struct after calling a layouting function + * \param[in] items | `void` pointer to a list of structures + * \param[in] count | Number of elements in the array of structs + * \param[in] items_sz | Size of an individual structure. + * \param[in] stride | Stride to a char* member inside the structure + * \param[in] selected | the index of the current selected item + * \param[in] item_height | Height of the element + * \param[in] size | Size of the element listing, must point to a `nk_vec2` structure + * + * \returns the index of the newly selected item. + */ NK_API int nk_combo_from_struct_array(struct nk_context *ctx, const void *items, int count, int item_sz, int stride, int selected, int item_height, struct nk_vec2 size); NK_API void nk_combobox(struct nk_context*, const char **items, int count, int *selected, int item_height, struct nk_vec2 size); 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);