|
|
@@ -236,17 +236,24 @@ struct SandboxApp : AppBase {
|
|
|
if (ImGui::BeginPopupModal("CreateClientPopup", NULL,
|
|
|
ImGuiWindowFlags_AlwaysAutoResize)) {
|
|
|
ClientInfo tmp_client;
|
|
|
+ struct Item {
|
|
|
+ std::string name;
|
|
|
+ bool is_hovered;
|
|
|
+ };
|
|
|
+ static std::vector<Item> types = {
|
|
|
+ {"Нет", false},
|
|
|
+ {"Физ", false},
|
|
|
+ {"Юр", false},
|
|
|
+ {"Контрагент", false},
|
|
|
+ };
|
|
|
+ static std::string title_type = "";
|
|
|
+
|
|
|
uint64_t def_str_size = 65;
|
|
|
|
|
|
this->mem_arena_temp->begin(this->def_mem_arena.get());
|
|
|
|
|
|
// Тип
|
|
|
{
|
|
|
- struct Item {
|
|
|
- std::string name;
|
|
|
- bool is_hovered;
|
|
|
- };
|
|
|
-
|
|
|
auto join_items_by_hovered{[](const std::vector<Item> &items,
|
|
|
size_t limit) -> std::string {
|
|
|
std::ostringstream oss;
|
|
|
@@ -274,50 +281,42 @@ struct SandboxApp : AppBase {
|
|
|
return oss.str();
|
|
|
}};
|
|
|
|
|
|
- static std::vector<Item> items = {
|
|
|
- {"Нет", false},
|
|
|
- {"Физ", false},
|
|
|
- {"Юр", false},
|
|
|
- {"Контрагент", false},
|
|
|
- };
|
|
|
-
|
|
|
static int current_item = 0;
|
|
|
- static std::string title = "Нет";
|
|
|
|
|
|
- if (ImGui::BeginCombo("Тип", title.c_str())) {
|
|
|
+ if (ImGui::BeginCombo("Тип", title_type.c_str())) {
|
|
|
if (ImGui::IsWindowAppearing()) {
|
|
|
}
|
|
|
|
|
|
// TODO(0xc3): почистить
|
|
|
- for (int i = 0; i < items.size(); i++) {
|
|
|
+ for (int i = 0; i < types.size(); i++) {
|
|
|
if (i == 0) {
|
|
|
if (ImGui::Selectable(
|
|
|
- items[0].name.c_str(), false,
|
|
|
+ types[0].name.c_str(), false,
|
|
|
ImGuiSelectableFlags_NoAutoClosePopups)) {
|
|
|
- for (auto &item : items) {
|
|
|
+ for (auto &item : types) {
|
|
|
item.is_hovered = false;
|
|
|
}
|
|
|
- title = items[0].name;
|
|
|
+ title_type = "Нет";
|
|
|
+ }
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!types[i].is_hovered) {
|
|
|
+ if (ImGui::Selectable(
|
|
|
+ types[i].name.c_str(), false,
|
|
|
+ ImGuiSelectableFlags_NoAutoClosePopups)) {
|
|
|
+ types[i].is_hovered = true;
|
|
|
}
|
|
|
} else {
|
|
|
- if (!items[i].is_hovered) {
|
|
|
- if (ImGui::Selectable(
|
|
|
- items[i].name.c_str(), false,
|
|
|
- ImGuiSelectableFlags_NoAutoClosePopups)) {
|
|
|
- items[i].is_hovered = true;
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (ImGui::Selectable(
|
|
|
- items[i].name.c_str(), false,
|
|
|
- ImGuiSelectableFlags_NoAutoClosePopups |
|
|
|
- ImGuiSelectableFlags_Highlight)) {
|
|
|
- items[i].is_hovered = false;
|
|
|
- }
|
|
|
+ if (ImGui::Selectable(types[i].name.c_str(), false,
|
|
|
+ ImGuiSelectableFlags_NoAutoClosePopups |
|
|
|
+ ImGuiSelectableFlags_Highlight)) {
|
|
|
+ types[i].is_hovered = false;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- title = join_items_by_hovered(items, 4);
|
|
|
+ title_type = join_items_by_hovered(types, 4);
|
|
|
|
|
|
ImGui::EndCombo();
|
|
|
}
|
|
|
@@ -325,7 +324,6 @@ struct SandboxApp : AppBase {
|
|
|
|
|
|
// Теги
|
|
|
{
|
|
|
- // TODO: get form server (DB)
|
|
|
static std::vector<std::string> items = {"Нет"};
|
|
|
static int current_item = 0;
|
|
|
|
|
|
@@ -366,10 +364,6 @@ struct SandboxApp : AppBase {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // Контрагент
|
|
|
- bool *contractor = (bool *)this->mem_arena_temp->push(def_str_size);
|
|
|
- ImGui::Checkbox("Контрагент", contractor);
|
|
|
-
|
|
|
// ФИО
|
|
|
uint8_t *full_name = this->mem_arena_temp->push(def_str_size);
|
|
|
ImGui::InputText("ФИО", (char *)full_name, def_str_size);
|
|
|
@@ -393,7 +387,6 @@ struct SandboxApp : AppBase {
|
|
|
ImGui::InputTextMultiline("Заметки", (char *)note, def_str_size);
|
|
|
|
|
|
if (ImGui::Button("Close", ImVec2(120, 0))) {
|
|
|
- tmp_client.contractor = *contractor;
|
|
|
tmp_client.full_name = (char *)full_name;
|
|
|
tmp_client.email = (char *)email;
|
|
|
tmp_client.legal_address = (char *)legal_address;
|
|
|
@@ -409,6 +402,14 @@ struct SandboxApp : AppBase {
|
|
|
spdlog::info("{}", tmp_client.note);
|
|
|
// spdlog::info("{}", tmp_client.reg_date);
|
|
|
|
|
|
+ types = {
|
|
|
+ {"Нет", false},
|
|
|
+ {"Физ", false},
|
|
|
+ {"Юр", false},
|
|
|
+ {"Контрагент", false},
|
|
|
+ };
|
|
|
+ title_type = types[0].name;
|
|
|
+
|
|
|
this->mem_arena_temp->pop_zero_all();
|
|
|
ImGui::CloseCurrentPopup();
|
|
|
}
|