From 2855642dd16cea260f3b32351f0529328a0bcb15 Mon Sep 17 00:00:00 2001 From: Aldrik Ramaekers Date: Sat, 4 Oct 2025 15:54:30 +0200 Subject: namespacing locale, config, file_templates --- src/ui/imgui_extensions.cpp | 46 ++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'src/ui/imgui_extensions.cpp') diff --git a/src/ui/imgui_extensions.cpp b/src/ui/imgui_extensions.cpp index 4a0117b..8c8f4c4 100644 --- a/src/ui/imgui_extensions.cpp +++ b/src/ui/imgui_extensions.cpp @@ -13,7 +13,7 @@ namespace ImGui void InputTextWithError(const char* text, char* buffer, size_t buf_size, bool has_error) { if (has_error) { - ImGui::PushStyleColor(ImGuiCol_Border, COLOR_ERROR_OUTLINE); + ImGui::PushStyleColor(ImGuiCol_Border, config::colors::COLOR_ERROR_OUTLINE); ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.5f); } ImGui::InputText(text, buffer, buf_size); @@ -29,7 +29,7 @@ namespace ImGui ImGui::SetNextItemWidth(widthAvailable*0.5f); if (has_error) { - ImGui::PushStyleColor(ImGuiCol_Border, COLOR_ERROR_OUTLINE); + ImGui::PushStyleColor(ImGuiCol_Border, config::colors::COLOR_ERROR_OUTLINE); ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.5f); } ImGui::InputTextWithHint(hint, hint, buffer, buf_size); @@ -53,7 +53,7 @@ namespace ImGui { const char *filterPatterns[] = { "*.pdf" }; const char *file = tinyfd_openFileDialog( - "Choose a file", // dialog title // @localize + "Choose a file", // dialog title // @locale::get NULL, // default path 1, // number of filter patterns filterPatterns, // filter patterns array @@ -76,7 +76,7 @@ namespace ImGui result = true; } ImGui::SameLine(); - ImGui::TextWrapped("Selected: %s", buffer); // @localize + ImGui::TextWrapped("Selected: %s", buffer); // @locale::get } @@ -90,16 +90,16 @@ namespace ImGui ImGui::SetNextItemWidth(widthAvailable*0.5f); const char* countries[30]; - for (int x = 0; x < country_count; x++) + for (int x = 0; x < config::country_count; x++) { char locale_str[20]; - snprintf(locale_str, 20, "country.%s", country_codes[x]); - countries[x] = localize(locale_str); + snprintf(locale_str, 20, "country.%s", config::country_codes[x]); + countries[x] = locale::get(locale_str); } - for (int i = 0; i < country_count; i++) + for (int i = 0; i < config::country_count; i++) { - if (strcmp(country_codes[i], buffer) == 0) + if (strcmp(config::country_codes[i], buffer) == 0) { selected_country = countries[i]; break; @@ -109,13 +109,13 @@ namespace ImGui int selected_country_index = -1; if (!has_a_selection) { - ImGui::PushStyleColor(ImGuiCol_Border, COLOR_ERROR_OUTLINE); + ImGui::PushStyleColor(ImGuiCol_Border, config::colors::COLOR_ERROR_OUTLINE); ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.5f); } - if (ImGui::BeginCombo(localize("contact.form.country"), selected_country)) + if (ImGui::BeginCombo(locale::get("contact.form.country"), selected_country)) { - for (int n = 0; n < country_count; n++) + for (int n = 0; n < config::country_count; n++) { bool is_selected = (selected_country == countries[n]); if (ImGui::Selectable(countries[n], is_selected)) { @@ -136,7 +136,7 @@ namespace ImGui } if (selected_country_index != -1) { - strops_copy(buffer, country_codes[selected_country_index], buf_size); + strops_copy(buffer, config::country_codes[selected_country_index], buf_size); } } @@ -144,9 +144,9 @@ namespace ImGui { float widthAvailable = ImGui::GetContentRegionAvail().x; ImGui::SetNextItemWidth(widthAvailable*0.5f); - const char* customer_types[2] = { localize("contact.form.type.business"), localize("contact.form.type.consumer") }; + const char* customer_types[2] = { locale::get("contact.form.type.business"), locale::get("contact.form.type.consumer") }; int currentItem = static_cast(*type); - if (ImGui::Combo(localize("contact.form.type"), ¤tItem, customer_types, IM_ARRAYSIZE(customer_types))) + if (ImGui::Combo(locale::get("contact.form.type"), ¤tItem, customer_types, IM_ARRAYSIZE(customer_types))) { *type = static_cast(currentItem); } @@ -159,7 +159,7 @@ namespace ImGui static bool is_open = false; if (has_error) { - ImGui::PushStyleColor(ImGuiCol_Border, COLOR_ERROR_OUTLINE); + ImGui::PushStyleColor(ImGuiCol_Border, config::colors::COLOR_ERROR_OUTLINE); ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.5f); } ImGui::InputTextWithHint(hint, hint, buffer, buf_size); @@ -230,7 +230,7 @@ namespace ImGui snprintf(autocomplete_strings[i], 200, "%s (%s %s)", autocomplete_list[i].name, autocomplete_list[i].address.address1, autocomplete_list[i].address.address2); } - int autocomplete_index = ImGui::TextInputWithAutocomplete(localize("contact.form.fullname"), + int autocomplete_index = ImGui::TextInputWithAutocomplete(locale::get("contact.form.fullname"), buffer->name, IM_ARRAYSIZE(buffer->name), (char**)autocomplete_strings, autocomplete_count, has_error); if (autocomplete_index != -1) @@ -266,12 +266,12 @@ namespace ImGui } int selected_costcenter_index = -1; - if (ImGui::BeginCombo(localize("invoice.form.costcenter"), selected_costcenter == NULL ? NULL : localize(selected_costcenter->description))) + if (ImGui::BeginCombo(locale::get("invoice.form.costcenter"), selected_costcenter == NULL ? NULL : locale::get(selected_costcenter->description))) { for (u32 n = 0; n < costcenter_count; n++) { bool is_selected = selected_costcenter && strcmp(selected_costcenter->id, buffer[n].id) == 0; - if (ImGui::Selectable(localize(buffer[n].description), is_selected)) { + if (ImGui::Selectable(locale::get(buffer[n].description), is_selected)) { selected_costcenter_index = n; } } @@ -307,7 +307,7 @@ namespace ImGui } int selected_project_index = -1; - if (ImGui::BeginCombo(localize("invoice.form.project"), selected_project == NULL ? NULL : selected_project->description)) + if (ImGui::BeginCombo(locale::get("invoice.form.project"), selected_project == NULL ? NULL : selected_project->description)) { for (u32 n = 0; n < project_count; n++) { @@ -356,13 +356,13 @@ namespace ImGui if (strcmp(selected_tax_rate->country_code, "00") == 0) { char category_code_desc[MAX_LEN_LONG_DESC]; snprintf(category_code_desc, MAX_LEN_LONG_DESC, "taxcategory.%s", selected_tax_rate->category_code); - snprintf(rate_str_buf, 40, "%s", localize(category_code_desc)); + snprintf(rate_str_buf, 40, "%s", locale::get(category_code_desc)); } else snprintf(rate_str_buf, 40, "%s/%.1f%%", selected_tax_rate->country_code, selected_tax_rate->rate); } if (has_error) { - ImGui::PushStyleColor(ImGuiCol_Border, COLOR_ERROR_OUTLINE); + ImGui::PushStyleColor(ImGuiCol_Border, config::colors::COLOR_ERROR_OUTLINE); ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.5f); } @@ -375,7 +375,7 @@ namespace ImGui if (strcmp(buffer[n].country_code, "00") == 0) { char category_code_desc[MAX_LEN_LONG_DESC]; snprintf(category_code_desc, MAX_LEN_LONG_DESC, "taxcategory.%s", buffer[n].category_code); - snprintf(rate_str_buf, 40, "%s", localize(category_code_desc)); + snprintf(rate_str_buf, 40, "%s", locale::get(category_code_desc)); } else snprintf(rate_str_buf, 40, "%s/%.1f%%", buffer[n].country_code, buffer[n].rate); -- cgit v1.2.3-70-g09d2