2020-11-10 21:31:04 +01:00
|
|
|
#include "views/view_pattern_data.hpp"
|
|
|
|
|
2020-11-11 10:47:02 +01:00
|
|
|
#include "providers/provider.hpp"
|
2020-11-19 11:36:52 +01:00
|
|
|
#include "lang/pattern_data.hpp"
|
2020-11-11 10:47:02 +01:00
|
|
|
|
2020-11-10 21:31:04 +01:00
|
|
|
namespace hex {
|
|
|
|
|
2020-11-19 11:36:52 +01:00
|
|
|
ViewPatternData::ViewPatternData(prv::Provider* &dataProvider, std::vector<lang::PatternData*> &patternData)
|
2020-11-14 14:42:21 +01:00
|
|
|
: View(), m_dataProvider(dataProvider), m_patternData(patternData) {
|
2020-11-10 21:31:04 +01:00
|
|
|
|
2020-11-15 00:46:18 +01:00
|
|
|
this->subscribeEvent(Events::PatternChanged, [this](auto data) {
|
|
|
|
this->m_sortedPatternData.clear();
|
|
|
|
});
|
2020-11-10 21:31:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ViewPatternData::~ViewPatternData() {
|
2020-11-15 00:46:18 +01:00
|
|
|
this->unsubscribeEvent(Events::PatternChanged);
|
2020-11-10 21:31:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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 23:57:43 +01:00
|
|
|
if (this->m_dataProvider != nullptr && this->m_dataProvider->isReadable()) {
|
2020-11-10 21:31:04 +01:00
|
|
|
|
2020-11-19 11:36:52 +01:00
|
|
|
if (lang::PatternData::beginPatternDataTable(this->m_dataProvider, this->m_patternData, this->m_sortedPatternData)) {
|
2020-11-15 00:46:18 +01:00
|
|
|
u32 rowCount = 0;
|
|
|
|
for (auto& patternData : this->m_sortedPatternData) {
|
2020-11-19 11:36:52 +01:00
|
|
|
patternData->createEntry(this->m_dataProvider);
|
2020-11-15 00:46:18 +01:00
|
|
|
ImGui::TableSetBgColor(ImGuiTableBgTarget_RowBg0, ((rowCount % 2) == 0) ? 0xFF101010 : 0xFF303030);
|
|
|
|
rowCount++;
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::EndTable();
|
2020-11-11 09:18:35 +01:00
|
|
|
}
|
2020-11-15 00:46:18 +01:00
|
|
|
|
2020-11-10 21:31:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::EndChild();
|
|
|
|
}
|
2020-11-11 10:47:02 +01:00
|
|
|
ImGui::End();
|
2020-11-10 21:31:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void ViewPatternData::createMenu() {
|
2020-11-11 09:22:55 +01:00
|
|
|
if (ImGui::BeginMenu("View")) {
|
2020-11-10 21:31:04 +01:00
|
|
|
ImGui::MenuItem("Data View", "", &this->m_windowOpen);
|
|
|
|
ImGui::EndMenu();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|