sys: Updated ImGui, ImPlot and imnodes to latest versions

This commit is contained in:
WerWolv
2022-08-03 23:32:34 +02:00
parent 09a1e59b8c
commit deabacbd50
43 changed files with 10201 additions and 10955 deletions

View File

@@ -996,8 +996,10 @@ namespace hex::plugin::builtin {
}
void drawPlot(const ImVec2 &viewSize) {
ImPlot::SetNextPlotLimits(0, 256, 0.5, float(*std::max_element(this->m_counts.begin(), this->m_counts.end())) * 1.1F, ImGuiCond_Always);
if (ImPlot::BeginPlot("##distribution", "Address", "Count", viewSize, ImPlotFlags_NoLegend | ImPlotFlags_NoMenus | ImPlotFlags_NoBoxSelect, ImPlotAxisFlags_Lock, ImPlotAxisFlags_Lock | ImPlotAxisFlags_LogScale, ImPlotAxisFlags_NoLabel | ImPlotAxisFlags_NoTickLabels, ImPlotAxisFlags_NoLabel | ImPlotAxisFlags_NoTickLabels)) {
if (ImPlot::BeginPlot("##distribution", viewSize, ImPlotFlags_NoLegend | ImPlotFlags_NoMenus | ImPlotFlags_NoBoxSelect)) {
ImPlot::SetupAxes("Address", "Count", ImPlotAxisFlags_Lock, ImPlotAxisFlags_Lock | ImPlotAxisFlags_LogScale);
ImPlot::SetupAxesLimits(0, 256, 1, double(*std::max_element(this->m_counts.begin(), this->m_counts.end())) * 1.1F, ImGuiCond_Always);
static auto x = [] {
std::array<ImU64, 256> result { 0 };
std::iota(result.begin(), result.end(), 0);

View File

@@ -412,7 +412,7 @@ namespace hex::plugin::builtin {
ImGui::EndTable();
}
ImGui::PushItemWidth(ImGui::GetContentRegionAvailWidth());
ImGui::PushItemWidth(ImGui::GetContentRegionAvail().x);
if (ImGui::InputText("##input", mathInput, ImGuiInputTextFlags_EnterReturnsTrue | ImGuiInputTextFlags_AutoSelectAll)) {
ImGui::SetKeyboardFocusHere();
evaluate = true;
@@ -622,7 +622,7 @@ namespace hex::plugin::builtin {
ImGui::TableNextColumn();
if (ImGui::Hyperlink(link.c_str())) {
if (ImGui::GetMergedKeyModFlags() == ImGuiKeyModFlags_Ctrl)
if (ImGui::IsKeyDown(ImGuiKey_LeftCtrl))
hex::openWebpage(link);
else
ImGui::SetClipboardText(link.c_str());

View File

@@ -123,7 +123,7 @@ namespace hex::plugin::builtin {
void ViewBookmarks::drawContent() {
if (ImGui::Begin(View::toWindowName("hex.builtin.view.bookmarks.name").c_str(), &this->getWindowOpenState())) {
ImGui::PushItemWidth(ImGui::GetContentRegionAvailWidth());
ImGui::PushItemWidth(ImGui::GetContentRegionAvail().x);
ImGui::InputTextWithHint("##filter", "hex.builtin.common.filter"_lang, this->m_currFilter);
ImGui::PopItemWidth();

View File

@@ -529,7 +529,7 @@ namespace hex::plugin::builtin {
auto &currOccurrences = this->m_sortedOccurrences[provider];
ImGui::PushItemWidth(ImGui::GetContentRegionAvailWidth());
ImGui::PushItemWidth(ImGui::GetContentRegionAvail().x);
if (ImGui::InputTextWithHint("##filter", "hex.builtin.common.filter"_lang, this->m_currFilter)) {
this->m_sortedOccurrences = this->m_foundOccurrences;

View File

@@ -85,7 +85,7 @@ namespace hex::plugin::builtin {
if (this->m_newHashName.empty() && this->m_selectedHash != nullptr)
this->m_newHashName = hex::format("{} {}", LangEntry(this->m_selectedHash->getUnlocalizedName()), static_cast<const char *>("hex.builtin.view.hashes.hash"_lang));
if (ImGui::BeginChild("##settings", ImVec2(ImGui::GetContentRegionAvailWidth(), 200_scaled), true)) {
if (ImGui::BeginChild("##settings", ImVec2(ImGui::GetContentRegionAvail().x, 200_scaled), true)) {
if (this->m_selectedHash != nullptr) {
auto startPos = ImGui::GetCursorPosY();
this->m_selectedHash->draw();
@@ -110,7 +110,7 @@ namespace hex::plugin::builtin {
}
ImGui::EndDisabled();
if (ImGui::BeginTable("##hashes", 3, ImGuiTableFlags_RowBg | ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_Borders, ImVec2(ImGui::GetContentRegionAvailWidth(), ImGui::GetTextLineHeightWithSpacing() * 10))) {
if (ImGui::BeginTable("##hashes", 3, ImGuiTableFlags_RowBg | ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_Borders, ImVec2(ImGui::GetContentRegionAvail().x, ImGui::GetTextLineHeightWithSpacing() * 10))) {
ImGui::TableSetupColumn("hex.builtin.view.hashes.name"_lang);
ImGui::TableSetupColumn("hex.builtin.view.hashes.type"_lang);
ImGui::TableSetupColumn("hex.builtin.view.hashes.result"_lang, ImGuiTableColumnFlags_WidthStretch);
@@ -159,7 +159,7 @@ namespace hex::plugin::builtin {
else
result = "???";
ImGui::PushItemWidth(ImGui::GetContentRegionAvailWidth());
ImGui::PushItemWidth(ImGui::GetContentRegionAvail().x);
ImGui::InputText("##result", result, ImGuiInputTextFlags_ReadOnly);
ImGui::PopItemWidth();

View File

@@ -44,7 +44,7 @@ namespace hex::plugin::builtin {
}
ImGui::SetKeyboardFocusHere();
ImGui::CaptureKeyboardFromApp(true);
ImGui::SetNextFrameWantCaptureKeyboard(true);
if (ImGui::InputText("##input", this->m_input, ImGuiInputTextFlags_EnterReturnsTrue | ImGuiInputTextFlags_AutoSelectAll)) {
if (auto result = this->m_evaluator.evaluate(this->m_input); result.has_value()) {
const auto inputResult = result.value();
@@ -531,7 +531,7 @@ namespace hex::plugin::builtin {
}
else {
ImGui::SetKeyboardFocusHere();
ImGui::CaptureKeyboardFromApp(true);
ImGui::SetNextFrameWantCaptureKeyboard(true);
if (ImGui::IsMouseClicked(ImGuiMouseButton_Left)) {
this->m_editingAddress = std::nullopt;
@@ -682,8 +682,9 @@ namespace hex::plugin::builtin {
if (ImHexApi::Provider::isValid()) {
auto provider = ImHexApi::Provider::get();
ImGuiListClipper clipper(std::ceil(provider->getSize() / (long double)(this->m_bytesPerRow)), CharacterSize.y);
ImGuiListClipper clipper;
clipper.Begin(std::ceil(provider->getSize() / (long double)(this->m_bytesPerRow)), CharacterSize.y);
while (clipper.Step()) {
this->m_visibleRowCount = clipper.DisplayEnd - clipper.DisplayStart;
@@ -1039,7 +1040,7 @@ namespace hex::plugin::builtin {
void ViewHexEditor::drawContent() {
if (ImGui::Begin(View::toWindowName(this->getUnlocalizedName()).c_str(), &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoNavInputs | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse)) {
const auto FooterSize = ImVec2(ImGui::GetContentRegionAvailWidth(), ImGui::GetTextLineHeightWithSpacing() * 3);
const auto FooterSize = ImVec2(ImGui::GetContentRegionAvail().x, ImGui::GetTextLineHeightWithSpacing() * 3);
const auto TableSize = ImGui::GetContentRegionAvail() - ImVec2(0, FooterSize.y);
this->drawPopup();

View File

@@ -101,7 +101,7 @@ namespace hex::plugin::builtin {
{
this->m_blockSize = std::max<u32>(std::ceil(provider->getActualSize() / 2048.0F), 256);
std::array<ImU64, 256> valueCounts = { 0 }, blockValueCounts = { 0 };
std::array<ImU64, 256> blockValueCounts = { 0 };
this->m_blockEntropy.clear();
this->m_valueCounts.fill(0);
@@ -110,7 +110,7 @@ namespace hex::plugin::builtin {
u64 count = 0;
for (u8 byte : reader) {
valueCounts[byte]++;
this->m_valueCounts[byte]++;
blockValueCounts[byte]++;
count++;
@@ -121,9 +121,7 @@ namespace hex::plugin::builtin {
}
}
this->m_valueCounts = valueCounts;
this->m_averageEntropy = calculateEntropy(valueCounts, provider->getSize());
this->m_averageEntropy = calculateEntropy(this->m_valueCounts, provider->getSize());
if (!this->m_blockEntropy.empty())
this->m_highestBlockEntropy = *std::max_element(this->m_blockEntropy.begin(), this->m_blockEntropy.end());
else
@@ -142,7 +140,7 @@ namespace hex::plugin::builtin {
if (ImHexApi::Provider::isValid() && provider->isReadable()) {
ImGui::BeginDisabled(this->m_analyzing);
{
if (ImGui::Button("hex.builtin.view.information.analyze"_lang, ImVec2(ImGui::GetContentRegionAvailWidth(), 0)))
if (ImGui::Button("hex.builtin.view.information.analyze"_lang, ImVec2(ImGui::GetContentRegionAvail().x, 0)))
this->analyze();
}
ImGui::EndDisabled();
@@ -218,8 +216,10 @@ namespace hex::plugin::builtin {
ImPlot::PushStyleColor(ImPlotCol_FrameBg, ImGui::GetColorU32(ImGuiCol_WindowBg));
ImGui::TextUnformatted("hex.builtin.view.information.distribution"_lang);
ImPlot::SetNextPlotLimits(0, 256, 0.5, float(*std::max_element(this->m_valueCounts.begin(), this->m_valueCounts.end())) * 1.1F, ImGuiCond_Always);
if (ImPlot::BeginPlot("##distribution", "Address", "Count", ImVec2(-1, 0), ImPlotFlags_NoChild | ImPlotFlags_NoLegend | ImPlotFlags_NoMenus | ImPlotFlags_NoBoxSelect, ImPlotAxisFlags_Lock, ImPlotAxisFlags_Lock | ImPlotAxisFlags_LogScale)) {
if (ImPlot::BeginPlot("##distribution", ImVec2(-1, 0), ImPlotFlags_NoChild | ImPlotFlags_NoLegend | ImPlotFlags_NoMenus | ImPlotFlags_NoBoxSelect)) {
ImPlot::SetupAxes("Address", "Count", ImPlotAxisFlags_Lock, ImPlotAxisFlags_Lock | ImPlotAxisFlags_LogScale);
ImPlot::SetupAxesLimits(0, 256, 1, double(*std::max_element(this->m_valueCounts.begin(), this->m_valueCounts.end())) * 1.1F, ImGuiCond_Always);
static auto x = [] {
std::array<ImU64, 256> result { 0 };
std::iota(result.begin(), result.end(), 0);
@@ -235,12 +235,14 @@ namespace hex::plugin::builtin {
ImGui::TextUnformatted("hex.builtin.view.information.entropy"_lang);
ImPlot::SetNextPlotLimits(0, this->m_blockEntropy.size(), -0.1, 1.1, ImGuiCond_Always);
if (ImPlot::BeginPlot("##entropy", "Address", "Entropy", ImVec2(-1, 0), ImPlotFlags_NoChild | ImPlotFlags_CanvasOnly | ImPlotFlags_AntiAliased, ImPlotAxisFlags_Lock | ImPlotAxisFlags_NoTickLabels, ImPlotAxisFlags_Lock)) {
if (ImPlot::BeginPlot("##entropy", ImVec2(-1, 0), ImPlotFlags_NoChild | ImPlotFlags_CanvasOnly)) {
ImPlot::SetupAxes("Address", "Entropy", ImPlotAxisFlags_Lock, ImPlotAxisFlags_Lock);
ImPlot::SetupAxesLimits(0, this->m_blockEntropy.size(), -0.1F, 1.1F, ImGuiCond_Always);
ImPlot::PlotLine("##entropy_line", this->m_blockEntropy.data(), this->m_blockEntropy.size());
if (ImPlot::DragLineX("Position", &this->m_entropyHandlePosition, false)) {
u64 address = u64(this->m_entropyHandlePosition * this->m_blockSize) + provider->getBaseAddress();
if (ImPlot::DragLineX(1, &this->m_entropyHandlePosition, ImGui::GetStyleColorVec4(ImGuiCol_Text))) {
u64 address = u64(std::max<double>(this->m_entropyHandlePosition, 0) * this->m_blockSize) + provider->getBaseAddress();
address = std::min(address, provider->getBaseAddress() + provider->getSize() - 1);
ImHexApi::HexEditor::setSelection(address, 1);
}

View File

@@ -46,8 +46,9 @@ namespace hex::plugin::builtin {
auto &patches = provider->getPatches();
u32 index = 0;
ImGuiListClipper clipper(patches.size());
ImGuiListClipper clipper;
clipper.Begin(patches.size());
while (clipper.Step()) {
auto iter = patches.begin();
for (auto i = 0; i < clipper.DisplayStart; i++)

View File

@@ -438,7 +438,10 @@ namespace hex::plugin::builtin {
void ViewPatternEditor::drawConsole(ImVec2 size) {
ImGui::PushStyleColor(ImGuiCol_ChildBg, this->m_textEditor.GetPalette()[u32(TextEditor::PaletteIndex::Background)]);
if (ImGui::BeginChild("##console", size, true, ImGuiWindowFlags_AlwaysVerticalScrollbar | ImGuiWindowFlags_HorizontalScrollbar)) {
ImGuiListClipper clipper(this->m_console.size());
ImGuiListClipper clipper;
clipper.Begin(this->m_console.size());
while (clipper.Step())
for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) {
const auto &[level, message] = this->m_console[i];
@@ -488,7 +491,7 @@ namespace hex::plugin::builtin {
ImGui::PushID(index++);
ON_SCOPE_EXIT { ImGui::PopID(); };
ImGui::PushItemWidth(ImGui::GetContentRegionAvailWidth());
ImGui::PushItemWidth(ImGui::GetContentRegionAvail().x);
constexpr const char *Types[] = { "I", "F", "S", "B" };
if (ImGui::BeginCombo("", Types[static_cast<int>(type)])) {
for (auto i = 0; i < IM_ARRAYSIZE(Types); i++) {
@@ -502,13 +505,13 @@ namespace hex::plugin::builtin {
ImGui::TableNextColumn();
ImGui::PushItemWidth(ImGui::GetContentRegionAvailWidth());
ImGui::PushItemWidth(ImGui::GetContentRegionAvail().x);
ImGui::InputText("###name", name);
ImGui::PopItemWidth();
ImGui::TableNextColumn();
ImGui::PushItemWidth(ImGui::GetContentRegionAvailWidth());
ImGui::PushItemWidth(ImGui::GetContentRegionAvail().x);
switch (type) {
case EnvVarType::Integer:
{

View File

@@ -128,7 +128,9 @@ namespace hex::plugin::builtin {
auto consoleSize = ImGui::GetContentRegionAvail();
if (ImGui::BeginChild("##console", consoleSize, true, ImGuiWindowFlags_AlwaysVerticalScrollbar | ImGuiWindowFlags_HorizontalScrollbar)) {
ImGuiListClipper clipper(this->m_consoleMessages.size());
ImGuiListClipper clipper;
clipper.Begin(this->m_consoleMessages.size());
while (clipper.Step())
for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) {
const auto &message = this->m_consoleMessages[i];