From 63f4d553cca6c8c9371d51ecd91f7e535c2a7a51 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Wed, 18 Aug 2021 23:12:27 +0200 Subject: [PATCH] ui: Add tooltips to custom titlebar buttons --- external/ImGui/include/imgui_imhex_extensions.h | 2 ++ external/ImGui/source/imgui_imhex_extensions.cpp | 8 ++++++++ include/window.hpp | 2 -- plugins/builtin/source/lang/de_DE.cpp | 2 ++ plugins/builtin/source/lang/en_US.cpp | 2 ++ plugins/builtin/source/lang/it_IT.cpp | 2 ++ source/views/view_settings.cpp | 4 +--- source/window/linux_window.cpp | 4 ++++ source/window/macos_window.cpp | 4 ++++ source/window/win_window.cpp | 2 ++ 10 files changed, 27 insertions(+), 5 deletions(-) diff --git a/external/ImGui/include/imgui_imhex_extensions.h b/external/ImGui/include/imgui_imhex_extensions.h index d03f24eeb..5c3112cf8 100644 --- a/external/ImGui/include/imgui_imhex_extensions.h +++ b/external/ImGui/include/imgui_imhex_extensions.h @@ -38,6 +38,8 @@ namespace ImGui { void Header(const char *label, bool firstEntry = false); + void InfoTooltip(const char *text); + inline bool HasSecondPassed() { return static_cast(ImGui::GetTime() * 100) % 100 <= static_cast(ImGui::GetIO().DeltaTime * 100); } diff --git a/external/ImGui/source/imgui_imhex_extensions.cpp b/external/ImGui/source/imgui_imhex_extensions.cpp index b260feadc..b3ceeb06a 100644 --- a/external/ImGui/source/imgui_imhex_extensions.cpp +++ b/external/ImGui/source/imgui_imhex_extensions.cpp @@ -204,6 +204,14 @@ namespace ImGui { ImGui::Separator(); } + void InfoTooltip(const char *text) { + if (IsItemHovered()) { + BeginTooltip(); + TextUnformatted(text); + EndTooltip(); + } + } + ImU32 GetCustomColorU32(ImGuiCustomCol idx, float alpha_mul) { auto& customData = *static_cast(GImGui->IO.UserData); ImVec4 c = customData.Colors[idx]; diff --git a/include/window.hpp b/include/window.hpp index ecb5f643e..4c518f9e6 100644 --- a/include/window.hpp +++ b/include/window.hpp @@ -65,8 +65,6 @@ namespace hex { ImGui::Texture m_bannerTexture; ImGui::Texture m_logoTexture; - - std::filesystem::path m_safetyBackupPath; }; diff --git a/plugins/builtin/source/lang/de_DE.cpp b/plugins/builtin/source/lang/de_DE.cpp index 96c6350b4..be79aced1 100644 --- a/plugins/builtin/source/lang/de_DE.cpp +++ b/plugins/builtin/source/lang/de_DE.cpp @@ -13,6 +13,8 @@ namespace hex::plugin::builtin { { "hex.menu.view.fps", "FPS anzeigen" }, { "hex.menu.view.demo", "ImGui Demo anzeigen" }, { "hex.menu.help", "Hilfe" }, + { "hex.menu.feedback", "Feedback hinterlassen" }, + { "hex.menu.debug_build", "Debug build"}, { "hex.welcome.header.main", "Wilkommen zu ImHex" }, { "hex.welcome.header.start", "Start" }, diff --git a/plugins/builtin/source/lang/en_US.cpp b/plugins/builtin/source/lang/en_US.cpp index f26c277e0..360119c1f 100644 --- a/plugins/builtin/source/lang/en_US.cpp +++ b/plugins/builtin/source/lang/en_US.cpp @@ -13,6 +13,8 @@ namespace hex::plugin::builtin { { "hex.menu.view.fps", "Display FPS" }, { "hex.menu.view.demo", "Show ImGui Demo" }, { "hex.menu.help", "Help" }, + { "hex.menu.feedback", "Leave Feedback" }, + { "hex.menu.debug_build", "Debug build"}, { "hex.welcome.header.main", "Welcome to ImHex" }, { "hex.welcome.header.start", "Start" }, diff --git a/plugins/builtin/source/lang/it_IT.cpp b/plugins/builtin/source/lang/it_IT.cpp index 090ac58b0..2dd076488 100644 --- a/plugins/builtin/source/lang/it_IT.cpp +++ b/plugins/builtin/source/lang/it_IT.cpp @@ -13,6 +13,8 @@ namespace hex::plugin::builtin { { "hex.menu.view.fps", "Mostra FPS" }, { "hex.menu.view.demo", "Mostra la demo di ImGui" }, { "hex.menu.help", "Aiuto" }, + //{ "hex.menu.feedback", "Leave Feedback" }, + //{ "hex.menu.debug_build", "Debug build"}, { "hex.welcome.header.main", "Benvenuto in ImHex" }, { "hex.welcome.header.start", "Inizia" }, diff --git a/source/views/view_settings.cpp b/source/views/view_settings.cpp index dfb46086a..f75924ec1 100644 --- a/source/views/view_settings.cpp +++ b/source/views/view_settings.cpp @@ -43,9 +43,7 @@ namespace hex { View::doLater([]{ ImGui::OpenPopup(View::toWindowName("hex.view.settings.name").c_str()); }); this->getWindowOpenState() = true; } - if (ImGui::MenuItem("Crash")) { - *reinterpret_cast(8) = 16; - } + ImGui::EndMenu(); } } diff --git a/source/window/linux_window.cpp b/source/window/linux_window.cpp index fc0acf5e5..1e09780aa 100644 --- a/source/window/linux_window.cpp +++ b/source/window/linux_window.cpp @@ -12,6 +12,10 @@ } + void Window::drawTitleBar() { + + } + } #endif \ No newline at end of file diff --git a/source/window/macos_window.cpp b/source/window/macos_window.cpp index 8ff09a68d..6fa7badb2 100644 --- a/source/window/macos_window.cpp +++ b/source/window/macos_window.cpp @@ -12,6 +12,10 @@ } + void Window::drawTitleBar() { + + } + } #endif \ No newline at end of file diff --git a/source/window/win_window.cpp b/source/window/win_window.cpp index 9a28c64ea..93d212963 100644 --- a/source/window/win_window.cpp +++ b/source/window/win_window.cpp @@ -148,9 +148,11 @@ #if defined(DEBUG) if (ImGui::Button(ICON_VS_DEBUG, buttonSize)) hex::openWebpage("https://imhex.werwolv.net/debug"); + ImGui::InfoTooltip("hex.menu.debug_build"_lang); #endif if (ImGui::Button(ICON_VS_SMILEY, buttonSize)) hex::openWebpage("mailto://hey@werwolv.net"); + ImGui::InfoTooltip("hex.menu.feedback"_lang); ImGui::SetCursorPosX(ImGui::GetWindowWidth() - buttonSize.x * 3); if (ImGui::Button(ICON_VS_CHROME_MINIMIZE, buttonSize))