7 this->list_size = list_size;
8 this->selected_index = selected_index;
14 this->font_size = font_size;
22 const char* preview_value = list[si];
25 if (current_fs != font_size)
29 ImGui::SetNextItemWidth((
float)
width);
32 sprintf(lab,
"%s##%d", label ? label :
"",
index);
35 if (ImGui::BeginCombo(lab, preview_value)) {
36 for (
int n = 0; n < list_size; n++) {
37 const bool is_selected = (si == n);
38 if (ImGui::Selectable(list[n], is_selected)) {
40 *(this->selected_index) = n;
41 selected_item = list[n];
46 if (this->callback !=
nullptr)
52 ImGui::SetItemDefaultFocus();
58 if (current_fs != font_size)
71 this->callback = callback;
static std::unique_ptr< app_workspace > & get_instance()
Get the instance app_workspace which is a singleton.
const char * get_selected_item()
void set_value_change_action(void(*callback)())
gui_combobox(const char **list, int list_size, int *selected_index, const char *label=nullptr, int x=-1, int y=-1, int width=-1, app_workspace_ns::font_size font_size=app_workspace_ns::font_size::NORMAL_FONT)
Construct a new gui combobox object.
virtual void render_element()
font_size
This enum defines sizes of corresponding fonts. E.g.: SMALL_FONT is 12px.