2020-09-19 22:19:39 +00:00
|
|
|
#include <gui/style.h>
|
2020-10-07 20:44:54 +00:00
|
|
|
#include <imgui.h>
|
|
|
|
#include <imgui_internal.h>
|
|
|
|
#include <config.h>
|
2020-12-22 13:50:26 +00:00
|
|
|
#include <options.h>
|
2020-12-22 21:39:24 +00:00
|
|
|
#include <spdlog/spdlog.h>
|
|
|
|
#include <filesystem>
|
2020-08-16 01:39:05 +00:00
|
|
|
|
|
|
|
namespace style {
|
2020-11-30 20:17:36 +00:00
|
|
|
ImFont* baseFont;
|
|
|
|
ImFont* bigFont;
|
|
|
|
ImFont* hugeFont;
|
|
|
|
|
2021-06-23 19:45:38 +00:00
|
|
|
bool loadFonts(std::string resDir) {
|
2020-12-22 21:39:24 +00:00
|
|
|
if (!std::filesystem::is_directory(resDir)) {
|
2021-09-20 17:59:35 +00:00
|
|
|
spdlog::error("Invalid resource directory: {0}", resDir);
|
2020-12-22 21:39:24 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
baseFont = ImGui::GetIO().Fonts->AddFontFromFileTTF(((std::string)(resDir + "/fonts/Roboto-Medium.ttf")).c_str(), 16.0f);
|
2021-01-28 20:10:08 +00:00
|
|
|
bigFont = ImGui::GetIO().Fonts->AddFontFromFileTTF(((std::string)(resDir + "/fonts/Roboto-Medium.ttf")).c_str(), 45.0f);
|
2020-12-22 21:39:24 +00:00
|
|
|
hugeFont = ImGui::GetIO().Fonts->AddFontFromFileTTF(((std::string)(resDir + "/fonts/Roboto-Medium.ttf")).c_str(), 128.0f);
|
2020-08-16 01:39:05 +00:00
|
|
|
|
2020-12-22 21:39:24 +00:00
|
|
|
return true;
|
2020-08-17 00:39:56 +00:00
|
|
|
}
|
|
|
|
|
2020-08-16 01:39:05 +00:00
|
|
|
void beginDisabled() {
|
|
|
|
ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true);
|
2021-06-23 19:45:38 +00:00
|
|
|
auto& style = ImGui::GetStyle();
|
|
|
|
ImVec4* colors = style.Colors;
|
|
|
|
ImVec4 btnCol = colors[ImGuiCol_Button];
|
2021-06-23 20:24:58 +00:00
|
|
|
ImVec4 frameCol = colors[ImGuiCol_FrameBg];
|
|
|
|
ImVec4 textCol = colors[ImGuiCol_Text];
|
2021-06-23 19:45:38 +00:00
|
|
|
btnCol.w = 0.15f;
|
|
|
|
frameCol.w = 0.30f;
|
|
|
|
textCol.w = 0.65f;
|
|
|
|
ImGui::PushStyleColor(ImGuiCol_Button, btnCol);
|
|
|
|
ImGui::PushStyleColor(ImGuiCol_FrameBg, frameCol);
|
|
|
|
ImGui::PushStyleColor(ImGuiCol_Text, textCol);
|
2020-08-16 01:39:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void endDisabled() {
|
|
|
|
ImGui::PopItemFlag();
|
2020-08-17 00:39:56 +00:00
|
|
|
ImGui::PopStyleColor(3);
|
2020-08-16 01:39:05 +00:00
|
|
|
}
|
2021-08-31 16:39:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace ImGui {
|
2021-10-02 23:41:18 +00:00
|
|
|
void LeftLabel(const char* text) {
|
2021-08-31 16:39:48 +00:00
|
|
|
float vpos = ImGui::GetCursorPosY();
|
|
|
|
ImGui::SetCursorPosY(vpos + GImGui->Style.FramePadding.y);
|
|
|
|
ImGui::Text(text);
|
|
|
|
ImGui::SameLine();
|
|
|
|
ImGui::SetCursorPosY(vpos);
|
|
|
|
}
|
2022-01-21 19:22:13 +00:00
|
|
|
|
|
|
|
void FillWidth() {
|
|
|
|
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvailWidth());
|
|
|
|
}
|
2020-08-16 01:39:05 +00:00
|
|
|
}
|