1
0
mirror of synced 2024-11-12 10:10:53 +01:00

impr: Split offset column into Start and End column in pattern data view

This commit is contained in:
WerWolv 2023-06-18 12:23:47 +02:00
parent e09b678426
commit d9af85f458
10 changed files with 45 additions and 27 deletions

View File

@ -365,10 +365,11 @@
"hex.builtin.nodes.visualizer.layered_dist.header": "Schichtverteilung", "hex.builtin.nodes.visualizer.layered_dist.header": "Schichtverteilung",
"hex.builtin.pattern_drawer.color": "Farbe", "hex.builtin.pattern_drawer.color": "Farbe",
"hex.builtin.pattern_drawer.double_click": "Doppelklicken um mehr Einträge zu sehen", "hex.builtin.pattern_drawer.double_click": "Doppelklicken um mehr Einträge zu sehen",
"hex.builtin.pattern_drawer.end": "Ende",
"hex.builtin.pattern_drawer.favorites": "", "hex.builtin.pattern_drawer.favorites": "",
"hex.builtin.pattern_drawer.local": "", "hex.builtin.pattern_drawer.local": "",
"hex.builtin.pattern_drawer.offset": "Offset",
"hex.builtin.pattern_drawer.size": "Grösse", "hex.builtin.pattern_drawer.size": "Grösse",
"hex.builtin.pattern_drawer.start": "Start",
"hex.builtin.pattern_drawer.tree_style.auto_expanded": "Automatisch geöffneter Baum", "hex.builtin.pattern_drawer.tree_style.auto_expanded": "Automatisch geöffneter Baum",
"hex.builtin.pattern_drawer.tree_style.flattened": "Flach", "hex.builtin.pattern_drawer.tree_style.flattened": "Flach",
"hex.builtin.pattern_drawer.tree_style.tree": "Baum", "hex.builtin.pattern_drawer.tree_style.tree": "Baum",

View File

@ -366,11 +366,12 @@
"hex.builtin.nodes.visualizer.layered_dist.header": "Layered Distribution", "hex.builtin.nodes.visualizer.layered_dist.header": "Layered Distribution",
"hex.builtin.pattern_drawer.color": "Color", "hex.builtin.pattern_drawer.color": "Color",
"hex.builtin.pattern_drawer.double_click": "Double-click to see more items", "hex.builtin.pattern_drawer.double_click": "Double-click to see more items",
"hex.builtin.pattern_drawer.end": "End",
"hex.builtin.pattern_drawer.export": "Export Patterns as...", "hex.builtin.pattern_drawer.export": "Export Patterns as...",
"hex.builtin.pattern_drawer.favorites": "Favorites", "hex.builtin.pattern_drawer.favorites": "Favorites",
"hex.builtin.pattern_drawer.local": "Local", "hex.builtin.pattern_drawer.local": "Local",
"hex.builtin.pattern_drawer.offset": "Offset",
"hex.builtin.pattern_drawer.size": "Size", "hex.builtin.pattern_drawer.size": "Size",
"hex.builtin.pattern_drawer.start": "Start",
"hex.builtin.pattern_drawer.tree_style.tree": "Tree", "hex.builtin.pattern_drawer.tree_style.tree": "Tree",
"hex.builtin.pattern_drawer.tree_style.auto_expanded": "Auto Expanded Tree", "hex.builtin.pattern_drawer.tree_style.auto_expanded": "Auto Expanded Tree",
"hex.builtin.pattern_drawer.tree_style.flattened": "Flattened", "hex.builtin.pattern_drawer.tree_style.flattened": "Flattened",

View File

@ -367,7 +367,6 @@
"hex.builtin.pattern_drawer.double_click": "Haga doble clic para ver más elementos", "hex.builtin.pattern_drawer.double_click": "Haga doble clic para ver más elementos",
"hex.builtin.pattern_drawer.favorites": "", "hex.builtin.pattern_drawer.favorites": "",
"hex.builtin.pattern_drawer.local": "", "hex.builtin.pattern_drawer.local": "",
"hex.builtin.pattern_drawer.offset": "Offset",
"hex.builtin.pattern_drawer.size": "Tamaño", "hex.builtin.pattern_drawer.size": "Tamaño",
"hex.builtin.pattern_drawer.tree_style.auto_expanded": "Árbol Automáticamente Expandido", "hex.builtin.pattern_drawer.tree_style.auto_expanded": "Árbol Automáticamente Expandido",
"hex.builtin.pattern_drawer.tree_style.flattened": "Allanado", "hex.builtin.pattern_drawer.tree_style.flattened": "Allanado",

View File

@ -367,7 +367,6 @@
"hex.builtin.pattern_drawer.double_click": "", "hex.builtin.pattern_drawer.double_click": "",
"hex.builtin.pattern_drawer.favorites": "", "hex.builtin.pattern_drawer.favorites": "",
"hex.builtin.pattern_drawer.local": "", "hex.builtin.pattern_drawer.local": "",
"hex.builtin.pattern_drawer.offset": "",
"hex.builtin.pattern_drawer.size": "", "hex.builtin.pattern_drawer.size": "",
"hex.builtin.pattern_drawer.tree_style.auto_expanded": "", "hex.builtin.pattern_drawer.tree_style.auto_expanded": "",
"hex.builtin.pattern_drawer.tree_style.flattened": "", "hex.builtin.pattern_drawer.tree_style.flattened": "",

View File

@ -367,7 +367,6 @@
"hex.builtin.pattern_drawer.double_click": "", "hex.builtin.pattern_drawer.double_click": "",
"hex.builtin.pattern_drawer.favorites": "", "hex.builtin.pattern_drawer.favorites": "",
"hex.builtin.pattern_drawer.local": "", "hex.builtin.pattern_drawer.local": "",
"hex.builtin.pattern_drawer.offset": "オフセット",
"hex.builtin.pattern_drawer.size": "サイズ", "hex.builtin.pattern_drawer.size": "サイズ",
"hex.builtin.pattern_drawer.tree_style.auto_expanded": "", "hex.builtin.pattern_drawer.tree_style.auto_expanded": "",
"hex.builtin.pattern_drawer.tree_style.flattened": "", "hex.builtin.pattern_drawer.tree_style.flattened": "",

View File

@ -367,7 +367,6 @@
"hex.builtin.pattern_drawer.double_click": "", "hex.builtin.pattern_drawer.double_click": "",
"hex.builtin.pattern_drawer.favorites": "", "hex.builtin.pattern_drawer.favorites": "",
"hex.builtin.pattern_drawer.local": "", "hex.builtin.pattern_drawer.local": "",
"hex.builtin.pattern_drawer.offset": "오프셋",
"hex.builtin.pattern_drawer.size": "크기", "hex.builtin.pattern_drawer.size": "크기",
"hex.builtin.pattern_drawer.tree_style.auto_expanded": "", "hex.builtin.pattern_drawer.tree_style.auto_expanded": "",
"hex.builtin.pattern_drawer.tree_style.flattened": "", "hex.builtin.pattern_drawer.tree_style.flattened": "",

View File

@ -367,7 +367,6 @@
"hex.builtin.pattern_drawer.double_click": "", "hex.builtin.pattern_drawer.double_click": "",
"hex.builtin.pattern_drawer.favorites": "", "hex.builtin.pattern_drawer.favorites": "",
"hex.builtin.pattern_drawer.local": "", "hex.builtin.pattern_drawer.local": "",
"hex.builtin.pattern_drawer.offset": "Offset",
"hex.builtin.pattern_drawer.size": "Tamanho", "hex.builtin.pattern_drawer.size": "Tamanho",
"hex.builtin.pattern_drawer.tree_style.auto_expanded": "", "hex.builtin.pattern_drawer.tree_style.auto_expanded": "",
"hex.builtin.pattern_drawer.tree_style.flattened": "", "hex.builtin.pattern_drawer.tree_style.flattened": "",

View File

@ -367,7 +367,6 @@
"hex.builtin.pattern_drawer.double_click": "双击查看更多", "hex.builtin.pattern_drawer.double_click": "双击查看更多",
"hex.builtin.pattern_drawer.favorites": "", "hex.builtin.pattern_drawer.favorites": "",
"hex.builtin.pattern_drawer.local": "", "hex.builtin.pattern_drawer.local": "",
"hex.builtin.pattern_drawer.offset": "偏移",
"hex.builtin.pattern_drawer.size": "大小", "hex.builtin.pattern_drawer.size": "大小",
"hex.builtin.pattern_drawer.tree_style.auto_expanded": "自动展开树", "hex.builtin.pattern_drawer.tree_style.auto_expanded": "自动展开树",
"hex.builtin.pattern_drawer.tree_style.flattened": "扁平化", "hex.builtin.pattern_drawer.tree_style.flattened": "扁平化",

View File

@ -367,7 +367,6 @@
"hex.builtin.pattern_drawer.double_click": "Double-click to see more items", "hex.builtin.pattern_drawer.double_click": "Double-click to see more items",
"hex.builtin.pattern_drawer.favorites": "", "hex.builtin.pattern_drawer.favorites": "",
"hex.builtin.pattern_drawer.local": "", "hex.builtin.pattern_drawer.local": "",
"hex.builtin.pattern_drawer.offset": "位移",
"hex.builtin.pattern_drawer.size": "大小", "hex.builtin.pattern_drawer.size": "大小",
"hex.builtin.pattern_drawer.tree_style.auto_expanded": "", "hex.builtin.pattern_drawer.tree_style.auto_expanded": "",
"hex.builtin.pattern_drawer.tree_style.flattened": "", "hex.builtin.pattern_drawer.tree_style.flattened": "",

View File

@ -91,25 +91,43 @@ namespace hex::plugin::builtin::ui {
} }
inline void drawOffsetColumnForBitfieldMember(const pl::ptrn::PatternBitfieldMember &pattern) { inline void drawOffsetColumnForBitfieldMember(const pl::ptrn::PatternBitfieldMember &pattern) {
auto bitOffset = pattern.getBitOffsetForDisplay(); if (pattern.isPatternLocal()) {
if (pattern.getBitSize() <= 1) ImGui::TextFormatted("[{}]", "hex.builtin.pattern_drawer.local"_lang);
ImGui::TextFormatted("bit {0}", bitOffset); ImGui::TableNextColumn();
else ImGui::TextFormatted("[{}]", "hex.builtin.pattern_drawer.local"_lang);
ImGui::TextFormatted("bits {0} - {1}", bitOffset, bitOffset + pattern.getBitSize() - 1); ImGui::TableNextColumn();
} else {
ImGui::TextFormatted("0x{0:08X}, bit {1}", pattern.getOffset(), pattern.getBitOffsetForDisplay());
ImGui::TableNextColumn();
ImGui::TextFormatted("0x{0:08X}, bit {1}", pattern.getOffset() + pattern.getSize(), pattern.getBitOffsetForDisplay() + pattern.getBitSize() - (pattern.getSize() == 0 ? 0 : 1));
ImGui::TableNextColumn();
}
} }
void drawOffsetColumn(const pl::ptrn::Pattern& pattern) { void drawOffsetColumn(const pl::ptrn::Pattern& pattern) {
if (pattern.isPatternLocal()) { if (auto *bitfieldMember = dynamic_cast<pl::ptrn::PatternBitfieldMember const*>(&pattern); bitfieldMember != nullptr && bitfieldMember->getParentBitfield() != nullptr)
ImGui::TextFormatted("[{}]", "hex.builtin.pattern_drawer.local"_lang); drawOffsetColumnForBitfieldMember(*bitfieldMember);
} else { else {
if (auto *bitfieldMember = dynamic_cast<pl::ptrn::PatternBitfieldMember const*>(&pattern); bitfieldMember != nullptr && bitfieldMember->getParentBitfield() != nullptr) if (pattern.isPatternLocal()) {
drawOffsetColumnForBitfieldMember(*bitfieldMember); ImGui::TextFormatted("[{}]", "hex.builtin.pattern_drawer.local"_lang);
else if (pattern.getSize() > 0) { } else {
ImGui::TextFormatted("0x{0:08X} : 0x{1:08X}", pattern.getOffset(), pattern.getOffset() + pattern.getSize() - (pattern.getSize() == 0 ? 0 : 1)); if (pattern.getSize() > 0) {
ImGui::TextFormatted("0x{0:08X}", pattern.getOffset());
}
} }
}
ImGui::TableNextColumn(); ImGui::TableNextColumn();
if (pattern.isPatternLocal()) {
ImGui::TextFormatted("[{}]", "hex.builtin.pattern_drawer.local"_lang);
} else {
if (pattern.getSize() > 0) {
ImGui::TextFormatted("0x{0:08X}", pattern.getOffset() + pattern.getSize() - (pattern.getSize() == 0 ? 0 : 1));
}
}
ImGui::TableNextColumn();
}
} }
inline void drawSizeColumnForBitfieldMember(const pl::ptrn::PatternBitfieldMember &pattern) { inline void drawSizeColumnForBitfieldMember(const pl::ptrn::PatternBitfieldMember &pattern) {
@ -358,7 +376,6 @@ namespace hex::plugin::builtin::ui {
ImGui::TableNextColumn(); ImGui::TableNextColumn();
drawColorColumn(pattern); drawColorColumn(pattern);
drawOffsetColumnForBitfieldMember(pattern); drawOffsetColumnForBitfieldMember(pattern);
ImGui::TableNextColumn();
drawSizeColumnForBitfieldMember(pattern); drawSizeColumnForBitfieldMember(pattern);
ImGui::TableNextColumn(); ImGui::TableNextColumn();
ImGui::TextFormattedColored(ImColor(0xFF9BC64D), "bits"); ImGui::TextFormattedColored(ImColor(0xFF9BC64D), "bits");
@ -901,11 +918,16 @@ namespace hex::plugin::builtin::ui {
return left->getDisplayName() < right->getDisplayName(); return left->getDisplayName() < right->getDisplayName();
else else
return left->getDisplayName() > right->getDisplayName(); return left->getDisplayName() > right->getDisplayName();
} else if (sortSpecs->Specs->ColumnUserID == ImGui::GetID("offset")) { } else if (sortSpecs->Specs->ColumnUserID == ImGui::GetID("start")) {
if (sortSpecs->Specs->SortDirection == ImGuiSortDirection_Ascending) if (sortSpecs->Specs->SortDirection == ImGuiSortDirection_Ascending)
return left->getOffsetForSorting() < right->getOffsetForSorting(); return left->getOffsetForSorting() < right->getOffsetForSorting();
else else
return left->getOffsetForSorting() > right->getOffsetForSorting(); return left->getOffsetForSorting() > right->getOffsetForSorting();
} else if (sortSpecs->Specs->ColumnUserID == ImGui::GetID("end")) {
if (sortSpecs->Specs->SortDirection == ImGuiSortDirection_Ascending)
return left->getOffsetForSorting() + left->getSize() < right->getOffsetForSorting() + right->getSize();
else
return left->getOffsetForSorting() + left->getSize() > right->getOffsetForSorting() + right->getSize();
} else if (sortSpecs->Specs->ColumnUserID == ImGui::GetID("size")) { } else if (sortSpecs->Specs->ColumnUserID == ImGui::GetID("size")) {
if (sortSpecs->Specs->SortDirection == ImGuiSortDirection_Ascending) if (sortSpecs->Specs->SortDirection == ImGuiSortDirection_Ascending)
return left->getSizeForSorting() < right->getSizeForSorting(); return left->getSizeForSorting() < right->getSizeForSorting();
@ -932,12 +954,13 @@ namespace hex::plugin::builtin::ui {
} }
static bool beginPatternTable(const std::vector<std::shared_ptr<pl::ptrn::Pattern>> &patterns, std::vector<pl::ptrn::Pattern*> &sortedPatterns, float height) { static bool beginPatternTable(const std::vector<std::shared_ptr<pl::ptrn::Pattern>> &patterns, std::vector<pl::ptrn::Pattern*> &sortedPatterns, float height) {
if (ImGui::BeginTable("##Patterntable", 7, ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable | ImGuiTableFlags_Sortable | ImGuiTableFlags_Hideable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_RowBg | ImGuiTableFlags_ScrollY, ImVec2(0, height))) { if (ImGui::BeginTable("##Patterntable", 8, ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable | ImGuiTableFlags_Sortable | ImGuiTableFlags_Hideable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_RowBg | ImGuiTableFlags_ScrollY, ImVec2(0, height))) {
ImGui::TableSetupScrollFreeze(0, 1); ImGui::TableSetupScrollFreeze(0, 1);
ImGui::TableSetupColumn("##favorite", ImGuiTableColumnFlags_NoSort | ImGuiTableColumnFlags_WidthFixed | ImGuiTableColumnFlags_NoResize | ImGuiTableColumnFlags_NoReorder | ImGuiTableColumnFlags_NoHide | ImGuiTableColumnFlags_IndentDisable, ImGui::GetTextLineHeight(), ImGui::GetID("favorite")); ImGui::TableSetupColumn("##favorite", ImGuiTableColumnFlags_NoSort | ImGuiTableColumnFlags_WidthFixed | ImGuiTableColumnFlags_NoResize | ImGuiTableColumnFlags_NoReorder | ImGuiTableColumnFlags_NoHide | ImGuiTableColumnFlags_IndentDisable, ImGui::GetTextLineHeight(), ImGui::GetID("favorite"));
ImGui::TableSetupColumn("hex.builtin.pattern_drawer.var_name"_lang, ImGuiTableColumnFlags_PreferSortAscending | ImGuiTableColumnFlags_NoHide | ImGuiTableColumnFlags_IndentEnable, 0, ImGui::GetID("name")); ImGui::TableSetupColumn("hex.builtin.pattern_drawer.var_name"_lang, ImGuiTableColumnFlags_PreferSortAscending | ImGuiTableColumnFlags_NoHide | ImGuiTableColumnFlags_IndentEnable, 0, ImGui::GetID("name"));
ImGui::TableSetupColumn("hex.builtin.pattern_drawer.color"_lang, ImGuiTableColumnFlags_PreferSortAscending, 0, ImGui::GetID("color")); ImGui::TableSetupColumn("hex.builtin.pattern_drawer.color"_lang, ImGuiTableColumnFlags_PreferSortAscending, 0, ImGui::GetID("color"));
ImGui::TableSetupColumn("hex.builtin.pattern_drawer.offset"_lang, ImGuiTableColumnFlags_PreferSortAscending | ImGuiTableColumnFlags_DefaultSort, 0, ImGui::GetID("offset")); ImGui::TableSetupColumn("hex.builtin.pattern_drawer.start"_lang, ImGuiTableColumnFlags_PreferSortAscending | ImGuiTableColumnFlags_DefaultSort, 0, ImGui::GetID("start"));
ImGui::TableSetupColumn("hex.builtin.pattern_drawer.end"_lang, ImGuiTableColumnFlags_PreferSortAscending | ImGuiTableColumnFlags_DefaultSort, 0, ImGui::GetID("end"));
ImGui::TableSetupColumn("hex.builtin.pattern_drawer.size"_lang, ImGuiTableColumnFlags_PreferSortAscending, 0, ImGui::GetID("size")); ImGui::TableSetupColumn("hex.builtin.pattern_drawer.size"_lang, ImGuiTableColumnFlags_PreferSortAscending, 0, ImGui::GetID("size"));
ImGui::TableSetupColumn("hex.builtin.pattern_drawer.type"_lang, ImGuiTableColumnFlags_PreferSortAscending, 0, ImGui::GetID("type")); ImGui::TableSetupColumn("hex.builtin.pattern_drawer.type"_lang, ImGuiTableColumnFlags_PreferSortAscending, 0, ImGui::GetID("type"));
ImGui::TableSetupColumn("hex.builtin.pattern_drawer.value"_lang, ImGuiTableColumnFlags_PreferSortAscending, 0, ImGui::GetID("value")); ImGui::TableSetupColumn("hex.builtin.pattern_drawer.value"_lang, ImGuiTableColumnFlags_PreferSortAscending, 0, ImGui::GetID("value"));