ImHex/source/views/view_pattern_data.cpp

47 lines
1.4 KiB
C++
Raw Normal View History

2020-11-10 20:31:04 +00:00
#include "views/view_pattern_data.hpp"
#include "providers/provider.hpp"
2020-11-10 20:31:04 +00:00
#include <cstring>
namespace hex {
ViewPatternData::ViewPatternData(prv::Provider* &dataProvider, std::vector<hex::PatternData*> &patternData)
: View(), m_dataProvider(dataProvider), m_patternData(patternData) {
2020-11-10 20:31:04 +00:00
}
ViewPatternData::~ViewPatternData() {
}
void ViewPatternData::createView() {
if (!this->m_windowOpen)
return;
if (ImGui::Begin("Pattern Data", &this->m_windowOpen)) {
ImGui::BeginChild("##scrolling", ImVec2(0, 0), false, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoNav);
2020-11-12 22:57:43 +00:00
if (this->m_dataProvider != nullptr && this->m_dataProvider->isReadable()) {
2020-11-10 20:31:04 +00:00
for (auto& patternData : this->m_patternData) {
ImGui::LabelText(patternData->getName().c_str(), "[0x%08lx:0x%08lx] %s",
patternData->getOffset(),
patternData->getOffset() + patternData->getSize(),
patternData->format(this->m_dataProvider).c_str());
}
2020-11-10 20:31:04 +00:00
}
ImGui::EndChild();
}
ImGui::End();
2020-11-10 20:31:04 +00:00
}
void ViewPatternData::createMenu() {
2020-11-11 08:22:55 +00:00
if (ImGui::BeginMenu("View")) {
2020-11-10 20:31:04 +00:00
ImGui::MenuItem("Data View", "", &this->m_windowOpen);
ImGui::EndMenu();
}
}
}