diff options
Diffstat (limited to 'src/ui')
| -rw-r--r-- | src/ui/ui_main.cpp | 14 | ||||
| -rw-r--r-- | src/ui/ui_projects.cpp | 2 | ||||
| -rw-r--r-- | src/ui/ui_settings.cpp | 62 |
3 files changed, 69 insertions, 9 deletions
diff --git a/src/ui/ui_main.cpp b/src/ui/ui_main.cpp index 8af8dbc..10f9cea 100644 --- a/src/ui/ui_main.cpp +++ b/src/ui/ui_main.cpp @@ -91,8 +91,8 @@ void ui_draw_main() ImGui::PopStyleVar(); } - if (ImGui::Button(localize("nav.Projects"), ImVec2(buttonWidth, 24))) set_dashboard_state(dashboard_view_state::PROJECTS); - if (ImGui::Button("Settings", ImVec2(buttonWidth, 24))) set_dashboard_state(dashboard_view_state::SETTINGS); //@localize + if (ImGui::Button(localize("nav.projects"), ImVec2(buttonWidth, 24))) set_dashboard_state(dashboard_view_state::PROJECTS); + if (ImGui::Button(localize("nav.settings"), ImVec2(buttonWidth, 24))) set_dashboard_state(dashboard_view_state::SETTINGS); ImGui::PopStyleColor(1); ImGui::PopStyleVar(3); @@ -122,8 +122,14 @@ void ui_draw_main() ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoCollapse); - - ImGui::Text("Working on: %s", administration_get_file_path()); // @localize + + char* path = administration_get_file_path(); + if (strlen(path) == 0) { + ImGui::Text("%s: %s", localize("ui.workingOn"), localize("ui.unsavedProject")); + } + else { + ImGui::Text("%s: %s", localize("ui.workingOn"), administration_get_file_path()); + } ImGui::End(); ImGui::PopStyleVar(); diff --git a/src/ui/ui_projects.cpp b/src/ui/ui_projects.cpp index a349814..a831f60 100644 --- a/src/ui/ui_projects.cpp +++ b/src/ui/ui_projects.cpp @@ -35,7 +35,7 @@ static void draw_project_form() float widthAvailable = ImGui::GetContentRegionAvail().x; ImGui::SetNextItemWidth(widthAvailable*0.2f); - ImGui::InputText(localize("contact.form.identifier"), active_project.id, IM_ARRAYSIZE(active_project.id)); + ImGui::InputText(localize("project.form.identifier"), active_project.id, IM_ARRAYSIZE(active_project.id)); if (!viewing_only) ImGui::EndDisabled(); ImGui::SetNextItemWidth(widthAvailable*0.5f); diff --git a/src/ui/ui_settings.cpp b/src/ui/ui_settings.cpp index 041b672..97e0503 100644 --- a/src/ui/ui_settings.cpp +++ b/src/ui/ui_settings.cpp @@ -1,3 +1,7 @@ +#include <stdlib.h> +#include <stdio.h> + +#include "strops.hpp" #include "ui.hpp" #include "imgui.h" #include "administration.hpp" @@ -6,17 +10,67 @@ extern bool draw_contact_form(contact* buffer, bool back_button_enabled = true, bool viewing_only = false); static contact company_info; +country_tax_bracket* tax_brackets; +u32 tax_bracket_count; + void ui_setup_settings() { company_info = administration_get_company_info(); + + tax_bracket_count = administration_get_tax_bracket_count(); + tax_brackets = (country_tax_bracket*)malloc(tax_bracket_count * sizeof(country_tax_bracket)); + administration_get_tax_brackets(tax_brackets); +} + +static void ui_draw_vat_rates() +{ + if (ImGui::BeginTable("TableVatRates", 2, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg)) { + + ImGui::TableSetupColumn(localize("settings.vat.table.country"), ImGuiTableColumnFlags_WidthFixed, 140); + ImGui::TableSetupColumn(localize("settings.vat.table.rates")); + + char prev_country[3]; + prev_country[0] = 0; + + for (u32 i = 0; i < tax_bracket_count; i++) { + country_tax_bracket c = tax_brackets[i]; + + if (strcmp(c.country_code, "00") == 0) + { + strops_copy(prev_country, c.country_code, 3); + } + else if (strcmp(c.country_code, prev_country) != 0) + { + strops_copy(prev_country, c.country_code, 3); + + ImGui::TableNextRow(); + ImGui::TableSetColumnIndex(0); ImGui::Text(""); + ImGui::TableSetBgColor(ImGuiTableBgTarget_CellBg, IM_COL32(69, 69, 69, 255)); + ImGui::TableSetColumnIndex(1); ImGui::Text(""); + ImGui::TableSetBgColor(ImGuiTableBgTarget_CellBg, IM_COL32(69, 69, 69, 255)); + + ImGui::TableNextRow(); + + char locale_buf[20]; + snprintf(locale_buf, sizeof(locale_buf), "country.%s", c.country_code); + ImGui::TableSetColumnIndex(0); ImGui::Text(localize(locale_buf)); + ImGui::TableSetColumnIndex(1); ImGui::Text(""); + } + + ImGui::TableNextRow(); + ImGui::TableSetColumnIndex(0); ImGui::Text(localize(c.description)); + ImGui::TableSetColumnIndex(1); ImGui::Text("%.2f%%", c.rate); + } + + ImGui::EndTable(); + } } void ui_draw_settings() { - // @localize if (ImGui::BeginTabBar("SettingsTabBar")) { - if (ImGui::BeginTabItem("Company")) + if (ImGui::BeginTabItem(localize("settings.table.company"))) { bool save = draw_contact_form(&company_info, false); @@ -25,9 +79,9 @@ void ui_draw_settings() } ImGui::EndTabItem(); } - if (ImGui::BeginTabItem("VAT Rates")) + if (ImGui::BeginTabItem(localize("settings.table.vatrates"))) { - ImGui::Text("This is the Broccoli tab!\nblah blah blah blah blah"); + ui_draw_vat_rates(); ImGui::EndTabItem(); } ImGui::EndTabBar(); |
