impr: Improved size display in pattern data view
This commit is contained in:
parent
09b9f26e6f
commit
313e3e748f
@ -141,13 +141,42 @@ namespace hex::ui {
|
|||||||
|
|
||||||
void drawSizeColumnForBitfieldMember(const pl::ptrn::PatternBitfieldMember &pattern) {
|
void drawSizeColumnForBitfieldMember(const pl::ptrn::PatternBitfieldMember &pattern) {
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
if (pattern.getBitSize() == 1)
|
|
||||||
ImGuiExt::TextFormatted("1 bit");
|
auto bits = pattern.getBitSize();
|
||||||
|
auto bytes = bits / 8;
|
||||||
|
bits = bits % 8;
|
||||||
|
|
||||||
|
std::string text;
|
||||||
|
if (bytes != 0) {
|
||||||
|
if (bytes == 1)
|
||||||
|
text += hex::format("{0} byte", bytes);
|
||||||
else
|
else
|
||||||
ImGuiExt::TextFormatted("{0} bits", pattern.getBitSize());
|
text += hex::format("{0} bytes", bytes);
|
||||||
|
|
||||||
|
if (bits != 0)
|
||||||
|
text += ", ";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bits != 0) {
|
||||||
|
if (bits == 1)
|
||||||
|
text += hex::format("{0} bit", bits);
|
||||||
|
else
|
||||||
|
text += hex::format("{0} bits", bits);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bytes == 0 && bits == 0) {
|
||||||
|
text = "0 bytes";
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::TextUnformatted(text.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawSizeColumn(const pl::ptrn::Pattern& pattern) {
|
void drawSizeColumn(const pl::ptrn::Pattern& pattern) {
|
||||||
|
if (pattern.isPatternLocal()) {
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (auto *bitfieldMember = dynamic_cast<const pl::ptrn::PatternBitfieldMember*>(&pattern); bitfieldMember != nullptr && bitfieldMember->getParentBitfield() != nullptr)
|
if (auto *bitfieldMember = dynamic_cast<const pl::ptrn::PatternBitfieldMember*>(&pattern); bitfieldMember != nullptr && bitfieldMember->getParentBitfield() != nullptr)
|
||||||
drawSizeColumnForBitfieldMember(*bitfieldMember);
|
drawSizeColumnForBitfieldMember(*bitfieldMember);
|
||||||
else {
|
else {
|
||||||
|
Loading…
Reference in New Issue
Block a user