mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-03 05:57:40 -05:00
Refactored libimhex to and includes to better represent it as library
This commit is contained in:
46
plugins/libimhex/include/hex/api/event.hpp
Normal file
46
plugins/libimhex/include/hex/api/event.hpp
Normal file
@@ -0,0 +1,46 @@
|
||||
#pragma once
|
||||
|
||||
#include <hex.hpp>
|
||||
|
||||
#include <vector>
|
||||
#include <functional>
|
||||
|
||||
namespace hex {
|
||||
|
||||
enum class Events : u32 {
|
||||
FileLoaded,
|
||||
DataChanged,
|
||||
PatternChanged,
|
||||
FileDropped,
|
||||
WindowClosing,
|
||||
RegionSelected,
|
||||
|
||||
SelectionChangeRequest,
|
||||
|
||||
AddBookmark,
|
||||
AppendPatternLanguageCode,
|
||||
|
||||
ProjectFileStore,
|
||||
ProjectFileLoad,
|
||||
|
||||
SettingsChanged,
|
||||
|
||||
|
||||
/* This is not a real event but a flag to show all events after this one are plugin ones */
|
||||
Events_BuiltinEnd
|
||||
};
|
||||
|
||||
struct EventHandler {
|
||||
void *owner;
|
||||
Events eventType;
|
||||
std::function<void(const void*)> callback;
|
||||
};
|
||||
|
||||
class EventManager {
|
||||
public:
|
||||
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);
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user