1
0
mirror of synced 2025-02-16 18:38:39 +01:00

ui: Fix invalid indentation with inlined patterns

This commit is contained in:
WerWolv 2022-09-06 20:04:55 +02:00
parent 37cc8f3aae
commit 073323b517
2 changed files with 13 additions and 23 deletions

View File

@ -53,12 +53,12 @@ namespace hex {
});
}
this->drawArrayEnd(pattern, opened);
this->drawArrayEnd(pattern, opened, pattern.isInlined());
}
bool drawArrayRoot(pl::ptrn::Pattern& pattern, size_t entryCount, bool isInlined);
void drawArrayNode(u64 idx, u64& displayEnd, pl::ptrn::Pattern& pattern);
void drawArrayEnd(pl::ptrn::Pattern& pattern, bool opened);
void drawArrayEnd(pl::ptrn::Pattern& pattern, bool opened, bool inlined);
void drawCommentTooltip(const pl::ptrn::Pattern &pattern) const;
void drawTypenameColumn(const pl::ptrn::Pattern& pattern, const std::string& pattern_name) const;

View File

@ -88,9 +88,6 @@ namespace hex {
drawTypenameColumn(pattern, "bitfield");
ImGui::TextFormatted("{}", pattern.getFormattedValue());
} else {
ImGui::SameLine();
ImGui::TreeNodeEx("", ImGuiTreeNodeFlags_SpanFullWidth | ImGuiTreeNodeFlags_Leaf);
}
if (open) {
@ -98,7 +95,8 @@ namespace hex {
this->draw(field);
});
ImGui::TreePop();
if (!pattern.isInlined())
ImGui::TreePop();
}
}
@ -155,15 +153,13 @@ namespace hex {
ImGui::TextFormattedColored(ImColor(0xFF9BC64D), "{}", pattern.getFormattedName());
ImGui::TableNextColumn();
ImGui::TextFormatted("{}", pattern.getFormattedValue());
} else {
ImGui::SameLine();
ImGui::TreeNodeEx("", ImGuiTreeNodeFlags_SpanFullWidth | ImGuiTreeNodeFlags_Leaf);
}
if (open) {
pattern.getPointedAtPattern()->accept(*this);
ImGui::TreePop();
if (!pattern.isInlined())
ImGui::TreePop();
}
}
@ -194,9 +190,6 @@ namespace hex {
drawSizeColumn(pattern);
drawTypenameColumn(pattern, "struct");
ImGui::TextFormatted("{}", pattern.getFormattedValue());
} else {
ImGui::SameLine();
ImGui::TreeNodeEx("", ImGuiTreeNodeFlags_SpanFullWidth | ImGuiTreeNodeFlags_Leaf);
}
if (open) {
@ -204,7 +197,8 @@ namespace hex {
this->draw(member);
});
ImGui::TreePop();
if (!pattern.isInlined())
ImGui::TreePop();
}
}
@ -226,9 +220,6 @@ namespace hex {
drawSizeColumn(pattern);
drawTypenameColumn(pattern, "union");
ImGui::TextFormatted("{}", pattern.getFormattedValue());
} else {
ImGui::SameLine();
ImGui::TreeNodeEx("", ImGuiTreeNodeFlags_SpanFullWidth | ImGuiTreeNodeFlags_Leaf);
}
if (open) {
@ -236,7 +227,8 @@ namespace hex {
this->draw(member);
});
ImGui::TreePop();
if (!pattern.isInlined())
ImGui::TreePop();
}
}
@ -327,9 +319,6 @@ namespace hex {
ImGui::TableNextColumn();
ImGui::TextFormatted("{}", pattern.getFormattedValue());
} else {
ImGui::SameLine();
ImGui::TreeNodeEx("", ImGuiTreeNodeFlags_SpanFullWidth | ImGuiTreeNodeFlags_Leaf);
}
return open;
@ -354,9 +343,10 @@ namespace hex {
ImGui::PopID();
}
void PatternDrawer::drawArrayEnd(pl::ptrn::Pattern& pattern, bool opened) {
void PatternDrawer::drawArrayEnd(pl::ptrn::Pattern& pattern, bool opened, bool inlined) {
if (opened) {
ImGui::TreePop();
if (!inlined)
ImGui::TreePop();
} else {
auto& displayEnd = this->getDisplayEnd(pattern);
displayEnd = DisplayEndDefault;