feat: event emitter
This commit is contained in:
@ -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);
|
||||
|
||||
Reference in New Issue
Block a user