From 391c8acfe440be2df9c623e7091cb6c180fa697c Mon Sep 17 00:00:00 2001 From: WerWolv Date: Mon, 10 Apr 2023 01:46:55 +0200 Subject: [PATCH] impr: Added path tooltips to accept pattern popup --- .../include/content/popups/popup_docs_question.hpp | 5 +++++ .../include/content/views/view_pattern_editor.hpp | 12 +++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/plugins/builtin/include/content/popups/popup_docs_question.hpp b/plugins/builtin/include/content/popups/popup_docs_question.hpp index 194e915e9..d41d321c2 100644 --- a/plugins/builtin/include/content/popups/popup_docs_question.hpp +++ b/plugins/builtin/include/content/popups/popup_docs_question.hpp @@ -37,7 +37,9 @@ namespace hex::plugin::builtin { else ImGui::TextFormattedCentered("{}", "hex.builtin.popup.docs_question.prompt"_lang); } else { + int id = 1; for (auto &[type, text] : this->m_answer) { + ImGui::PushID(id); switch (type) { case TextBlockType::Text: ImGui::TextFormattedWrapped("{}", text); @@ -54,6 +56,9 @@ namespace hex::plugin::builtin { break; } + + ImGui::PopID(); + id += 1; } } } else { diff --git a/plugins/builtin/include/content/views/view_pattern_editor.hpp b/plugins/builtin/include/content/views/view_pattern_editor.hpp index a66527e29..a53d0d223 100644 --- a/plugins/builtin/include/content/views/view_pattern_editor.hpp +++ b/plugins/builtin/include/content/views/view_pattern_editor.hpp @@ -47,6 +47,8 @@ namespace hex::plugin::builtin { PopupAcceptPattern(ViewPatternEditor *view) : Popup("hex.builtin.view.pattern_editor.accept_pattern"), m_view(view) {} void drawContent() override { + auto provider = ImHexApi::Provider::get(); + ImGui::TextFormattedWrapped("{}", static_cast("hex.builtin.view.pattern_editor.accept_pattern.desc"_lang)); std::vector entries; @@ -59,8 +61,14 @@ namespace hex::plugin::builtin { if (ImGui::BeginListBox("##patterns_accept", ImVec2(-FLT_MIN, 0))) { u32 index = 0; for (auto &path : this->m_view->m_possiblePatternFiles) { - if (ImGui::Selectable(wolv::util::toUTF8String(path.filename()).c_str(), index == this->m_view->m_selectedPatternFile)) + if (ImGui::Selectable(wolv::util::toUTF8String(path.filename()).c_str(), index == this->m_view->m_selectedPatternFile, ImGuiSelectableFlags_DontClosePopups)) this->m_view->m_selectedPatternFile = index; + + if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(0)) + this->m_view->loadPatternFile(this->m_view->m_possiblePatternFiles[this->m_view->m_selectedPatternFile], provider); + + ImGui::InfoTooltip(wolv::util::toUTF8String(path).c_str()); + index++; } @@ -70,8 +78,6 @@ namespace hex::plugin::builtin { ImGui::NewLine(); ImGui::TextUnformatted("hex.builtin.view.pattern_editor.accept_pattern.question"_lang); - auto provider = ImHexApi::Provider::get(); - confirmButtons( "hex.builtin.common.yes"_lang, "hex.builtin.common.no"_lang, [this, provider] { this->m_view->loadPatternFile(this->m_view->m_possiblePatternFiles[this->m_view->m_selectedPatternFile], provider);