SDLPP: can set minimal width/height on rectangle renderer

This commit is contained in:
2021-05-02 14:03:26 +02:00
parent 61e45e89a5
commit e84284e613
3 changed files with 19 additions and 1 deletions
+14
View File
@@ -146,6 +146,10 @@ void RectangleRender::updateSizeAndPosition() {
rect.h =
std::round( ( current.getY() + original_size.getY() ) * dimension ) -
rect.y;
if(rect.w < min_size.getX())
rect.w = min_size.getX();
if(rect.h < min_size.getY())
rect.h = min_size.getY();
if ( polygon )
polygon->updateCollision( collisionPushX(), collisionPushY(),
collisionWidth(), collisionHeight(),
@@ -169,4 +173,14 @@ void RectangleRender::copyTo( std::shared_ptr< RenderObject > other ) {
std::string RectangleRender::getColor() const {
return color;
}
void RectangleRender::setMinWidth( uint64_t width ) {
min_size = {width, min_size.getY()};
}
void RectangleRender::setMinHeight( uint64_t height ) {
min_size = {min_size.getX(), height};
}
void RectangleRender::setSize( Vec2D< double > size ) {
original_size = size;
updateSizeAndPosition();
}
} // namespace SDLPP