diff --git a/sdlpp/sdlpp_rectrenderer.cpp b/sdlpp/sdlpp_rectrenderer.cpp index 35fffc5..f3592e0 100644 --- a/sdlpp/sdlpp_rectrenderer.cpp +++ b/sdlpp/sdlpp_rectrenderer.cpp @@ -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 diff --git a/sdlpp/sdlpp_rectrenderer.hpp b/sdlpp/sdlpp_rectrenderer.hpp index 623bd5a..0a882a5 100644 --- a/sdlpp/sdlpp_rectrenderer.hpp +++ b/sdlpp/sdlpp_rectrenderer.hpp @@ -76,12 +76,16 @@ public: virtual SDL_Rect getRect() override; virtual std::shared_ptr< RenderObject > copySelf() override; std::string getColor() const; + void setMinWidth( uint64_t width ); + void setMinHeight( uint64_t height ); + void setSize( Vec2D< double > size ); protected: virtual void copyTo( std::shared_ptr< RenderObject > other ) override; Vec2D< double > original_size; Vec2D< double > size; std::string color = ""; + Vec2D< uint64_t > min_size = {0, 0}; }; } // end of namespace SDLPP #endif diff --git a/sdlpp/sdlpp_renderobject.hpp b/sdlpp/sdlpp_renderobject.hpp index b168aa7..a2208fe 100644 --- a/sdlpp/sdlpp_renderobject.hpp +++ b/sdlpp/sdlpp_renderobject.hpp @@ -110,7 +110,7 @@ public: void resumeAnimation(); void removeAnimation(); void animate( int ticks ); - void visit( Visitor &visitor ); + virtual void visit( Visitor &visitor ); void setAlignment( ObjectAlignment horizontal, ObjectAlignment vertical ); void flipHorizontally(); void flipVertically();