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