mirror of
https://github.com/thunderbrewhq/thunderbrew
synced 2025-10-26 22:06:06 +03:00
feat(gx): handle SDL window resize event
This commit is contained in:
parent
dbac391d9e
commit
21dcc7d8ae
@ -2,6 +2,7 @@
|
||||
#include "event/Types.hpp"
|
||||
#include "event/Input.hpp"
|
||||
#include "event/Event.hpp"
|
||||
#include "gx/Window.hpp"
|
||||
|
||||
#include <bc/Debug.hpp>
|
||||
#include <storm/Unicode.hpp>
|
||||
@ -287,6 +288,9 @@ void GLSDLWindow::DispatchSDLEvent(const SDL_Event& event) {
|
||||
case SDL_EVENT_TEXT_INPUT:
|
||||
this->DispatchSDLTextInputEvent(event);
|
||||
break;
|
||||
case SDL_EVENT_WINDOW_RESIZED:
|
||||
this->DispatchSDLWindowResizedEvent(event);
|
||||
break;
|
||||
case SDL_EVENT_QUIT:
|
||||
EventPostClose();
|
||||
break;
|
||||
@ -363,3 +367,19 @@ void GLSDLWindow::DispatchSDLTextInputEvent(const SDL_Event& event) {
|
||||
text += charactersize;
|
||||
}
|
||||
}
|
||||
|
||||
void GLSDLWindow::DispatchSDLWindowResizedEvent(const SDL_Event& event) {
|
||||
auto width = static_cast<int32_t>(event.window.data1);
|
||||
auto height = static_cast<int32_t>(event.window.data2);
|
||||
|
||||
OsQueuePut(OS_INPUT_SIZE, width, height, 0, 0);
|
||||
|
||||
auto bounds = GetSavedWindowBounds();
|
||||
Rect newBounds = {
|
||||
bounds->top,
|
||||
bounds->left,
|
||||
static_cast<int16_t>(bounds->top + height),
|
||||
static_cast<int16_t>(bounds->left + width)
|
||||
};
|
||||
SetSavedWindowBounds(newBounds);
|
||||
}
|
||||
|
||||
@ -35,6 +35,7 @@ class GLSDLWindow {
|
||||
void DispatchSDLMouseMotionEvent(const SDL_Event& event);
|
||||
void DispatchSDLMouseButtonEvent(const SDL_Event& event);
|
||||
void DispatchSDLTextInputEvent(const SDL_Event& event);
|
||||
void DispatchSDLWindowResizedEvent(const SDL_Event& event);
|
||||
void Resize(const GLSDLWindowRect& rect);
|
||||
|
||||
GLSDLWindowRect GetRect();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user