feat: event emitter

This commit is contained in:
2025-10-22 11:31:42 +02:00
parent 31fbecbb47
commit 71f1b2c6d2
9 changed files with 147 additions and 123 deletions

View File

@ -101,10 +101,12 @@ void Window::ProcessEvents() {
case SDL_EVENT_WINDOW_CLOSE_REQUESTED:
case SDL_EVENT_QUIT:
Dispatch(WindowCloseEvent());
EmitEvent(WindowCloseEvent{});
break;
case SDL_EVENT_KEY_DOWN:
if (event.key.scancode == SDL_SCANCODE_ESCAPE) {
Dispatch(WindowCloseEvent());
EmitEvent(WindowCloseEvent{});
}
if (event.key.scancode == SDL_SCANCODE_F11) {
bool isFullscreen = SDL_GetWindowFlags(m_handle) & SDL_WINDOW_FULLSCREEN;
@ -122,7 +124,9 @@ void Window::ProcessEvents() {
0,
width,
height);
Dispatch(WindowResizeEvent(static_cast<unsigned int>(m_width), static_cast<unsigned int>(m_height)));
auto event = WindowResizeEvent(static_cast<unsigned int>(m_width), static_cast<unsigned int>(m_height));
Dispatch(event);
EmitEvent(event);
SDL_SetWindowRelativeMouseMode(m_handle, true);
SDL_Rect boundaries = {0, 0, m_width, m_height};
SDL_SetWindowMouseRect(m_handle, &boundaries);