mirror of
https://github.com/thunderbrewhq/thunderbrew
synced 2025-12-12 03:02:30 +00:00
feat(gx): handle SDL window resize event
This commit is contained in:
parent
dbac391d9e
commit
21dcc7d8ae
2 changed files with 21 additions and 0 deletions
|
|
@ -2,6 +2,7 @@
|
||||||
#include "event/Types.hpp"
|
#include "event/Types.hpp"
|
||||||
#include "event/Input.hpp"
|
#include "event/Input.hpp"
|
||||||
#include "event/Event.hpp"
|
#include "event/Event.hpp"
|
||||||
|
#include "gx/Window.hpp"
|
||||||
|
|
||||||
#include <bc/Debug.hpp>
|
#include <bc/Debug.hpp>
|
||||||
#include <storm/Unicode.hpp>
|
#include <storm/Unicode.hpp>
|
||||||
|
|
@ -287,6 +288,9 @@ void GLSDLWindow::DispatchSDLEvent(const SDL_Event& event) {
|
||||||
case SDL_EVENT_TEXT_INPUT:
|
case SDL_EVENT_TEXT_INPUT:
|
||||||
this->DispatchSDLTextInputEvent(event);
|
this->DispatchSDLTextInputEvent(event);
|
||||||
break;
|
break;
|
||||||
|
case SDL_EVENT_WINDOW_RESIZED:
|
||||||
|
this->DispatchSDLWindowResizedEvent(event);
|
||||||
|
break;
|
||||||
case SDL_EVENT_QUIT:
|
case SDL_EVENT_QUIT:
|
||||||
EventPostClose();
|
EventPostClose();
|
||||||
break;
|
break;
|
||||||
|
|
@ -363,3 +367,19 @@ void GLSDLWindow::DispatchSDLTextInputEvent(const SDL_Event& event) {
|
||||||
text += charactersize;
|
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 DispatchSDLMouseMotionEvent(const SDL_Event& event);
|
||||||
void DispatchSDLMouseButtonEvent(const SDL_Event& event);
|
void DispatchSDLMouseButtonEvent(const SDL_Event& event);
|
||||||
void DispatchSDLTextInputEvent(const SDL_Event& event);
|
void DispatchSDLTextInputEvent(const SDL_Event& event);
|
||||||
|
void DispatchSDLWindowResizedEvent(const SDL_Event& event);
|
||||||
void Resize(const GLSDLWindowRect& rect);
|
void Resize(const GLSDLWindowRect& rect);
|
||||||
|
|
||||||
GLSDLWindowRect GetRect();
|
GLSDLWindowRect GetRect();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue