1
0
mirror of synced 2025-02-19 19:51:41 +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,6 +95,7 @@ namespace hex {
this->draw(field);
});
if (!pattern.isInlined())
ImGui::TreePop();
}
}
@ -155,14 +153,12 @@ 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);
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,6 +197,7 @@ namespace hex {
this->draw(member);
});
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,6 +227,7 @@ namespace hex {
this->draw(member);
});
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,8 +343,9 @@ 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) {
if (!inlined)
ImGui::TreePop();
} else {
auto& displayEnd = this->getDisplayEnd(pattern);