diff --git a/external/ImGui/include/imgui_memory_editor.h b/external/ImGui/include/imgui_memory_editor.h index d7d4978c4..0b71ab248 100644 --- a/external/ImGui/include/imgui_memory_editor.h +++ b/external/ImGui/include/imgui_memory_editor.h @@ -717,7 +717,6 @@ struct MemoryEditor ImGui::EndChild(); DataEditingAddr = DataPreviewAddr = HighlightMin; DataPreviewAddrEnd = HighlightMax; - DataEditingTakeFocus = true; } GotoAddr = (size_t)-1; } diff --git a/include/views/view_information.hpp b/include/views/view_information.hpp index e4112b45a..382dbba66 100644 --- a/include/views/view_information.hpp +++ b/include/views/view_information.hpp @@ -26,6 +26,8 @@ namespace hex { float m_highestBlockEntropy = 0; std::vector m_blockEntropy; + double m_entropyHandlePosition; + std::array m_valueCounts = { 0 }; bool m_analyzing = false; diff --git a/source/views/view_information.cpp b/source/views/view_information.cpp index a7eb3d6c4..7c12da656 100644 --- a/source/views/view_information.cpp +++ b/source/views/view_information.cpp @@ -30,10 +30,15 @@ namespace hex { this->m_fileDescription = ""; this->m_analyzedRegion = { 0, 0 }; }); + + EventManager::subscribe(this, [this](Region region) { + this->m_entropyHandlePosition = region.address / this->m_blockSize; + }); } ViewInformation::~ViewInformation() { EventManager::unsubscribe(this); + EventManager::unsubscribe(this); } static float calculateEntropy(std::array &valueCounts, size_t numBytes) { @@ -196,7 +201,9 @@ namespace hex { return result; }(); + ImPlot::PlotBars("##bytes", x.data(), this->m_valueCounts.data(), x.size(), 0.67); + ImPlot::EndPlot(); } @@ -208,8 +215,9 @@ namespace hex { if (ImPlot::BeginPlot("##entropy", "Address", "Entropy", ImVec2(-1,0), ImPlotFlags_CanvasOnly, ImPlotAxisFlags_Lock | ImPlotAxisFlags_NoTickLabels, ImPlotAxisFlags_Lock)) { ImPlot::PlotLine("##entropy_line", this->m_blockEntropy.data(), this->m_blockEntropy.size()); - if (ImGui::IsItemClicked()) - EventManager::post( Region{ u64(ImPlot::GetPlotMousePos().x) * this->m_blockSize, 1 }); + if (ImPlot::DragLineX("Position", &this->m_entropyHandlePosition, false)) { + EventManager::post( Region{ u64(this->m_entropyHandlePosition * this->m_blockSize), 1 }); + } ImPlot::EndPlot(); } @@ -218,7 +226,7 @@ namespace hex { ImGui::NewLine(); - ImGui::LabelText("hex.view.information.block_size"_lang, "hex.view.information.block_size.desc"_lang, this->m_blockEntropy.size(), this->m_blockSize); + ImGui::LabelText("hex.view.information.block_size"_lang, "%s", hex::format("hex.view.information.block_size.desc"_lang, this->m_blockEntropy.size(), this->m_blockSize).c_str()); ImGui::LabelText("hex.view.information.file_entropy"_lang, "%.8f", this->m_averageEntropy); ImGui::LabelText("hex.view.information.highest_entropy"_lang, "%.8f", this->m_highestBlockEntropy);