SDLPP: can set minimal width/height on rectangle renderer
This commit is contained in:
parent
61e45e89a5
commit
e84284e613
@ -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
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user