CYD-UI
A C++ library for building native graphic user interfaces
Loading...
Searching...
No Matches
cydui_events.cppm
Go to the documentation of this file.
1// Copyright (c) 2024, Víctor Castillo Agüero.
2// SPDX-License-Identifier: GPL-3.0-or-later
3
4module;
5#include <cyd_fabric_modules/headers/macros/async_events.h>
6#include <SDL3/SDL_events.h>
7
8export module cydui.events;
9
10export import std;
11export import fabric.async;
12export import cydui.dimensions;
13
15
16export {
17 EVENT(RedrawEvent) {
18 unsigned long win = 0;
19 int x = 0;
20 int y = 0;
21 void* component = nullptr;
22 };
23
24 EVENT(ButtonEvent) {
25 const unsigned long win = 0;
26 const unsigned int button = 0;
27 const screen_measure x = 0;
28 const screen_measure y = 0;
29 const bool pressed = false;
30 const bool released = false;
31 const bool holding = false;
32 };
33
34 EVENT(ScrollEvent) {
35 unsigned long win = 0;
36 const screen_measure dy = 0;
37 const screen_measure dx = 0;
38 const screen_measure x = 0;
39 const screen_measure y = 0;
40 };
41
42 EVENT(MotionEvent) {
43 unsigned long win = 0;
44 const screen_measure x = 0;
45 const screen_measure y = 0;
46 bool enter = false;
47 bool exit = false;
48
49 bool dragging = false;
50 };
51
52 EVENT(ResizeEvent) {
53 unsigned long win = 0;
54 const screen_measure w = 0;
55 const screen_measure h = 0;
56 };
57
58 namespace cydui {
67 }
68
69 using Scancode = SDL_Scancode;
70 using Keycode = SDL_Keycode;
71 using Keymod = Uint16;
72
73 struct Keysym {
75 SDL_Keycode code;
77 };
78
79 EVENT(KeyEvent) {
80 const Keysym keysym;
81 const bool pressed = false;
82 const bool released = false;
83 const bool holding = false;
84 };
85
86 EVENT(TextInputEvent) {
87 std::string text = "";
88 bool compositing_event = false;
89 struct {
90 int cursor{0};
91 int selection{0};
92 } compositing_state { };
93 };
94
95 EVENT(WindowClosed) {};
96}
SDL_Keycode Keycode
EVENT(RedrawEvent)
SDL_Scancode Scancode
Uint16 Keymod
quantify::quantity_t< screen::pixel, double > screen_measure
Definition _types.cppm:21
Scancode scancode
SDL_Keycode code
Keymod mod