diff options
| author | Aldrik Ramaekers <aldrikboy@gmail.com> | 2025-08-09 08:33:08 +0200 |
|---|---|---|
| committer | Aldrik Ramaekers <aldrikboy@gmail.com> | 2025-08-09 08:33:08 +0200 |
| commit | 5d34aff5888d3f0c624251f15bedb96c347978d6 (patch) | |
| tree | 69a49651271d645ca7eaa114cb1830bf759c0930 /src/ui/ui_main.cpp | |
| parent | b94a7ae06b20d550c727d5192cea8baf3e8fb641 (diff) | |
refactors
Diffstat (limited to 'src/ui/ui_main.cpp')
| -rw-r--r-- | src/ui/ui_main.cpp | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/src/ui/ui_main.cpp b/src/ui/ui_main.cpp new file mode 100644 index 0000000..f6661b8 --- /dev/null +++ b/src/ui/ui_main.cpp @@ -0,0 +1,110 @@ +#include "ui.hpp" +#include "imgui.h" +#include "administration.hpp" +#include "locales.hpp" + +typedef enum +{ + INVOICES = 0, + EXPENSES = 1, + CONTACTS = 2, + REPORT_RESULTS = 3, + REPORT_TAX = 4, + PROJECTS = 5, + + END +} dashboard_view_state; + +static dashboard_view_state dashboard_state = dashboard_view_state::INVOICES; +void (*drawcalls[dashboard_view_state::END])(void) = { + 0, + 0, + ui_draw_contacts, + 0, + 0, + ui_draw_projects, +}; + +void ui_draw_main() +{ + // @localize + if (ImGui::BeginMainMenuBar()) + { + if (ImGui::BeginMenu("File")) + { + if (ImGui::MenuItem("Open", "Ctrl+O")) { /* Handle Open */ } + if (ImGui::MenuItem("Save", "Ctrl+S")) { /* Handle Save */ } + + ImGui::EndMenu(); + } + ImGui::EndMainMenuBar(); + } + + ImGuiIO& io = ImGui::GetIO(); + float menuBarHeight = ImGui::GetFrameHeight(); + float statusBarHeight = 26.0f; + float sidePanelWidth = 120.0f; + ImGui::SetNextWindowPos(ImVec2(0, menuBarHeight)); + ImGui::SetNextWindowSize(ImVec2(sidePanelWidth, io.DisplaySize.y - menuBarHeight - statusBarHeight)); + + // Side panel + ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0)); + ImGui::Begin("SidePanel", nullptr, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse); + { + // Navigation buttons with custom styling + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.0f, 0.0f, 0.0f, 0.0f)); // Transparent background + ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0.0f, 0.5f)); + ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0)); // Reduce spacing between buttons + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(10.0f, 0.0f)); + + 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; + + 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; + ImGui::PopStyleVar(); + } + + if (ImGui::Button(localize("nav.Projects"), ImVec2(buttonWidth, 24))) dashboard_state = dashboard_view_state::PROJECTS; + + ImGui::PopStyleColor(1); + ImGui::PopStyleVar(3); + } + ImGui::End(); + ImGui::PopStyleVar(); + + ImGui::SetNextWindowPos(ImVec2(sidePanelWidth, menuBarHeight)); + ImGui::SetNextWindowSize(ImVec2(io.DisplaySize.x - sidePanelWidth, io.DisplaySize.y - menuBarHeight - statusBarHeight)); + + // Main content + ImGui::Begin("AccountingMainWindow", nullptr, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse); + if (drawcalls[dashboard_state]) drawcalls[dashboard_state](); + ImGui::End(); + + // Status bar. + ImGui::SetNextWindowPos(ImVec2(0, io.DisplaySize.y - statusBarHeight)); + ImGui::SetNextWindowSize(ImVec2(io.DisplaySize.x, statusBarHeight)); + + ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(10, 3)); + ImGui::Begin("StatusBar", nullptr, + ImGuiWindowFlags_NoTitleBar | + ImGuiWindowFlags_NoResize | + ImGuiWindowFlags_NoMove | + ImGuiWindowFlags_NoScrollbar | + ImGuiWindowFlags_NoSavedSettings | + ImGuiWindowFlags_NoBringToFrontOnFocus | + ImGuiWindowFlags_NoCollapse); + + ImGui::Text("Working on: %s", administration_get_file_path()); // @localize + + ImGui::End(); + ImGui::PopStyleVar(); +}
\ No newline at end of file |
