/* * Copyright (c) 2025 Aldrik Ramaekers * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #pragma once #include "imgui.h" #include "administration.hpp" #define STATUS_TEXT_LEN 64 #define STATUS_DURATION 4.0f #define STATUS_FLASH_INTERVAL 0.1f #define STATUS_MAX_FLASHES 2 #define COLOR_ERROR IM_COL32(235, 64, 52, 255) #define COLOR_DEFAULT IM_COL32(235, 255, 255, 255) typedef enum { UI_INVOICES = 0, UI_EXPENSES = 1, UI_CONTACTS = 2, UI_REPORT_RESULTS = 3, UI_REPORT_TAX = 4, UI_PROJECTS = 5, UI_SETTINGS = 6, UI_LOG = 7, UI_END } main_state; typedef enum { LIST, EDIT, CREATE, VIEW, } view_state; typedef struct { bool visible; int flash_count; int color; char text[STATUS_TEXT_LEN]; float time; bool loading; } ui_status; extern ImFont* fontBold; extern ImFont* fontBig; ui_status ui_get_status(); void ui_set_status_loading(bool loading); void ui_set_status_error(const char* txt); void ui_set_status_ex(const char* txt, int color); void ui_set_status(const char* txt); void ui_draw_status(); void ui_set_state(main_state state); void ui_draw_main(); void ui_draw_contacts(); void ui_draw_projects(); void ui_draw_invoices(); void ui_draw_settings(); void ui_draw_expenses(); void ui_draw_earnings(); void ui_draw_log(); void ui_setup_invoices(); void ui_setup_contacts(); void ui_setup_projects(); void ui_setup_settings(); void ui_setup_expenses(); void ui_setup_earnings(); void ui_destroy_invoices(); void ui_destroy_settings(); void ui_destroy_expenses(); void ui_destroy_earnings(); // Custom imgui widgets. namespace ImGui { int TextInputWithAutocomplete(const char* hint, char* buffer, size_t buf_size, char** suggestions, int suggestion_count, bool has_error); void FormContactAutocomplete(contact* buffer, bool has_error); void FormInputTextWithErrorHint(const char* hint, char* buffer, size_t buf_size, bool has_error); void FormCountryCombo(char* buffer, size_t buf_size); void FormContactTypeCombo(contact_type* type); void FormCostCenterCombo(char* costcenter_id); void FormProjectCombo(char* project_id); void FormTaxRateCombo(char* tax_rate_id, char* orig_country, char* dest_country); bool FormCurrencyCombo(char* currency); void FormToggleCombo(bool *buffer, char* option1, char* option2); }