1
0
mirror of synced 2024-12-04 20:17:57 +01:00
ImHex/plugins/builtin/include/content/views/view_diff.hpp
2023-11-21 13:47:50 +01:00

53 lines
1.2 KiB
C++

#pragma once
#include <hex.hpp>
#include <hex/ui/view.hpp>
#include <hex/api/task_manager.hpp>
#include <array>
#include <vector>
#include "ui/hex_editor.hpp"
namespace hex::plugin::builtin {
class ViewDiff : public View::Window {
public:
ViewDiff();
~ViewDiff() override;
void drawContent() override;
ImGuiWindowFlags getWindowFlags() const override { return ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse; }
public:
struct Column {
ui::HexEditor hexEditor;
int provider = -1;
i32 scrollLock = 0;
};
enum class DifferenceType : u8 {
Added,
Removed,
Modified
};
struct Diff {
Region region;
DifferenceType type;
};
private:
std::function<std::optional<color_t>(u64, const u8*, size_t)> createCompareFunction(size_t otherIndex) const;
void analyze(prv::Provider *providerA, prv::Provider *providerB);
private:
std::array<Column, 2> m_columns;
std::vector<Diff> m_diffs;
TaskHolder m_diffTask;
std::atomic<bool> m_analyzed = false;
};
}