diff options
Diffstat (limited to 'src/ui/ui_main.cpp')
| -rw-r--r-- | src/ui/ui_main.cpp | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/src/ui/ui_main.cpp b/src/ui/ui_main.cpp index f6661b8..8af8dbc 100644 --- a/src/ui/ui_main.cpp +++ b/src/ui/ui_main.cpp @@ -11,20 +11,38 @@ typedef enum REPORT_RESULTS = 3, REPORT_TAX = 4, PROJECTS = 5, + SETTINGS = 6, END } dashboard_view_state; static dashboard_view_state dashboard_state = dashboard_view_state::INVOICES; void (*drawcalls[dashboard_view_state::END])(void) = { - 0, + ui_draw_invoices, 0, ui_draw_contacts, 0, 0, ui_draw_projects, + ui_draw_settings, }; +void (*setupcalls[dashboard_view_state::END])(void) = { + 0, + 0, + ui_setup_contacts, + 0, + 0, + ui_setup_projects, + ui_setup_settings, +}; + +static void set_dashboard_state(dashboard_view_state state) +{ + dashboard_state = state; + if (setupcalls[dashboard_state]) setupcalls[dashboard_state](); +} + void ui_draw_main() { // @localize @@ -59,21 +77,22 @@ void ui_draw_main() float buttonWidth = sidePanelWidth; - if (ImGui::Button(localize("nav.invoices"), ImVec2(buttonWidth, 24))) dashboard_state = dashboard_view_state::INVOICES; - if (ImGui::Button(localize("nav.expenses"), ImVec2(buttonWidth, 24))) dashboard_state = dashboard_view_state::EXPENSES; - if (ImGui::Button(localize("nav.contacts"), ImVec2(buttonWidth, 24))) dashboard_state = dashboard_view_state::CONTACTS; + if (ImGui::Button(localize("nav.invoices"), ImVec2(buttonWidth, 24))) set_dashboard_state(dashboard_view_state::INVOICES); + if (ImGui::Button(localize("nav.expenses"), ImVec2(buttonWidth, 24))) set_dashboard_state(dashboard_view_state::EXPENSES); + if (ImGui::Button(localize("nav.contacts"), ImVec2(buttonWidth, 24))) set_dashboard_state(dashboard_view_state::CONTACTS); static bool reports_opened = false; if (ImGui::Button(localize("nav.reports"), ImVec2(buttonWidth, 24))) reports_opened = !reports_opened; if (reports_opened) { ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(20.0f, 0.0f)); - if (ImGui::Button(localize("nav.reports.results"), ImVec2(buttonWidth, 24))) dashboard_state = dashboard_view_state::REPORT_RESULTS; - if (ImGui::Button(localize("nav.reports.tax"), ImVec2(buttonWidth, 24))) dashboard_state = dashboard_view_state::REPORT_TAX; + if (ImGui::Button(localize("nav.reports.results"), ImVec2(buttonWidth, 24))) set_dashboard_state(dashboard_view_state::REPORT_RESULTS); + if (ImGui::Button(localize("nav.reports.tax"), ImVec2(buttonWidth, 24))) set_dashboard_state(dashboard_view_state::REPORT_TAX); ImGui::PopStyleVar(); } - if (ImGui::Button(localize("nav.Projects"), ImVec2(buttonWidth, 24))) dashboard_state = dashboard_view_state::PROJECTS; + 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 ImGui::PopStyleColor(1); ImGui::PopStyleVar(3); @@ -87,6 +106,7 @@ 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. |
