Crafter.CppDOM/interfaces/Crafter.CppDOM-EventTypes.cppm

79 lines
3.1 KiB
Text
Raw Normal View History

2025-11-10 20:02:11 +01:00
/*
Crafter.CppDOM
Copyright (C) 2025 Catcrafts
Catcrafts.net
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3.0 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
export module Crafter.CppDOM:EventTypes;
import std;
export namespace Crafter {
struct KeyboardEvent {
std::string key;
std::uint_fast8_t keyCode;
bool altKey;
bool ctrlKey;
bool shiftKey;
bool metaKey;
KeyboardEvent(const char* key, std::int32_t keyCode, bool altKey, bool ctrlKey, bool shiftKey, bool metaKey) : key(key), keyCode(keyCode), altKey(altKey), ctrlKey(ctrlKey), shiftKey(shiftKey), metaKey(metaKey) {}
};
// Mouse event structure
struct MouseEvent {
double clientX;
double clientY;
double screenX;
double screenY;
std::uint_fast32_t button;
std::uint_fast32_t buttons;
bool altKey;
bool ctrlKey;
bool shiftKey;
bool metaKey;
2025-11-10 20:25:50 +01:00
MouseEvent(double clientX, double clientY, double screenX, double screenY, std::uint_fast32_t button, std::uint_fast32_t buttons, bool altKey, bool ctrlKey, bool shiftKey, bool metaKey) : clientX(clientX), clientY(clientY), screenX(screenX), screenY(screenY), button(button), buttons(buttons), altKey(altKey), ctrlKey(ctrlKey), shiftKey(shiftKey), metaKey(metaKey) {}
2025-11-10 20:02:11 +01:00
};
struct InputEvent {
std::string data;
bool isComposing;
2025-11-10 20:25:50 +01:00
InputEvent(const char* data, bool isComposing) : data(data), isComposing(isComposing) {}
2025-11-10 20:02:11 +01:00
};
struct WheelEvent : public MouseEvent {
double deltaX;
double deltaY;
double deltaZ;
2025-11-10 20:25:50 +01:00
WheelEvent(double clientX, double clientY, double screenX, double screenY, std::uint_fast32_t button, std::uint_fast32_t buttons, bool altKey, bool ctrlKey, bool shiftKey, bool metaKey, double deltaX, double deltaY, double deltaZ): MouseEvent(clientX, clientY, screenX, screenY, button, buttons, altKey, ctrlKey, shiftKey, metaKey), deltaX(deltaX), deltaY(deltaY), deltaZ(deltaZ) {}
2025-11-10 20:02:11 +01:00
};
struct ResizeEvent {
std::uint_fast32_t width;
std::uint_fast32_t height;
2025-11-10 20:25:50 +01:00
ResizeEvent(std::uint_fast32_t width, std::uint_fast32_t height) : width(width), height(height) {}
2025-11-10 20:02:11 +01:00
};
struct ScrollEvent {
double scrollX;
double scrollY;
2025-11-10 20:25:50 +01:00
ScrollEvent(double scrollX, double scrollY) : scrollX(scrollX), scrollY(scrollY) {}
2025-11-10 20:02:11 +01:00
};
struct ChangeEvent {
std::string value;
2025-11-10 20:25:50 +01:00
ChangeEvent(const char* value) : value(value) {}
2025-11-10 20:02:11 +01:00
};
}