/* * InfiniPaint * Copyright (C) 2025-2026 Yousef Khadadeh * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #pragma once #include #include #include #include #include #include #include #include #include #include "RichText/TextBox.hpp" namespace CustomEvents { void init(); typedef int64_t InputTextBoxID; InputTextBoxID text_box_get_new_id(); 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; bool saveThumbnail = false; std::optional filePathEmptyAutoSaveDir; 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; }; struct RefreshTextBoxInputEvent { static uint32_t EVENT_NUM; }; struct AndroidTextBoxInputEvent { static uint32_t EVENT_NUM; InputTextBoxID textboxID; enum class CommandType { COMMIT_ALL } command; std::string strData; Vector3i intData; }; struct AndroidInsetsChangedEvent { static uint32_t EVENT_NUM; SCollision::AABB safeWindowRect; }; }