1
0
mirror of synced 2024-12-14 08:42:54 +01:00
ImHex/plugins/diffing/include/content/views/view_diff.hpp

48 lines
1.2 KiB
C++
Raw Normal View History

2021-09-21 02:48:41 +02:00
#pragma once
#include <hex.hpp>
#include <hex/ui/view.hpp>
#include <hex/api/task_manager.hpp>
2021-09-21 02:48:41 +02:00
#include <array>
2021-09-21 19:54:13 +02:00
#include <vector>
2021-09-21 02:48:41 +02:00
#include "ui/hex_editor.hpp"
namespace hex::plugin::diffing {
2021-09-21 02:48:41 +02:00
class ViewDiff : public View::Window {
2021-09-21 02:48:41 +02:00
public:
2021-09-21 19:54:13 +02:00
ViewDiff();
~ViewDiff() override;
2021-09-21 02:48:41 +02:00
void drawContent() override;
void drawAlwaysVisibleContent() override;
ImGuiWindowFlags getWindowFlags() const override { return ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse; }
2021-09-21 02:48:41 +02:00
2023-02-16 08:53:05 +01:00
public:
struct Column {
ui::HexEditor hexEditor;
ContentRegistry::Diffing::DiffTree diffTree;
2024-02-11 19:29:02 +01:00
std::vector<ContentRegistry::Diffing::DiffTree::Data> differences;
int provider = -1;
i32 scrollLock = 0;
};
private:
2023-11-10 20:47:08 +01:00
std::function<std::optional<color_t>(u64, const u8*, size_t)> createCompareFunction(size_t otherIndex) const;
void analyze(prv::Provider *providerA, prv::Provider *providerB);
2024-02-11 19:29:02 +01:00
void reset();
private:
std::array<Column, 2> m_columns;
2021-09-21 19:54:13 +02:00
TaskHolder m_diffTask;
std::atomic<bool> m_analyzed = false;
ContentRegistry::Diffing::Algorithm *m_algorithm = nullptr;
2021-09-21 02:48:41 +02:00
};
}