diff options
Diffstat (limited to 'src/ui')
| -rw-r--r-- | src/ui/helpers.cpp | 42 | ||||
| -rw-r--r-- | src/ui/ui_contacts.cpp | 2 | ||||
| -rw-r--r-- | src/ui/ui_invoices.cpp | 30 | ||||
| -rw-r--r-- | src/ui/ui_main.cpp | 1 |
4 files changed, 19 insertions, 56 deletions
diff --git a/src/ui/helpers.cpp b/src/ui/helpers.cpp index 0cce207..7bde384 100644 --- a/src/ui/helpers.cpp +++ b/src/ui/helpers.cpp @@ -3,43 +3,6 @@ #include "locales.hpp" #include "strops.hpp" -static float toast_timer = 0.0f; -static const char* toast_msg = nullptr; -void ui_helper_show_toast(const char* msg) -{ - toast_msg = msg; - toast_timer = 3.0f; -} - -void ui_helper_draw_toasts() -{ - if (toast_timer > 0.0f && toast_msg) - { - toast_timer -= ImGui::GetIO().DeltaTime; - - const float pad = 10.0f; - const ImVec2 window_pos = ImVec2( - ImGui::GetIO().DisplaySize.x - pad, - ImGui::GetIO().DisplaySize.y - pad - ); - const ImVec2 window_pos_pivot = ImVec2(1.0f, 1.0f); - - ImGui::SetNextWindowPos(window_pos, ImGuiCond_Always, window_pos_pivot); - ImGui::SetNextWindowBgAlpha(0.85f); // semi-transparent - - ImGuiWindowFlags flags = ImGuiWindowFlags_NoDecoration | - ImGuiWindowFlags_AlwaysAutoResize | - ImGuiWindowFlags_NoFocusOnAppearing | - ImGuiWindowFlags_NoNav; - - if (ImGui::Begin("##Toast", nullptr, flags)) - { - ImGui::TextUnformatted(toast_msg); - } - ImGui::End(); - } -} - void ui_helper_draw_required_tag() { ImDrawList* draw_list = ImGui::GetWindowDrawList(); @@ -65,7 +28,7 @@ void ui_helper_draw_required_tag() ImGui::PopStyleColor(); } -int ui_helper_TextInputWithAutocomplete(const char* label, const char* hint, char* buffer, size_t buf_size, +int TextInputWithAutocomplete(const char* label, const char* hint, char* buffer, size_t buf_size, char* suggestions[], int suggestion_count) { int result = -1; @@ -110,4 +73,5 @@ int ui_helper_TextInputWithAutocomplete(const char* label, const char* hint, cha } } return result; -}
\ No newline at end of file +} + diff --git a/src/ui/ui_contacts.cpp b/src/ui/ui_contacts.cpp index 4db726d..a55fd73 100644 --- a/src/ui/ui_contacts.cpp +++ b/src/ui/ui_contacts.cpp @@ -102,7 +102,7 @@ void draw_contact_form_ex(contact* buffer, bool viewing_only = false, bool with_ autocomplete_strings[i] = autocomplete_list[i].name; } - int autocomplete_index = ui_helper_TextInputWithAutocomplete(localize("contact.form.fullname"), localize("contact.form.fullname"), + int autocomplete_index = TextInputWithAutocomplete(localize("contact.form.fullname"), localize("contact.form.fullname"), buffer->name, IM_ARRAYSIZE(buffer->name), (char**)autocomplete_strings, autocomplete_count); if (on_autocomplete) { diff --git a/src/ui/ui_invoices.cpp b/src/ui/ui_invoices.cpp index 0256fbd..c08dd76 100644 --- a/src/ui/ui_invoices.cpp +++ b/src/ui/ui_invoices.cpp @@ -39,8 +39,6 @@ void ui_setup_invoices() tax_bracket_list_buffer = (country_tax_bracket*) malloc(sizeof(country_tax_bracket) * tax_bracket_count); // @leak } -// TODO move custom ui functions to helpers.cpp - void draw_tax_bracket_selector(char* tax_bracket_id) { country_tax_bracket* selected_tax_bracket = NULL; @@ -134,7 +132,7 @@ bool draw_currency_selector(char* currency) if (ImGui::Selectable(currencies[n], isSelected)) { result = true; - strops_copy(currency, currencies[n], CURRENCY_LENGTH); + strops_copy(currency, currencies[n], MAX_LEN_CURRENCY); } if (isSelected) @@ -349,7 +347,7 @@ static void draw_invoice_items_form(invoice* invoice) free(buffer); } -void draw_invoice_form(invoice* buffer, bool viewing_only = false) +static void draw_invoice_form(invoice* buffer, bool viewing_only = false) { ImGui::BeginDisabled(); @@ -447,7 +445,7 @@ void draw_invoice_form(invoice* buffer, bool viewing_only = false) if (viewing_only) ImGui::EndDisabled(); } -void draw_invoices_list() +static void ui_draw_invoices_list() { const u32 items_per_page = 50; static s32 current_page = 0; @@ -529,7 +527,7 @@ void draw_invoices_list() { snprintf(btn_name, sizeof(btn_name), "%s##%d", localize("form.change"), i); if (ImGui::Button(btn_name)) { - active_invoice = c; + active_invoice = administration_invoice_create_copy(&c); // We create a copy because of billing item list pointers. current_view_state = view_state::EDIT; } } @@ -612,20 +610,22 @@ static void ui_draw_invoice_create() if (!can_save) ImGui::EndDisabled(); } +static void ui_draw_invoice_view() +{ + if (ImGui::Button(localize("form.back"))) { + current_view_state = view_state::LIST; + } + + draw_invoice_form(&active_invoice, true); +} + void ui_draw_invoices() { switch(current_view_state) { - case view_state::LIST: draw_invoices_list(); break; + case view_state::LIST: ui_draw_invoices_list(); break; case view_state::CREATE: ui_draw_invoice_create(); break; case view_state::EDIT: ui_draw_invoice_update(); break; - case view_state::VIEW: - { - if (ImGui::Button(localize("form.back"))) { - current_view_state = view_state::LIST; - } - - draw_invoice_form(&active_invoice, true); - } break; + case view_state::VIEW: ui_draw_invoice_view(); break; } }
\ No newline at end of file diff --git a/src/ui/ui_main.cpp b/src/ui/ui_main.cpp index 2d79129..d8fd5d4 100644 --- a/src/ui/ui_main.cpp +++ b/src/ui/ui_main.cpp @@ -108,7 +108,6 @@ void ui_draw_main() // Main content ImGui::Begin("AccountingMainWindow", nullptr, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse); if (drawcalls[dashboard_state]) drawcalls[dashboard_state](); - ui_helper_draw_toasts(); ImGui::End(); // Status bar. |
