Files
Aethera/mcp/core/runtime/Input_Event.hpp
T
2026-09-03 15:31:39 +08:00

45 lines
1.5 KiB
C++

#pragma once
#include <event/Event.hpp>
#include <nlohmann/json_fwd.hpp>
#include <cstdint>
#include <memory>
namespace aethera::web {
struct Input_Point {
double x{}; /* Plot 局部或全局像素横坐标。 */
double y{}; /* Plot 局部或全局像素纵坐标。 */
};
struct Input_Size {
std::uint32_t width{}; /* 输入事件携带的视口宽度,单位为像素。 */
std::uint32_t height{}; /* 输入事件携带的视口高度,单位为像素。 */
};
struct Input_Resize_Event final : Event {
explicit Input_Resize_Event(Event_Timeline_Time occurred_at);
Input_Size old_size{}; /* 调整前的视口尺寸;协议未提供时为零。 */
Input_Size new_size{}; /* 调整后的视口尺寸;协议未提供时为零。 */
};
struct Input_Pointer_Event final : Basic_Pointer_Event<Input_Point> {
Input_Pointer_Event(Event_Type type, Event_Timeline_Time occurred_at);
};
struct Input_Wheel_Event final : Basic_Wheel_Event<Input_Point> {
explicit Input_Wheel_Event(Event_Timeline_Time occurred_at);
};
struct Input_Key_Event final : Key_Event {
Input_Key_Event(Event_Type type, Event_Timeline_Time occurred_at);
};
struct Input_Viewport {
std::uint32_t width{}; /* 可选的局部横坐标裁剪宽度,零表示不裁剪。 */
std::uint32_t height{}; /* 可选的局部纵坐标裁剪高度,零表示不裁剪。 */
};
[[nodiscard]] std::unique_ptr<Event> make_input_event(const nlohmann::json& input, Input_Viewport viewport = {});
}