ui: Added global running tasks progress bar

This commit is contained in:
WerWolv
2021-12-16 23:48:52 +01:00
parent 677036fb9c
commit 891cc42f08
18 changed files with 193 additions and 29 deletions

View File

@@ -71,8 +71,19 @@ namespace hex::plugin::builtin {
std::thread([this]{
auto provider = ImHexApi::Provider::get();
auto task = ImHexApi::Tasks::createTask("hex.builtin.view.information.analyzing", provider->getSize());
this->m_analyzedRegion = { provider->getBaseAddress(), provider->getBaseAddress() + provider->getSize() };
{
magic::compile();
this->m_fileDescription = magic::getDescription(provider);
this->m_mimeType = magic::getMIMEType(provider);
}
this->m_dataValid = true;
{
this->m_blockSize = std::max<u32>(std::ceil(provider->getSize() / 2048.0F), 256);
std::vector<u8> buffer(this->m_blockSize, 0x00);
@@ -90,22 +101,13 @@ namespace hex::plugin::builtin {
}
this->m_blockEntropy.push_back(calculateEntropy(blockValueCounts, this->m_blockSize));
this->m_bytesAnalyzed = i;
task.update(i);
}
this->m_averageEntropy = calculateEntropy(this->m_valueCounts, provider->getSize());
this->m_highestBlockEntropy = *std::max_element(this->m_blockEntropy.begin(), this->m_blockEntropy.end());
}
{
magic::compile();
this->m_fileDescription = magic::getDescription(provider);
this->m_mimeType = magic::getMIMEType(provider);
this->m_dataValid = true;
}
this->m_analyzing = false;
}).detach();
}
@@ -127,10 +129,8 @@ namespace hex::plugin::builtin {
if (this->m_analyzing) {
ImGui::TextSpinner("hex.builtin.view.information.analyzing"_lang);
ImGui::ProgressBar(this->m_bytesAnalyzed / static_cast<double>(provider->getSize()));
} else {
ImGui::NewLine();
ImGui::NewLine();
}
ImGui::NewLine();