mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2024-11-15 06:52:52 +01:00
46 lines
1.5 KiB
C++
46 lines
1.5 KiB
C++
#include <gui/style.h>
|
|
#include <imgui.h>
|
|
#include <imgui_internal.h>
|
|
#include <config.h>
|
|
#include <options.h>
|
|
#include <spdlog/spdlog.h>
|
|
#include <filesystem>
|
|
|
|
namespace style {
|
|
ImFont* baseFont;
|
|
ImFont* bigFont;
|
|
ImFont* hugeFont;
|
|
|
|
bool loadFonts(std::string resDir) {
|
|
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);
|
|
hugeFont = ImGui::GetIO().Fonts->AddFontFromFileTTF(((std::string)(resDir + "/fonts/Roboto-Medium.ttf")).c_str(), 128.0f);
|
|
|
|
return true;
|
|
}
|
|
|
|
void beginDisabled() {
|
|
ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true);
|
|
auto& style = ImGui::GetStyle();
|
|
ImVec4* colors = style.Colors;
|
|
ImVec4 btnCol = colors[ImGuiCol_Button];
|
|
ImVec4 frameCol = colors[ImGuiCol_FrameBg];
|
|
ImVec4 textCol = colors[ImGuiCol_Text];
|
|
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);
|
|
}
|
|
|
|
void endDisabled() {
|
|
ImGui::PopItemFlag();
|
|
ImGui::PopStyleColor(3);
|
|
}
|
|
} |