1
0
mirror of synced 2024-11-12 02:00:52 +01:00

No need to manually set table colors

This commit is contained in:
WerWolv 2020-11-22 20:41:54 +01:00
parent 43f5cc622e
commit 8d6d959e17
3 changed files with 5 additions and 20 deletions

View File

@ -111,21 +111,18 @@ namespace hex {
if (ImGui::Begin("Data Inspector", &this->m_windowOpen)) { if (ImGui::Begin("Data Inspector", &this->m_windowOpen)) {
if (this->m_dataProvider != nullptr && this->m_dataProvider->isReadable()) { if (this->m_dataProvider != nullptr && this->m_dataProvider->isReadable()) {
if (ImGui::BeginChild("##scrolling", ImVec2(0, ImGui::GetWindowHeight() - 60))) { if (ImGui::BeginChild("##scrolling", ImVec2(0, ImGui::GetWindowHeight() - 60))) {
if (ImGui::BeginTable("##datainspector", 2, ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable | ImGuiTableFlags_RowBg)) { if (ImGui::BeginTable("##datainspector", 2, ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable | ImGuiTableFlags_RowBg | ImGuiTableFlags_NoBordersInBody)) {
ImGui::TableSetupColumn("Name"); ImGui::TableSetupColumn("Name");
ImGui::TableSetupColumn("Value"); ImGui::TableSetupColumn("Value");
ImGui::TableHeadersRow(); ImGui::TableHeadersRow();
u32 rowCount = 0;
for (const auto &[name, value] : this->m_cachedData) { for (const auto &[name, value] : this->m_cachedData) {
ImGui::TableNextRow(); ImGui::TableNextRow();
ImGui::TableNextColumn(); ImGui::TableNextColumn();
ImGui::TextUnformatted(name.c_str()); ImGui::TextUnformatted(name.c_str());
ImGui::TableNextColumn(); ImGui::TableNextColumn();
ImGui::TextUnformatted(value.c_str()); ImGui::TextUnformatted(value.c_str());
ImGui::TableSetBgColor(ImGuiTableBgTarget_RowBg0,
((rowCount % 2) == 0) ? 0xFF101010 : 0xFF303030);
rowCount++;
} }
{ {
@ -135,9 +132,6 @@ namespace hex {
ImGui::TableNextColumn(); ImGui::TableNextColumn();
ImGui::ColorButton("##nolabel", ImColor(hex::changeEndianess(this->m_previewData.unsigned32, this->m_endianess)), ImGui::ColorButton("##nolabel", ImColor(hex::changeEndianess(this->m_previewData.unsigned32, this->m_endianess)),
ImGuiColorEditFlags_None, ImVec2(ImGui::GetColumnWidth(), 15)); ImGuiColorEditFlags_None, ImVec2(ImGui::GetColumnWidth(), 15));
ImGui::TableSetBgColor(ImGuiTableBgTarget_RowBg0,
((rowCount % 2) == 0) ? 0xFF101010 : 0xFF303030);
rowCount++;
} }

View File

@ -18,7 +18,7 @@ namespace hex {
} }
static bool beginPatternDataTable(prv::Provider* &provider, const std::vector<lang::PatternData*> &patterns, std::vector<lang::PatternData*> &sortedPatterns) { static bool beginPatternDataTable(prv::Provider* &provider, const std::vector<lang::PatternData*> &patterns, std::vector<lang::PatternData*> &sortedPatterns) {
if (ImGui::BeginTable("##patterndatatable", 6, ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable | ImGuiTableFlags_Sortable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_RowBg)) { if (ImGui::BeginTable("##patterndatatable", 6, ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable | ImGuiTableFlags_Sortable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_RowBg | ImGuiTableFlags_NoBordersInBody)) {
ImGui::TableSetupColumn("Color", 0, -1, ImGui::GetID("color")); ImGui::TableSetupColumn("Color", 0, -1, ImGui::GetID("color"));
ImGui::TableSetupColumn("Name", 0, -1, ImGui::GetID("name")); ImGui::TableSetupColumn("Name", 0, -1, ImGui::GetID("name"));
ImGui::TableSetupColumn("Offset", 0, -1, ImGui::GetID("offset")); ImGui::TableSetupColumn("Offset", 0, -1, ImGui::GetID("offset"));
@ -60,13 +60,8 @@ namespace hex {
if (this->m_sortedPatternData.size() > 0) { if (this->m_sortedPatternData.size() > 0) {
ImGui::TableHeadersRow(); ImGui::TableHeadersRow();
u32 rowCount = 0; for (auto &patternData : this->m_sortedPatternData)
for (auto &patternData : this->m_sortedPatternData) {
patternData->createEntry(this->m_dataProvider); patternData->createEntry(this->m_dataProvider);
ImGui::TableSetBgColor(ImGuiTableBgTarget_RowBg0,
((rowCount % 2) == 0) ? 0xFF101010 : 0xFF303030);
rowCount++;
}
} }

View File

@ -74,7 +74,7 @@ namespace hex {
if (ImGui::BeginTable("##strings", 3, if (ImGui::BeginTable("##strings", 3,
ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable | ImGuiTableFlags_Sortable | ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable | ImGuiTableFlags_Sortable |
ImGuiTableFlags_Reorderable | ImGuiTableFlags_RowBg)) { ImGuiTableFlags_Reorderable | ImGuiTableFlags_RowBg | ImGuiTableFlags_NoBordersInBody)) {
ImGui::TableSetupColumn("Offset", 0, -1, ImGui::GetID("offset")); ImGui::TableSetupColumn("Offset", 0, -1, ImGui::GetID("offset"));
ImGui::TableSetupColumn("Size", 0, -1, ImGui::GetID("size")); ImGui::TableSetupColumn("Size", 0, -1, ImGui::GetID("size"));
ImGui::TableSetupColumn("String", 0, -1, ImGui::GetID("string")); ImGui::TableSetupColumn("String", 0, -1, ImGui::GetID("string"));
@ -113,7 +113,6 @@ namespace hex {
clipper.Begin(this->m_foundStrings.size()); clipper.Begin(this->m_foundStrings.size());
while (clipper.Step()) { while (clipper.Step()) {
u32 rowCount = clipper.DisplayStart;
for (u64 i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) { for (u64 i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) {
auto &foundString = this->m_foundStrings[i]; auto &foundString = this->m_foundStrings[i];
@ -128,9 +127,6 @@ namespace hex {
ImGui::Text("0x%04lx", foundString.size); ImGui::Text("0x%04lx", foundString.size);
ImGui::TableNextColumn(); ImGui::TableNextColumn();
ImGui::Text("%s", foundString.string.c_str()); ImGui::Text("%s", foundString.string.c_str());
ImGui::TableSetBgColor(ImGuiTableBgTarget_RowBg0,
((rowCount % 2) == 0) ? 0xFF101010 : 0xFF303030);
rowCount++;
} }
} }
clipper.End(); clipper.End();