1 #pragma once 2 3 #include <hex.hpp> 4 5 #include <any> 6 #include <functional> 7 #include <vector> 8 9 namespace hex { 10 11 enum class Events : u32 { 12 FileLoaded, 13 DataChanged, 14 PatternChanged, 15 FileDropped, 16 WindowClosing, 17 RegionSelected, 18 19 SelectionChangeRequest, 20 21 AddBookmark, 22 AppendPatternLanguageCode, 23 24 ProjectFileStore, 25 ProjectFileLoad, 26 27 SettingsChanged, 28 29 OpenWindow, 30 CloseImHex, 31 32 /* This is not a real event but a flag to show all events after this one are plugin ones */ 33 Events_BuiltinEnd 34 }; 35 36 struct EventHandler { 37 void *owner; 38 Events eventType; 39 std::function<std::any(const std::any&)> callback; 40 }; 41 42 class EventManager { 43 public: 44 static std::vector<std::any> post(Events eventType, const std::any &userData); 45 static void subscribe(Events eventType, void *owner, std::function<std::any(const std::any&)> callback); 46 static void unsubscribe(Events eventType, void *sender); 47 }; 48 49 }