mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-02 05:27:41 -05:00
feat: Highlight patterns in hex editor when hovering over pattern data row
Fixes #1742
This commit is contained in:
@@ -32,6 +32,7 @@ namespace hex::ui {
|
||||
|
||||
void setTreeStyle(TreeStyle style) { m_treeStyle = style; }
|
||||
void setSelectionCallback(std::function<void(const pl::ptrn::Pattern *)> callback) { m_selectionCallback = std::move(callback); }
|
||||
void setHoverCallback(std::function<void(const pl::ptrn::Pattern *)> callback) { m_hoverCallback = std::move(callback); }
|
||||
void enableRowColoring(bool enabled) { m_rowColoring = enabled; }
|
||||
void enablePatternEditing(bool enabled) { m_editingEnabled = enabled; }
|
||||
void reset();
|
||||
@@ -126,6 +127,7 @@ namespace hex::ui {
|
||||
TaskHolder m_favoritesUpdateTask;
|
||||
|
||||
std::function<void(const pl::ptrn::Pattern *)> m_selectionCallback = [](const pl::ptrn::Pattern *) { };
|
||||
std::function<void(const pl::ptrn::Pattern *)> m_hoverCallback = [](const pl::ptrn::Pattern *) { };
|
||||
|
||||
pl::gen::fmt::FormatterArray m_formatters;
|
||||
};
|
||||
|
||||
@@ -433,10 +433,14 @@ namespace hex::ui {
|
||||
}
|
||||
}
|
||||
|
||||
if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left) && m_editingEnabled) {
|
||||
m_editingPattern = &pattern;
|
||||
m_editingPatternOffset = pattern.getOffset();
|
||||
AchievementManager::unlockAchievement("hex.builtin.achievement.patterns", "hex.builtin.achievement.patterns.modify_data.name");
|
||||
if (ImGui::IsItemHovered()) {
|
||||
m_hoverCallback(&pattern);
|
||||
|
||||
if (ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left) && m_editingEnabled) {
|
||||
m_editingPattern = &pattern;
|
||||
m_editingPatternOffset = pattern.getOffset();
|
||||
AchievementManager::unlockAchievement("hex.builtin.achievement.patterns", "hex.builtin.achievement.patterns.modify_data.name");
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::SameLine(0, 0);
|
||||
@@ -1114,6 +1118,8 @@ namespace hex::ui {
|
||||
void PatternDrawer::draw(const std::vector<std::shared_ptr<pl::ptrn::Pattern>> &patterns, const pl::PatternLanguage *runtime, float height) {
|
||||
std::scoped_lock lock(s_resetDrawMutex);
|
||||
|
||||
m_hoverCallback(nullptr);
|
||||
|
||||
const auto treeStyleButton = [this](auto icon, TreeStyle style, const char *tooltip) {
|
||||
bool pushed = false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user