diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-06-15 15:28:53 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-06-15 15:28:53 +0100 |
commit | 02c3f1fd622bb5b4da1462c5bb507a4a541447d5 (patch) | |
tree | 8db9ad8cc755cdab17d11a97309b3b147c576964 /ui/windowContent.cpp | |
parent | Add imgui init and shutdown to appbase and gamemainwindow (diff) | |
download | ilt-02c3f1fd622bb5b4da1462c5bb507a4a541447d5.tar.bz2 ilt-02c3f1fd622bb5b4da1462c5bb507a4a541447d5.tar.xz ilt-02c3f1fd622bb5b4da1462c5bb507a4a541447d5.zip |
First cut reshuffling app/window/gl/render bits
Diffstat (limited to 'ui/windowContent.cpp')
-rw-r--r-- | ui/windowContent.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/ui/windowContent.cpp b/ui/windowContent.cpp new file mode 100644 index 0000000..91732a7 --- /dev/null +++ b/ui/windowContent.cpp @@ -0,0 +1,32 @@ +#include "windowContent.h" +#include "SDL_events.h" + +WindowContent::WindowContent(size_t width, size_t height) : uiShader {width, height} { } + +void +WindowContent::tick(TickDuration) +{ +} + +bool +WindowContent::handleInput(const SDL_Event & e) +{ + SDL_Event eAdjusted {e}; + const auto size = [&e] { + glm::ivec2 size {}; + SDL_GetWindowSizeInPixels(SDL_GetWindowFromID(e.window.windowID), &size.x, &size.y); + return size; + }(); + switch (e.type) { + // SDL and OpenGL have coordinates that are vertically opposed. + case SDL_MOUSEBUTTONDOWN: + case SDL_MOUSEBUTTONUP: + eAdjusted.button.y = size.y - e.button.y; + break; + case SDL_MOUSEMOTION: + eAdjusted.motion.y = size.y - e.motion.y; + break; + } + uiComponents.rapplyOne(&UIComponent::handleInput, eAdjusted, UIComponent::Position {{}, size}); + return true; +} |