1
0
mirror of synced 2025-01-21 01:58:55 +01:00

feat: Display visualizers in pattern tooltips

This commit is contained in:
WerWolv 2024-11-29 20:23:36 +01:00
parent caae5c9711
commit 2c2d3b2de3
2 changed files with 22 additions and 1 deletions

View File

@ -11,6 +11,7 @@
#include <ui/hex_editor.hpp>
#include <ui/pattern_drawer.hpp>
#include <ui/visualizer_drawer.hpp>
#include <filesystem>
#include <functional>
@ -243,6 +244,8 @@ namespace hex::plugin::builtin {
std::map<prv::Provider*, std::function<void()>> m_sectionWindowDrawer;
ui::HexEditor m_sectionHexEditor;
PerProvider<ui::VisualizerDrawer> m_visualizerDrawer;
bool m_tooltipJustOpened = false;
PatternSourceCode m_sourceCode;
PerProvider<std::vector<std::string>> m_console;

View File

@ -1559,7 +1559,16 @@ namespace hex::plugin::builtin {
ImGui::SameLine();
ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical);
ImGui::SameLine();
ImGuiExt::TextFormatted("{: <{}} ", hex::limitStringLength(pattern->getFormattedValue(), 64), shiftHeld ? 40 : 0);
if (const auto &inlineVisualizeArgs = pattern->getAttributeArguments("hex::inline_visualize"); !inlineVisualizeArgs.empty()) {
auto x = ImGui::GetCursorPosX();
ImGui::Dummy(ImVec2(125_scaled, ImGui::GetTextLineHeight()));
ImGui::SameLine();
ImGui::SetCursorPos(ImVec2(x, ImGui::GetCursorPosY() + ImGui::GetStyle().FramePadding.y));
m_visualizerDrawer->drawVisualizer(ContentRegistry::PatternLanguage::impl::getInlineVisualizers(), inlineVisualizeArgs, *pattern, true);
} else {
ImGuiExt::TextFormatted("{: <{}} ", hex::limitStringLength(pattern->getFormattedValue(), 64), shiftHeld ? 40 : 0);
}
if (shiftHeld) {
ImGui::Indent();
@ -1661,7 +1670,16 @@ namespace hex::plugin::builtin {
ImGui::EndTable();
}
if (const auto &visualizeArgs = pattern->getAttributeArguments("hex::visualize"); !visualizeArgs.empty()) {
m_visualizerDrawer->drawVisualizer(ContentRegistry::PatternLanguage::impl::getVisualizers(), visualizeArgs, *pattern, m_tooltipJustOpened);
}
ImGui::Unindent();
m_tooltipJustOpened = false;
} else {
m_tooltipJustOpened = true;
}
}