SDRPlusPlus/core/src/gui/style.cpp

46 lines
1.5 KiB
C++
Raw Normal View History

2020-09-20 00:19:39 +02:00
#include <gui/style.h>
#include <imgui.h>
#include <imgui_internal.h>
#include <config.h>
2020-12-22 14:50:26 +01:00
#include <options.h>
2020-12-22 22:39:24 +01:00
#include <spdlog/spdlog.h>
#include <filesystem>
2020-08-16 03:39:05 +02:00
namespace style {
2020-11-30 21:17:36 +01:00
ImFont* baseFont;
ImFont* bigFont;
ImFont* hugeFont;
2021-06-23 21:45:38 +02:00
bool loadFonts(std::string resDir) {
2020-12-22 22:39:24 +01:00
if (!std::filesystem::is_directory(resDir)) {
spdlog::error("Inavlid resource directory: {0}", resDir);
return false;
}
baseFont = ImGui::GetIO().Fonts->AddFontFromFileTTF(((std::string)(resDir + "/fonts/Roboto-Medium.ttf")).c_str(), 16.0f);
bigFont = ImGui::GetIO().Fonts->AddFontFromFileTTF(((std::string)(resDir + "/fonts/Roboto-Medium.ttf")).c_str(), 45.0f);
2020-12-22 22:39:24 +01:00
hugeFont = ImGui::GetIO().Fonts->AddFontFromFileTTF(((std::string)(resDir + "/fonts/Roboto-Medium.ttf")).c_str(), 128.0f);
2020-08-16 03:39:05 +02:00
2020-12-22 22:39:24 +01:00
return true;
2020-08-17 02:39:56 +02:00
}
2020-08-16 03:39:05 +02:00
void beginDisabled() {
ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true);
2021-06-23 21:45:38 +02:00
auto& style = ImGui::GetStyle();
ImVec4* colors = style.Colors;
ImVec4 btnCol = colors[ImGuiCol_Button];
ImVec4 frameCol = colors[ImGuiCol_Button];
ImVec4 textCol = colors[ImGuiCol_Button];
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 03:39:05 +02:00
}
void endDisabled() {
ImGui::PopItemFlag();
2020-08-17 02:39:56 +02:00
ImGui::PopStyleColor(3);
2020-08-16 03:39:05 +02:00
}
}