2020-12-22 17:10:01 +00:00
|
|
|
#pragma once
|
|
|
|
|
2021-01-11 20:11:03 +00:00
|
|
|
#include <hex.hpp>
|
|
|
|
|
2021-01-21 09:53:12 +00:00
|
|
|
#include <any>
|
2020-12-22 17:10:01 +00:00
|
|
|
#include <functional>
|
2021-01-21 09:53:12 +00:00
|
|
|
#include <vector>
|
2020-12-22 17:10:01 +00:00
|
|
|
|
|
|
|
namespace hex {
|
|
|
|
|
2021-01-11 20:11:03 +00:00
|
|
|
enum class Events : u32 {
|
2020-12-22 17:10:01 +00:00
|
|
|
FileLoaded,
|
|
|
|
DataChanged,
|
|
|
|
PatternChanged,
|
|
|
|
FileDropped,
|
|
|
|
WindowClosing,
|
|
|
|
RegionSelected,
|
|
|
|
|
|
|
|
SelectionChangeRequest,
|
|
|
|
|
|
|
|
AddBookmark,
|
|
|
|
AppendPatternLanguageCode,
|
|
|
|
|
|
|
|
ProjectFileStore,
|
2021-01-11 19:31:40 +00:00
|
|
|
ProjectFileLoad,
|
|
|
|
|
2021-01-11 20:11:03 +00:00
|
|
|
SettingsChanged,
|
|
|
|
|
2021-01-27 13:26:24 +00:00
|
|
|
OpenWindow,
|
2021-02-01 18:03:45 +00:00
|
|
|
CloseImHex,
|
2021-01-11 20:11:03 +00:00
|
|
|
|
|
|
|
/* This is not a real event but a flag to show all events after this one are plugin ones */
|
|
|
|
Events_BuiltinEnd
|
2020-12-22 17:10:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct EventHandler {
|
|
|
|
void *owner;
|
|
|
|
Events eventType;
|
2021-01-21 09:53:12 +00:00
|
|
|
std::function<std::any(const std::any&)> callback;
|
2020-12-22 17:10:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class EventManager {
|
|
|
|
public:
|
2021-01-21 09:53:12 +00:00
|
|
|
static std::vector<std::any> post(Events eventType, const std::any &userData);
|
|
|
|
static void subscribe(Events eventType, void *owner, std::function<std::any(const std::any&)> callback);
|
2021-01-03 23:19:56 +00:00
|
|
|
static void unsubscribe(Events eventType, void *sender);
|
2020-12-22 17:10:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|