diff --git a/lib/libimhex/include/hex/ui/imgui_imhex_extensions.h b/lib/libimhex/include/hex/ui/imgui_imhex_extensions.h index 45c4a601e..dc55dd6b2 100644 --- a/lib/libimhex/include/hex/ui/imgui_imhex_extensions.h +++ b/lib/libimhex/include/hex/ui/imgui_imhex_extensions.h @@ -132,6 +132,7 @@ namespace ImGui { bool InputText(const char* label, std::string &buffer, ImGuiInputTextFlags flags = ImGuiInputTextFlags_None); bool InputText(const char *label, std::u8string &buffer, ImGuiInputTextFlags flags = ImGuiInputTextFlags_None); bool InputTextMultiline(const char* label, std::string &buffer, const ImVec2& size = ImVec2(0, 0), ImGuiInputTextFlags flags = ImGuiInputTextFlags_None); + bool InputTextWithHint(const char *label, const char *hint, std::string &buffer, ImGuiInputTextFlags flags = ImGuiInputTextFlags_None); bool InputScalarCallback(const char* label, ImGuiDataType data_type, void* p_data, const char* format, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data); diff --git a/lib/libimhex/source/ui/imgui_imhex_extensions.cpp b/lib/libimhex/source/ui/imgui_imhex_extensions.cpp index 72e0fb4b7..931c298e1 100644 --- a/lib/libimhex/source/ui/imgui_imhex_extensions.cpp +++ b/lib/libimhex/source/ui/imgui_imhex_extensions.cpp @@ -553,6 +553,10 @@ namespace ImGui { return ImGui::InputText(label, buffer.data(), buffer.size() + 1, ImGuiInputTextFlags_CallbackResize | flags, ImGui::UpdateStringSizeCallback, &buffer); } + bool InputTextWithHint(const char *label, const char *hint, std::string &buffer, ImGuiInputTextFlags flags) { + return ImGui::InputTextWithHint(label, hint, buffer.data(), buffer.size() + 1, ImGuiInputTextFlags_CallbackResize | flags, ImGui::UpdateStringSizeCallback, &buffer); + } + bool InputText(const char *label, std::u8string &buffer, ImGuiInputTextFlags flags) { return ImGui::InputText(label, reinterpret_cast(buffer.data()), buffer.size() + 1, ImGuiInputTextFlags_CallbackResize | flags, ImGui::UpdateStringSizeCallback, &buffer); } diff --git a/plugins/builtin/include/content/views/view_bookmarks.hpp b/plugins/builtin/include/content/views/view_bookmarks.hpp index 89d5eadb2..3752b53d5 100644 --- a/plugins/builtin/include/content/views/view_bookmarks.hpp +++ b/plugins/builtin/include/content/views/view_bookmarks.hpp @@ -16,6 +16,7 @@ namespace hex::plugin::builtin { private: std::list m_bookmarks; + std::string m_currFilter; }; } \ No newline at end of file diff --git a/plugins/builtin/source/content/views/view_bookmarks.cpp b/plugins/builtin/source/content/views/view_bookmarks.cpp index ac0f1fd7a..7d1438e5f 100644 --- a/plugins/builtin/source/content/views/view_bookmarks.cpp +++ b/plugins/builtin/source/content/views/view_bookmarks.cpp @@ -122,17 +122,29 @@ namespace hex::plugin::builtin { void ViewBookmarks::drawContent() { if (ImGui::Begin(View::toWindowName("hex.builtin.view.bookmarks.name").c_str(), &this->getWindowOpenState())) { - if (ImGui::BeginChild("##scrolling")) { + + ImGui::PushItemWidth(ImGui::GetContentRegionAvailWidth()); + ImGui::InputTextWithHint("##filter", "Filter", this->m_currFilter); + ImGui::PopItemWidth(); + + ImGui::NewLine(); + + if (ImGui::BeginChild("##bookmarks")) { if (this->m_bookmarks.empty()) { ImGui::TextFormattedCentered("hex.builtin.view.bookmarks.no_bookmarks"_lang); } - u32 id = 1; + u32 id = 1; auto bookmarkToRemove = this->m_bookmarks.end(); for (auto iter = this->m_bookmarks.begin(); iter != this->m_bookmarks.end(); iter++) { auto &[region, name, comment, color, locked] = *iter; + if (!this->m_currFilter.empty()) { + if (!name.contains(this->m_currFilter) && !comment.contains(this->m_currFilter)) + continue; + } + auto headerColor = ImColor(color); auto hoverColor = ImColor(color); hoverColor.Value.w *= 1.3F;