1
0
mirror of synced 2025-02-21 04:27:21 +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); bool drawArrayRoot(pl::ptrn::Pattern& pattern, size_t entryCount, bool isInlined);
void drawArrayNode(u64 idx, u64& displayEnd, pl::ptrn::Pattern& pattern); 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 drawCommentTooltip(const pl::ptrn::Pattern &pattern) const;
void drawTypenameColumn(const pl::ptrn::Pattern& pattern, const std::string& pattern_name) 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"); drawTypenameColumn(pattern, "bitfield");
ImGui::TextFormatted("{}", pattern.getFormattedValue()); ImGui::TextFormatted("{}", pattern.getFormattedValue());
} else {
ImGui::SameLine();
ImGui::TreeNodeEx("", ImGuiTreeNodeFlags_SpanFullWidth | ImGuiTreeNodeFlags_Leaf);
} }
if (open) { if (open) {
@ -98,6 +95,7 @@ namespace hex {
this->draw(field); this->draw(field);
}); });
if (!pattern.isInlined())
ImGui::TreePop(); ImGui::TreePop();
} }
} }
@ -155,14 +153,12 @@ namespace hex {
ImGui::TextFormattedColored(ImColor(0xFF9BC64D), "{}", pattern.getFormattedName()); ImGui::TextFormattedColored(ImColor(0xFF9BC64D), "{}", pattern.getFormattedName());
ImGui::TableNextColumn(); ImGui::TableNextColumn();
ImGui::TextFormatted("{}", pattern.getFormattedValue()); ImGui::TextFormatted("{}", pattern.getFormattedValue());
} else {
ImGui::SameLine();
ImGui::TreeNodeEx("", ImGuiTreeNodeFlags_SpanFullWidth | ImGuiTreeNodeFlags_Leaf);
} }
if (open) { if (open) {
pattern.getPointedAtPattern()->accept(*this); pattern.getPointedAtPattern()->accept(*this);
if (!pattern.isInlined())
ImGui::TreePop(); ImGui::TreePop();
} }
} }
@ -194,9 +190,6 @@ namespace hex {
drawSizeColumn(pattern); drawSizeColumn(pattern);
drawTypenameColumn(pattern, "struct"); drawTypenameColumn(pattern, "struct");
ImGui::TextFormatted("{}", pattern.getFormattedValue()); ImGui::TextFormatted("{}", pattern.getFormattedValue());
} else {
ImGui::SameLine();
ImGui::TreeNodeEx("", ImGuiTreeNodeFlags_SpanFullWidth | ImGuiTreeNodeFlags_Leaf);
} }
if (open) { if (open) {
@ -204,6 +197,7 @@ namespace hex {
this->draw(member); this->draw(member);
}); });
if (!pattern.isInlined())
ImGui::TreePop(); ImGui::TreePop();
} }
} }
@ -226,9 +220,6 @@ namespace hex {
drawSizeColumn(pattern); drawSizeColumn(pattern);
drawTypenameColumn(pattern, "union"); drawTypenameColumn(pattern, "union");
ImGui::TextFormatted("{}", pattern.getFormattedValue()); ImGui::TextFormatted("{}", pattern.getFormattedValue());
} else {
ImGui::SameLine();
ImGui::TreeNodeEx("", ImGuiTreeNodeFlags_SpanFullWidth | ImGuiTreeNodeFlags_Leaf);
} }
if (open) { if (open) {
@ -236,6 +227,7 @@ namespace hex {
this->draw(member); this->draw(member);
}); });
if (!pattern.isInlined())
ImGui::TreePop(); ImGui::TreePop();
} }
} }
@ -327,9 +319,6 @@ namespace hex {
ImGui::TableNextColumn(); ImGui::TableNextColumn();
ImGui::TextFormatted("{}", pattern.getFormattedValue()); ImGui::TextFormatted("{}", pattern.getFormattedValue());
} else {
ImGui::SameLine();
ImGui::TreeNodeEx("", ImGuiTreeNodeFlags_SpanFullWidth | ImGuiTreeNodeFlags_Leaf);
} }
return open; return open;
@ -354,8 +343,9 @@ namespace hex {
ImGui::PopID(); 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 (opened) {
if (!inlined)
ImGui::TreePop(); ImGui::TreePop();
} else { } else {
auto& displayEnd = this->getDisplayEnd(pattern); auto& displayEnd = this->getDisplayEnd(pattern);