/* * 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. */ #include #include #include "ui.hpp" #include "assets.hpp" #include "strops.hpp" #include "config.hpp" #include "locales.hpp" #include "administration_writer.hpp" #include "administration_reader.hpp" void ui::draw_setup() { static int img = assets::load_image("img/splash"); ImVec2 area = ImGui::GetContentRegionAvail(); ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0.0f, 0.5f)); ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(10.0f, 10.0f)); ImGui::PushFont(ui::fontBig); const char* title = "OpenBooks"; ImVec2 textSize = ImGui::CalcTextSize(title); ImGui::SetCursorPos(ImVec2((area.x - textSize.x) * 0.5f, 20)); ImGui::Text(title); ImGui::PopFont(); ImGui::Spacing(); ImGui::Spacing(); if (ImGui::Button(ICON_FA_FILE_IMPORT " Load administration", ImVec2(area.x, 0))) { // @locale if (administration_reader::open_existing(NULL)) { ui::set_state(ui::main_state::UI_SETTINGS); ui::recreate_window_for_main_views(); } } if (ImGui::Button(ICON_FA_FOLDER_PLUS " Create administration", ImVec2(area.x, 0))) { // @locale if (administration_reader::open_new()) { ui::set_state(ui::main_state::UI_SETTINGS); ui::recreate_window_for_main_views(); } } ImGui::PopStyleVar(); ImGui::PopStyleVar(); char version_txt[100]; strops::format(version_txt, sizeof(version_txt), "VERSION: %s %s", PROGRAM_VERSION, _DATE_); textSize = ImGui::CalcTextSize(version_txt); ImGui::SetCursorPos(ImVec2(5, area.y)); ImGui::PushFont(ui::fontSmall); ImGui::Text(version_txt); ImGui::PopFont(); int imageW = 150; int imageH = 150; ImGui::SetCursorScreenPos(ImVec2(area.x - imageW + 20, area.y - imageH + 20)); ImGui::Image(img, ImVec2(imageW, imageH)); } void ui::setup_setup() { } void ui::destroy_setup() { }