feat: Display visualizers in pattern tooltips
This commit is contained in:
parent
caae5c9711
commit
2c2d3b2de3
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user