diff options
author | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2024-12-09 13:49:22 +0100 |
---|---|---|
committer | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2024-12-09 13:49:22 +0100 |
commit | ae141f77fc54638bed0cea9213fe8900769e5d92 (patch) | |
tree | f3a2fe7543e725a33bfa67c8edd0aebd47b7f7c8 /src/crepe | |
parent | 87c41870e7e66308ee0c74270e1f91f4943bd733 (diff) |
seperated long function
Diffstat (limited to 'src/crepe')
-rw-r--r-- | src/crepe/facade/SDLContext.cpp | 65 | ||||
-rw-r--r-- | src/crepe/facade/SDLContext.h | 16 |
2 files changed, 39 insertions, 42 deletions
diff --git a/src/crepe/facade/SDLContext.cpp b/src/crepe/facade/SDLContext.cpp index fdc83b2..f336fd3 100644 --- a/src/crepe/facade/SDLContext.cpp +++ b/src/crepe/facade/SDLContext.cpp @@ -427,36 +427,7 @@ std::vector<SDLContext::EventData> SDLContext::get_events() { // Forward window events for further processing case SDL_WINDOWEVENT: - switch (event.window.event) { - case SDL_WINDOWEVENT_EXPOSED: - event_list.push_back({SDLContext::EventType::WINDOW_EXPOSE, {}, {}, {}}); - break; - case SDL_WINDOWEVENT_RESIZED: - { - std::cout << "window resize" << std::endl; - SDLContext::EventData event_data; - event_data.event_type = SDLContext::EventType::WINDOW_RESIZE; - event_data.window_data.resize_dimension = {event.window.data1,event.window.data2}; - event_list.push_back(event_data); - break; - } - case SDL_WINDOWEVENT_MOVED: - event_list.push_back({SDLContext::EventType::WINDOW_MOVE, {}, {}, - {{event.window.data1, event.window.data2}, {}}}); - break; - case SDL_WINDOWEVENT_MINIMIZED: - event_list.push_back({SDLContext::EventType::WINDOW_MINIMIZE, {}, {}, {}}); - break; - case SDL_WINDOWEVENT_MAXIMIZED: - event_list.push_back({SDLContext::EventType::WINDOW_MAXIMIZE, {}, {}, {}}); - break; - case SDL_WINDOWEVENT_FOCUS_GAINED: - event_list.push_back({SDLContext::EventType::WINDOW_FOCUS_GAIN, {}, {}, {}}); - break; - case SDL_WINDOWEVENT_FOCUS_LOST: - event_list.push_back({SDLContext::EventType::WINDOW_FOCUS_LOST, {}, {}, {}}); - break; - } + this->handle_window_event(event.window, event_list); break; } } @@ -464,10 +435,36 @@ std::vector<SDLContext::EventData> SDLContext::get_events() { return event_list; } -// // Separate function for SDL_WINDOWEVENT subtypes -// void SDLContext::handle_event(const SDL_WindowEvent& event, -// std::vector<SDLContext::EventData>& event_list) { -// } +// Separate function for SDL_WINDOWEVENT subtypes +void SDLContext::handle_window_event(const SDL_WindowEvent& window_event, + std::vector<SDLContext::EventData>& event_list) { + switch (window_event.event) { + case SDL_WINDOWEVENT_EXPOSED: + event_list.push_back({SDLContext::EventType::WINDOW_EXPOSE, {}, {}, {}}); + break; + case SDL_WINDOWEVENT_RESIZED: + std::cout << "window resize" << std::endl; + event_list.push_back({SDLContext::EventType::WINDOW_RESIZE, {}, {}, + {{}, {window_event.data1, window_event.data2}}}); + break; + case SDL_WINDOWEVENT_MOVED: + event_list.push_back({SDLContext::EventType::WINDOW_MOVE, {}, {}, + {{window_event.data1, window_event.data2}, {}}}); + break; + case SDL_WINDOWEVENT_MINIMIZED: + event_list.push_back({SDLContext::EventType::WINDOW_MINIMIZE, {}, {}, {}}); + break; + case SDL_WINDOWEVENT_MAXIMIZED: + event_list.push_back({SDLContext::EventType::WINDOW_MAXIMIZE, {}, {}, {}}); + break; + case SDL_WINDOWEVENT_FOCUS_GAINED: + event_list.push_back({SDLContext::EventType::WINDOW_FOCUS_GAIN, {}, {}, {}}); + break; + case SDL_WINDOWEVENT_FOCUS_LOST: + event_list.push_back({SDLContext::EventType::WINDOW_FOCUS_LOST, {}, {}, {}}); + break; + } +} diff --git a/src/crepe/facade/SDLContext.h b/src/crepe/facade/SDLContext.h index 98be988..21d17c7 100644 --- a/src/crepe/facade/SDLContext.h +++ b/src/crepe/facade/SDLContext.h @@ -135,14 +135,14 @@ private: * \return Events that occurred since last call to `get_events()` */ std::vector<SDLContext::EventData> get_events(); - // /** - // * \brief Fills event_list with triggered window events - // * - // * This method checks if any window events are triggered and adds them to the event_list. - // * - // */ - // void handle_window_event(const SDL_WindowEvent& window_event, - // std::vector<SDLContext::EventData>& event_list); + /** + * \brief Fills event_list with triggered window events + * + * This method checks if any window events are triggered and adds them to the event_list. + * + */ + void handle_window_event(const SDL_WindowEvent& window_event, + std::vector<SDLContext::EventData>& event_list); /** * \brief Converts an SDL key code to the custom Keycode type. * |