From 7f75f814e364359586271071aa873c1cd64a2f73 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Wed, 21 Apr 2021 19:27:05 +0200 Subject: [PATCH] ui: Added some more icons in various places --- source/init/splash_window.cpp | 39 ++++++++++++++++++++++++++++++++++- source/views/view_help.cpp | 4 ++-- source/window.cpp | 2 +- 3 files changed, 41 insertions(+), 4 deletions(-) diff --git a/source/init/splash_window.cpp b/source/init/splash_window.cpp index e7bd400bd..6d1efd5d4 100644 --- a/source/init/splash_window.cpp +++ b/source/init/splash_window.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -91,7 +92,14 @@ namespace hex::init { auto drawList = ImGui::GetOverlayDrawList(); drawList->AddImage(splashTexture, ImVec2(0, 0), ImVec2(splashWidth, splashHeight)); - drawList->AddText(ImVec2(15, 120), ImColor(0xFF, 0xFF, 0xFF, 0xFF), hex::format("WerWolv 2020 - {0}\n{1} : {2}@{3}", &__DATE__[7], IMHEX_VERSION, GIT_BRANCH, GIT_COMMIT_HASH).c_str()); + + #if defined(DEBUG) + drawList->AddText(ImVec2(15, 120), ImColor(0xFF, 0xFF, 0xFF, 0xFF), hex::format("WerWolv 2020 - {0}", &__DATE__[7]).c_str()); + drawList->AddText(ImVec2(15, 140), ImColor(0xFF, 0xFF, 0xFF, 0xFF), hex::format("{0} : {1} {2}@{3}", IMHEX_VERSION, ICON_FA_CODE_BRANCH, GIT_BRANCH, GIT_COMMIT_HASH).c_str()); + #else + drawList->AddText(ImVec2(15, 120), ImColor(0xFF, 0xFF, 0xFF, 0xFF), hex::format("WerWolv 2020 - {0}", &__DATE__[7]).c_str()); + drawList->AddText(ImVec2(15, 140), ImColor(0xFF, 0xFF, 0xFF, 0xFF), hex::format("{0}", IMHEX_VERSION).c_str()); + #endif drawList->AddRectFilled(ImVec2(0, splashHeight - 5), ImVec2(splashWidth * this->m_progress, splashHeight), 0xFFFFFFFF); drawList->AddText(ImVec2(15, splashHeight - 22), ImColor(0xFF, 0xFF, 0xFF, 0xFF), this->m_currTaskName.data()); } @@ -174,6 +182,35 @@ namespace hex::init { ImGui_ImplGlfw_InitForOpenGL(this->m_window, true); ImGui_ImplOpenGL3_Init("#version 130"); + + auto &io = ImGui::GetIO(); + + io.Fonts->Clear(); + + ImFontConfig cfg; + cfg.OversampleH = cfg.OversampleV = 1, cfg.PixelSnapH = true; + cfg.SizePixels = 13.0f; + io.Fonts->AddFontDefault(&cfg); + + cfg.MergeMode = true; + + ImWchar fontAwesomeRange[] = { + ICON_MIN_FA, ICON_MAX_FA, + 0 + }; + std::uint8_t *px; + int w, h; + io.Fonts->AddFontFromMemoryCompressedTTF(font_awesome_compressed_data, font_awesome_compressed_size, 11.0f, &cfg, fontAwesomeRange); + io.Fonts->GetTexDataAsRGBA32(&px, &w, &h); + + // Create new font atlas + GLuint tex; + glGenTextures(1, &tex); + glBindTexture(GL_TEXTURE_2D, tex); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, w, h, 0, GL_RGBA8, GL_UNSIGNED_INT, px); + io.Fonts->SetTexID(reinterpret_cast(tex)); } void WindowSplash::deinitGLFW() { diff --git a/source/views/view_help.cpp b/source/views/view_help.cpp index d3fd8b9b7..bcc86c0ec 100644 --- a/source/views/view_help.cpp +++ b/source/views/view_help.cpp @@ -30,8 +30,8 @@ namespace hex { void ViewHelp::drawAboutPopup() { if (ImGui::BeginPopupModal(View::toWindowName("hex.view.about.name").c_str(), &this->m_aboutWindowOpen, ImGuiWindowFlags_AlwaysAutoResize)) { - ImGui::Text("ImHex Hex Editor v%s by WerWolv -", IMHEX_VERSION); - #if defined(GIT_BRANCH) && defined(GIT_COMMIT_HASH) + ImGui::Text("ImHex Hex Editor v%s by WerWolv - " ICON_FA_CODE_BRANCH, IMHEX_VERSION); + #if defined(DEBUG) && defined(GIT_BRANCH) && defined(GIT_COMMIT_HASH) ImGui::SameLine(); if (ImGui::Hyperlink(hex::format("{0}@{1}", GIT_BRANCH, GIT_COMMIT_HASH).c_str())) hex::openWebpage("https://github.com/WerWolv/ImHex/commit/" GIT_COMMIT_HASH); diff --git a/source/window.cpp b/source/window.cpp index bc92498b6..7c4740206 100644 --- a/source/window.cpp +++ b/source/window.cpp @@ -725,7 +725,7 @@ namespace hex { }; std::uint8_t *px; int w, h; - io.Fonts->AddFontFromMemoryCompressedTTF(font_awesome_compressed_data, font_awesome_compressed_size, 13.0f * this->m_fontScale, &cfg, fontAwesomeRange); + io.Fonts->AddFontFromMemoryCompressedTTF(font_awesome_compressed_data, font_awesome_compressed_size, 11.0f * this->m_fontScale, &cfg, fontAwesomeRange); io.Fonts->GetTexDataAsRGBA32(&px, &w, &h); // Create new font atlas