#pragma once #include #include #include #include #include #include #include #include #include "RichText/TextBox.hpp" namespace CustomEvents { void init(); extern std::queue> eventDataQueue; extern std::mutex eventDataQueueMutex; template bool emit_event(const T& data) { std::scoped_lock l{eventDataQueueMutex}; SDL_Event event; SDL_zero(event); event.type = T::EVENT_NUM; if(SDL_PushEvent(&event)) { eventDataQueue.push(std::make_shared(data)); return true; } return false; } template std::shared_ptr get_event() { std::scoped_lock l{eventDataQueueMutex}; std::shared_ptr toRet = std::static_pointer_cast(eventDataQueue.front()); eventDataQueue.pop(); return toRet; } struct PasteEvent { static uint32_t EVENT_NUM; enum class DataType { TEXT, IMAGE } type; std::string data; std::optional richText; std::optional mousePos; }; struct OpenInfiniPaintFileEvent { static uint32_t EVENT_NUM; bool isClient; std::optional filePathSource; std::string netSource; std::string serverLocalID; std::string_view fileDataBuffer; }; struct AddFileToCanvasEvent { static uint32_t EVENT_NUM; enum class Type { BUFFER, PATH } type; std::string name; std::string buffer; std::filesystem::path filePath; Vector2f pos; }; }