Nuklear
Nuklear copied to clipboard
added support for combo from an array of struct
This PR adds a new combo function nk_combo_from_struct_array
the objective is to be able to make combos from an array of structs (the only requirement is for the struct to have a char* ptr to hold the name)
parameters are the same as for the nk_combo function, with the addition of the size of the struct and a stride to the
member to use for the combo entry.
example:
struct mystruct{
float f;
char* name;
int i;
};
struct mystruct items [3]={
{1.0, "foo", 1},
{1.0, "foobar", 1},
{1.0, "bar", 1},
};
int selected;
/* ... */
selected = nk_combo_from_struct_array(ctx, &items, 3, sizeof(struct mystruct), offsetof(struct mystruct, name), selected, 15, nk_vec2(x,y));
Thanks a lot. Would you mind adding a small example in the overview demo? It serves as a good space to test the code and make sure it's all still functional.
I added a small example as requested. Please let me know if something else is needed.
I do agree the function name might not be the best, i'll try to come up with a better suited one.
for the documentation, do you prefer that i do it in the source file / header for nk_combo ? or as a comment in the overview.c file ?
Definitely in the NK combo section. Preferably in the nuclear.H file, as the packer puts that first. when reading the single header, the public api prototypes are listed and documented near the top, then private library comes second; then definitions later. So placing docs above the definition will not be seen by future readers unless they explicitly scroll through 30k lines to find it.
Also, overview.c is not sourced for documentation
I'd even say in src/nuklear.h
Unfortunately, the documentation format you have chosen has been recently deprecated. Take a look at the other header blocks in the most recent src/nuklear.h