mirror of https://github.com/WerWolv/ImHex.git
patterns: Added `hidden` attribute
This commit is contained in:
parent
21f8fb4090
commit
b4b2c41b34
|
@ -92,6 +92,7 @@ namespace hex::lang {
|
|||
}
|
||||
|
||||
virtual std::map<u64, u32> getHighlightedAddresses() {
|
||||
if (this->isHidden()) return { };
|
||||
if (this->m_highlightedAddresses.empty()) {
|
||||
for (u64 i = 0; i < this->getSize(); i++)
|
||||
this->m_highlightedAddresses.insert({ this->getOffset() + i, this->getColor() });
|
||||
|
@ -154,8 +155,22 @@ namespace hex::lang {
|
|||
return false;
|
||||
}
|
||||
|
||||
void draw(prv::Provider *provider) {
|
||||
if (isHidden()) return;
|
||||
|
||||
this->createEntry(provider);
|
||||
}
|
||||
|
||||
static void resetPalette() { SharedData::patternPaletteOffset = 0; }
|
||||
|
||||
void setHidden(bool hidden) {
|
||||
this->m_hidden = hidden;
|
||||
}
|
||||
|
||||
bool isHidden() const {
|
||||
return this->m_hidden;
|
||||
}
|
||||
|
||||
protected:
|
||||
void createDefaultEntry(std::string_view value) const {
|
||||
ImGui::TableNextRow();
|
||||
|
@ -190,6 +205,7 @@ namespace hex::lang {
|
|||
protected:
|
||||
std::endian m_endian = std::endian::native;
|
||||
std::map<u64, u32> m_highlightedAddresses;
|
||||
bool m_hidden = false;
|
||||
|
||||
private:
|
||||
u64 m_offset;
|
||||
|
@ -599,7 +615,7 @@ namespace hex::lang {
|
|||
|
||||
if (open) {
|
||||
for (auto &member : this->m_entries)
|
||||
member->createEntry(provider);
|
||||
member->draw(provider);
|
||||
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
@ -681,7 +697,7 @@ namespace hex::lang {
|
|||
|
||||
if (open) {
|
||||
for (auto &member : this->m_sortedMembers)
|
||||
member->createEntry(provider);
|
||||
member->draw(provider);
|
||||
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
@ -782,7 +798,7 @@ namespace hex::lang {
|
|||
|
||||
if (open) {
|
||||
for (auto &member : this->m_sortedMembers)
|
||||
member->createEntry(provider);
|
||||
member->draw(provider);
|
||||
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
|
|
@ -432,6 +432,8 @@ namespace hex::lang {
|
|||
currPattern->setVariableName(value->data());
|
||||
else if (attribute == "comment" && value.has_value())
|
||||
currPattern->setComment(value->data());
|
||||
else if (attribute == "hidden" && value.has_value())
|
||||
currPattern->setHidden(true);
|
||||
else
|
||||
this->getConsole().abortEvaluation("unknown or invalid attribute");
|
||||
|
||||
|
|
|
@ -162,8 +162,9 @@ namespace hex {
|
|||
EventManager::subscribe<EventPatternChanged>(this, [this]() {
|
||||
this->m_highlightedBytes.clear();
|
||||
|
||||
for (const auto &pattern : SharedData::patternData)
|
||||
for (const auto &pattern : SharedData::patternData) {
|
||||
this->m_highlightedBytes.merge(pattern->getHighlightedAddresses());
|
||||
}
|
||||
});
|
||||
|
||||
EventManager::subscribe<RequestOpenWindow>(this, [this](std::string name) {
|
||||
|
|
|
@ -57,7 +57,7 @@ namespace hex {
|
|||
if (this->m_sortedPatternData.size() > 0) {
|
||||
|
||||
for (auto &patternData : this->m_sortedPatternData)
|
||||
patternData->createEntry(provider);
|
||||
patternData->draw(provider);
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue