diff --git a/external/ImGui/include/imgui_memory_editor.h b/external/ImGui/include/imgui_memory_editor.h index f78dc960f..9ff0f68bd 100644 --- a/external/ImGui/include/imgui_memory_editor.h +++ b/external/ImGui/include/imgui_memory_editor.h @@ -89,6 +89,7 @@ struct MemoryEditor ImU8 (*ReadFn)(const ImU8* data, size_t off); // = 0 // optional handler to read bytes. void (*WriteFn)(ImU8* data, size_t off, ImU8 d); // = 0 // optional handler to write bytes. bool (*HighlightFn)(const ImU8* data, size_t off, bool next);//= 0 // optional handler to return Highlight property (to support non-contiguous highlighting). + void (*HoverFn)(const ImU8 *data, size_t off); // [Internal State] bool ContentsWidthChanged; @@ -121,6 +122,7 @@ struct MemoryEditor ReadFn = NULL; WriteFn = NULL; HighlightFn = NULL; + HoverFn = NULL; // State/Internals ContentsWidthChanged = false; @@ -324,6 +326,7 @@ struct MemoryEditor const char* format_byte = OptUpperCaseHex ? "%02X" : "%02x"; const char* format_byte_space = OptUpperCaseHex ? "%02X " : "%02x "; + bool tooltipShown = false; for (int line_i = clipper.DisplayStart; line_i < clipper.DisplayEnd; line_i++) // display only visible lines { size_t addr = (size_t)(line_i * Cols); @@ -458,6 +461,12 @@ struct MemoryEditor if (ImGui::IsItemHovered() && ((ImGui::IsMouseClicked(0) && ImGui::GetIO().KeyShift) || ImGui::IsMouseDragging(0))) { DataPreviewAddrEnd = addr; } + if (ImGui::IsItemHovered() && !tooltipShown) { + if (HoverFn) { + HoverFn(mem_data, addr); + tooltipShown = true; + } + } } } diff --git a/source/views/view_bookmarks.cpp b/source/views/view_bookmarks.cpp index b92674bfb..cda8ba35c 100644 --- a/source/views/view_bookmarks.cpp +++ b/source/views/view_bookmarks.cpp @@ -84,35 +84,37 @@ namespace hex { ImGui::TextColored(ImColor(0xFF9BC64D), bytesString.c_str()); } - + ImGui::PushID(id); if (ImGui::Button("Jump to")) View::postEvent(Events::SelectionChangeRequest, ®ion); - + ImGui::PopID(); ImGui::SameLine(0, 15); + ImGui::PushID(id + 1); if (ImGui::Button("Remove")) bookmarkToRemove = iter; + ImGui::PopID(); ImGui::NewLine(); ImGui::TextUnformatted("Name"); ImGui::Separator(); - ImGui::PushID(id); + ImGui::PushID(id + 2); ImGui::InputText("##nolabel", name.data(), 64); ImGui::PopID(); ImGui::SameLine(); - ImGui::PushID(id + 1); + ImGui::PushID(id + 3); ImGui::ColorEdit4("Color", (float*)&headerColor.Value, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel | ImGuiColorEditFlags_NoAlpha); color = headerColor; ImGui::PopID(); ImGui::NewLine(); ImGui::TextUnformatted("Comment"); ImGui::Separator(); - ImGui::PushID(id + 2); + ImGui::PushID(id + 4); ImGui::InputTextMultiline("##nolabel", comment.data(), 0xF'FFFF); ImGui::PopID(); ImGui::NewLine(); - id += 3; + id += 5; } ImGui::PopStyleColor(3); } diff --git a/source/views/view_hexeditor.cpp b/source/views/view_hexeditor.cpp index a1c135dbe..fd438221d 100644 --- a/source/views/view_hexeditor.cpp +++ b/source/views/view_hexeditor.cpp @@ -69,6 +69,27 @@ namespace hex { return false; }; + this->m_memoryEditor.HoverFn = [](const ImU8 *data, size_t addr) { + ViewHexEditor *_this = (ViewHexEditor *) data; + + bool tooltipShown = false; + + for (const auto &[region, name, comment, color] : _this->m_bookmarks) { + if (addr >= region.address && addr < (region.address + region.size)) { + if (!tooltipShown) { + ImGui::BeginTooltip(); + tooltipShown = true; + } + ImGui::ColorButton(name.data(), ImColor(color).Value); + ImGui::SameLine(0, 10); + ImGui::TextUnformatted(name.data()); + } + } + + if (tooltipShown) + ImGui::EndTooltip(); + }; + View::subscribeEvent(Events::FileDropped, [this](const void *userData) { auto filePath = static_cast(userData);