Add option to make window resizable, fix scaling

This commit is contained in:
zvon 2020-08-24 22:14:26 +02:00
parent f36890e124
commit 3cc5c4192a

View File

@ -49,6 +49,9 @@ public:
throw "Couldn't create window";
}
}
void setResizable(bool resizable) {
SDL_SetWindowResizable(window, resizable ? SDL_TRUE : SDL_FALSE);
}
~Window() {
SDL_DestroyWindow( window );
}
@ -959,10 +962,10 @@ public:
virtual void updateSizeAndPosition() override {
updateXY();
auto dimension = renderer->getSmallerSide();
rect.x = x_ * dimension;
rect.y = y_ * dimension;
rect.w = w_ * dimension;
rect.h = h_ * dimension;
rect.x = std::round(x_ * dimension);
rect.y = std::round(y_ * dimension);
rect.w = std::round((x_ + w_) * dimension) - rect.x;
rect.h = std::round((y_ + h_) * dimension) - rect.y;
if ( polygon )
polygon->updateCollision( collisionPushX(), collisionPushY(),
collisionWidth(), collisionHeight() );