1
0
mirror of synced 2024-11-24 15:50:16 +01:00

impr: Better UI for the data information view

This commit is contained in:
WerWolv 2023-12-12 12:15:20 +01:00
parent 1b457dae7d
commit f618e634e9

View File

@ -141,17 +141,29 @@ namespace hex::plugin::builtin {
auto provider = ImHexApi::Provider::get(); auto provider = ImHexApi::Provider::get();
if (ImHexApi::Provider::isValid() && provider->isReadable()) { if (ImHexApi::Provider::isValid() && provider->isReadable()) {
ImGui::BeginDisabled(this->m_analyzerTask.isRunning()); ImGui::BeginDisabled(this->m_analyzerTask.isRunning());
ImGuiExt::BeginSubWindow("hex.builtin.common.settings"_lang);
{ {
ImGuiExt::Header("hex.builtin.common.settings"_lang, true); if (ImGui::BeginTable("SettingsTable", 2, ImGuiTableFlags_BordersInner | ImGuiTableFlags_SizingFixedSame, ImVec2(ImGui::GetContentRegionAvail().x, 0))) {
ImGui::TableSetupColumn("Left", ImGuiTableColumnFlags_WidthStretch, 0.3F);
ImGui::TableSetupColumn("Right", ImGuiTableColumnFlags_WidthStretch, 0.7F);
ImGui::TableNextRow();
ImGui::TableNextColumn();
ui::regionSelectionPicker(&this->m_analysisRegion, provider, &this->m_selectionType, false);
ui::regionSelectionPicker(&this->m_analysisRegion, provider, &this->m_selectionType, false); ImGui::TableNextColumn();
ImGui::InputInt("hex.builtin.view.information.block_size"_lang, &this->m_inputChunkSize, ImGuiInputTextFlags_CharsDecimal);
ImGui::EndTable();
}
ImGui::NewLine(); ImGui::NewLine();
ImGui::InputInt("hex.builtin.view.information.block_size"_lang, &this->m_inputChunkSize, ImGuiInputTextFlags_CharsDecimal); ImGui::SetCursorPosX(50_scaled);
if (ImGuiExt::DimmedButton("hex.builtin.view.information.analyze"_lang, ImVec2(ImGui::GetContentRegionAvail().x - 50_scaled, 0)))
if (ImGui::Button("hex.builtin.view.information.analyze"_lang, ImVec2(ImGui::GetContentRegionAvail().x, 0)))
this->analyze(); this->analyze();
} }
ImGuiExt::EndSubWindow();
ImGui::EndDisabled(); ImGui::EndDisabled();
if (this->m_analyzerTask.isRunning()) { if (this->m_analyzerTask.isRunning()) {
@ -282,8 +294,17 @@ namespace hex::plugin::builtin {
ImGui::TableNextColumn(); ImGui::TableNextColumn();
ImGuiExt::TextFormatted("{}", "hex.builtin.view.information.file_entropy"_lang); ImGuiExt::TextFormatted("{}", "hex.builtin.view.information.file_entropy"_lang);
ImGui::TableNextColumn(); ImGui::TableNextColumn();
if (this->m_averageEntropy < 0) ImGui::TextUnformatted("???"); if (this->m_averageEntropy < 0)
else ImGuiExt::TextFormatted("{:.5f}", std::abs(this->m_averageEntropy)); ImGui::TextUnformatted("???");
else {
auto entropy = std::abs(this->m_averageEntropy);
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 0.1F);
ImGui::PushStyleColor(ImGuiCol_FrameBg, ImGui::GetColorU32(ImGuiCol_TableRowBgAlt));
ImGui::PushStyleColor(ImGuiCol_PlotHistogram, ImColor::HSV(0.3F - (0.3F * entropy), 0.6F, 0.8F, 1.0F).Value);
ImGui::ProgressBar(entropy, ImVec2(200_scaled, ImGui::GetTextLineHeight()), hex::format("{:.5f}", entropy).c_str());
ImGui::PopStyleColor(2);
ImGui::PopStyleVar();
}
ImGui::TableNextColumn(); ImGui::TableNextColumn();
ImGuiExt::TextFormatted("{}", "hex.builtin.view.information.highest_entropy"_lang); ImGuiExt::TextFormatted("{}", "hex.builtin.view.information.highest_entropy"_lang);
@ -314,8 +335,16 @@ namespace hex::plugin::builtin {
ImGui::TableNextColumn(); ImGui::TableNextColumn();
ImGuiExt::TextFormatted("{}", "hex.builtin.view.information.plain_text_percentage"_lang); ImGuiExt::TextFormatted("{}", "hex.builtin.view.information.plain_text_percentage"_lang);
ImGui::TableNextColumn(); ImGui::TableNextColumn();
if (this->m_plainTextCharacterPercentage < 0) ImGui::TextUnformatted("???"); if (this->m_plainTextCharacterPercentage < 0)
else ImGuiExt::TextFormatted("{:.2f}%", this->m_plainTextCharacterPercentage); ImGui::TextUnformatted("???");
else {
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 0.1F);
ImGui::PushStyleColor(ImGuiCol_FrameBg, ImGui::GetColorU32(ImGuiCol_TableRowBgAlt));
ImGui::PushStyleColor(ImGuiCol_PlotHistogram, ImColor::HSV(0.3F * (this->m_plainTextCharacterPercentage / 100.0F), 0.8F, 0.6F, 1.0F).Value);
ImGui::ProgressBar(this->m_plainTextCharacterPercentage / 100.0F, ImVec2(200_scaled, ImGui::GetTextLineHeight()));
ImGui::PopStyleColor(2);
ImGui::PopStyleVar();
}
ImGui::EndTable(); ImGui::EndTable();
} }