feat: Added visibility toggle to hide bookmark highlighting
This commit is contained in:
parent
6e861001cf
commit
6ecc495d43
@ -19,6 +19,7 @@ namespace hex::plugin::builtin {
|
|||||||
struct Bookmark {
|
struct Bookmark {
|
||||||
ImHexApi::Bookmarks::Entry entry;
|
ImHexApi::Bookmarks::Entry entry;
|
||||||
TextEditor editor;
|
TextEditor editor;
|
||||||
|
bool highlightVisible;
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -44,7 +44,7 @@ namespace hex::plugin::builtin {
|
|||||||
bookmarkId
|
bookmarkId
|
||||||
};
|
};
|
||||||
|
|
||||||
m_bookmarks->emplace_back(std::move(bookmark), TextEditor());
|
m_bookmarks->emplace_back(std::move(bookmark), TextEditor(), true);
|
||||||
|
|
||||||
ImHexApi::Provider::markDirty();
|
ImHexApi::Provider::markDirty();
|
||||||
|
|
||||||
@ -81,7 +81,10 @@ namespace hex::plugin::builtin {
|
|||||||
std::ignore = data;
|
std::ignore = data;
|
||||||
|
|
||||||
// Loop over all bookmarks
|
// Loop over all bookmarks
|
||||||
for (const auto &[bookmark, editor] : *m_bookmarks) {
|
for (const auto &[bookmark, editor, highlightVisible] : *m_bookmarks) {
|
||||||
|
if (!highlightVisible)
|
||||||
|
continue;
|
||||||
|
|
||||||
// Make sure the bookmark overlaps the currently hovered address
|
// Make sure the bookmark overlaps the currently hovered address
|
||||||
if (!Region { address, size }.isWithin(bookmark.region))
|
if (!Region { address, size }.isWithin(bookmark.region))
|
||||||
continue;
|
continue;
|
||||||
@ -176,7 +179,7 @@ namespace hex::plugin::builtin {
|
|||||||
|
|
||||||
result += "## Bookmarks\n\n";
|
result += "## Bookmarks\n\n";
|
||||||
|
|
||||||
for (const auto &[bookmark, editor] : bookmarks) {
|
for (const auto &[bookmark, editor, highlightVisible] : bookmarks) {
|
||||||
result += hex::format("### <span style=\"background-color: #{:06X}80\">{} [0x{:04X} - 0x{:04X}]</span>\n\n", hex::changeEndianness(bookmark.color, std::endian::big) >> 8, bookmark.name, bookmark.region.getStartAddress(), bookmark.region.getEndAddress());
|
result += hex::format("### <span style=\"background-color: #{:06X}80\">{} [0x{:04X} - 0x{:04X}]</span>\n\n", hex::changeEndianness(bookmark.color, std::endian::big) >> 8, bookmark.name, bookmark.region.getStartAddress(), bookmark.region.getEndAddress());
|
||||||
|
|
||||||
for (const auto &line : hex::splitString(bookmark.comment, "\n"))
|
for (const auto &line : hex::splitString(bookmark.comment, "\n"))
|
||||||
@ -306,7 +309,7 @@ namespace hex::plugin::builtin {
|
|||||||
|
|
||||||
// Draw all bookmarks
|
// Draw all bookmarks
|
||||||
for (auto it = m_bookmarks->begin(); it != m_bookmarks->end(); ++it) {
|
for (auto it = m_bookmarks->begin(); it != m_bookmarks->end(); ++it) {
|
||||||
auto &[bookmark, editor] = *it;
|
auto &[bookmark, editor, highlightVisible] = *it;
|
||||||
auto &[region, name, comment, color, locked, bookmarkId] = bookmark;
|
auto &[region, name, comment, color, locked, bookmarkId] = bookmark;
|
||||||
|
|
||||||
// Apply filter
|
// Apply filter
|
||||||
@ -362,7 +365,7 @@ namespace hex::plugin::builtin {
|
|||||||
auto nextPos = ImGui::GetCursorPos();
|
auto nextPos = ImGui::GetCursorPos();
|
||||||
|
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + ImGui::GetContentRegionAvail().x - 70_scaled);
|
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + ImGui::GetContentRegionAvail().x - 100_scaled);
|
||||||
|
|
||||||
{
|
{
|
||||||
// Draw jump to region button
|
// Draw jump to region button
|
||||||
@ -389,6 +392,14 @@ namespace hex::plugin::builtin {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
ImGui::SetItemTooltip("%s", "hex.builtin.view.bookmarks.tooltip.open_in_view"_lang.get());
|
ImGui::SetItemTooltip("%s", "hex.builtin.view.bookmarks.tooltip.open_in_view"_lang.get());
|
||||||
|
|
||||||
|
ImGui::SameLine(0, 4_scaled);
|
||||||
|
|
||||||
|
// Draw highlight visible toggle
|
||||||
|
if (ImGuiExt::DimmedIconButton(highlightVisible ? ICON_VS_EYE : ICON_VS_EYE_CLOSED, ImGui::GetStyleColorVec4(ImGuiCol_Text))) {
|
||||||
|
highlightVisible = !highlightVisible;
|
||||||
|
EventHighlightingChanged::post();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2());
|
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2());
|
||||||
@ -548,9 +559,10 @@ namespace hex::plugin::builtin {
|
|||||||
.comment = bookmark["comment"],
|
.comment = bookmark["comment"],
|
||||||
.color = bookmark["color"],
|
.color = bookmark["color"],
|
||||||
.locked = bookmark["locked"],
|
.locked = bookmark["locked"],
|
||||||
.id = bookmark.contains("id") ? bookmark["id"].get<u64>() : m_currBookmarkId.get(provider)
|
.id = bookmark.contains("id") ? bookmark["id"].get<u64>() : m_currBookmarkId.get(provider),
|
||||||
},
|
},
|
||||||
editor
|
editor,
|
||||||
|
bookmark.contains("highlightVisible") ? bookmark["highlightVisible"].get<bool>() : true,
|
||||||
});
|
});
|
||||||
if (bookmark.contains("id"))
|
if (bookmark.contains("id"))
|
||||||
m_currBookmarkId.get(provider) = std::max<u64>(m_currBookmarkId.get(provider), bookmark["id"].get<i64>() + 1);
|
m_currBookmarkId.get(provider) = std::max<u64>(m_currBookmarkId.get(provider), bookmark["id"].get<i64>() + 1);
|
||||||
@ -564,7 +576,7 @@ namespace hex::plugin::builtin {
|
|||||||
bool ViewBookmarks::exportBookmarks(prv::Provider *provider, nlohmann::json &json) {
|
bool ViewBookmarks::exportBookmarks(prv::Provider *provider, nlohmann::json &json) {
|
||||||
json["bookmarks"] = nlohmann::json::array();
|
json["bookmarks"] = nlohmann::json::array();
|
||||||
size_t index = 0;
|
size_t index = 0;
|
||||||
for (const auto &[bookmark, editor] : m_bookmarks.get(provider)) {
|
for (const auto &[bookmark, editor, highlightVisible] : m_bookmarks.get(provider)) {
|
||||||
json["bookmarks"][index] = {
|
json["bookmarks"][index] = {
|
||||||
{ "name", bookmark.name },
|
{ "name", bookmark.name },
|
||||||
{ "comment", editor.GetText() },
|
{ "comment", editor.GetText() },
|
||||||
@ -575,7 +587,8 @@ namespace hex::plugin::builtin {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ "locked", bookmark.locked },
|
{ "locked", bookmark.locked },
|
||||||
{ "id", bookmark.id }
|
{ "id", bookmark.id },
|
||||||
|
{ "highlightVisible", highlightVisible }
|
||||||
};
|
};
|
||||||
|
|
||||||
index++;
|
index++;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user