Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added support for combo from an array of struct #725

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

gooosedev
Copy link

@gooosedev gooosedev commented Oct 27, 2024

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));

@RobLoach
Copy link
Contributor

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.

@gooosedev
Copy link
Author

I added a small example as requested.
Please let me know if something else is needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants