|
|
@@ -236,15 +236,17 @@ struct SandboxApp : AppBase {
|
|
|
|
|
|
this->mem_arena_temp->begin(this->def_mem_arena.get());
|
|
|
|
|
|
- // Тип
|
|
|
+ // Теги
|
|
|
{
|
|
|
// TODO: get form server (DB)
|
|
|
- static const char *items[] = {"Вариант 1", "Вариант 2",
|
|
|
- "Вариант 3"};
|
|
|
- static int current_item = 0;
|
|
|
+ static std::vector<std::string> items;
|
|
|
+ static int current_item;
|
|
|
+
|
|
|
+ std::string preview_value = items.size() == 0 ? "None" : items.at(current_item);
|
|
|
|
|
|
- if (ImGui::BeginCombo("Тип", items[current_item])) {
|
|
|
+ if (ImGui::BeginCombo("Теги", preview_value.c_str())) {
|
|
|
if (ImGui::IsWindowAppearing()) {
|
|
|
+ items.clear();
|
|
|
auto res = cpr::Get(
|
|
|
cpr::Url(
|
|
|
"http://api.localhost:8090/v1/example/client/tags"),
|
|
|
@@ -255,33 +257,25 @@ struct SandboxApp : AppBase {
|
|
|
throw std::runtime_error("Expected JSON array but got " +
|
|
|
std::string(res_json.type_name()));
|
|
|
}
|
|
|
- spdlog::info("Response: {}", res_json.dump(2));
|
|
|
+ for (auto &item : res_json) {
|
|
|
+ spdlog::info("Response: {}", item.get<std::string>());
|
|
|
+ items.push_back(item.get<std::string>());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- ImGui::EndCombo();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // Теги
|
|
|
- {
|
|
|
- // TODO: get form server (DB)
|
|
|
- static const char *items[] = {"Вариант 1", "Вариант 2",
|
|
|
- "Вариант 3"};
|
|
|
- static int current_item = 0;
|
|
|
-
|
|
|
- if (ImGui::BeginCombo("Теги", items[current_item])) {
|
|
|
- for (int n = 0; n < IM_ARRAYSIZE(items); n++) {
|
|
|
- bool is_selected = (current_item == n);
|
|
|
+ for (int i = 0; i < items.size(); i++) {
|
|
|
+ const bool is_selected = (current_item == i);
|
|
|
|
|
|
- if (ImGui::Selectable(items[n], is_selected)) {
|
|
|
- current_item = n;
|
|
|
+ if (ImGui::Selectable(items[i].c_str(), is_selected)) {
|
|
|
+ current_item = i;
|
|
|
}
|
|
|
|
|
|
if (is_selected) {
|
|
|
ImGui::SetItemDefaultFocus();
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
ImGui::EndCombo();
|
|
|
}
|
|
|
}
|