SDLPP: TextRenderer remembers last font/color/outline
This is used for changeText() and updateSizeAndPosition() so programmer doesn't have to pass the text configuration with every change of text/size.
This commit is contained in:
@@ -14,18 +14,18 @@ public:
|
||||
TextRenderer( double x, double y, double w, double h,
|
||||
std::shared_ptr< Renderer > &r );
|
||||
TextRenderer( double x, double y, double w, double h,
|
||||
std::shared_ptr< Renderer > &r, Font &font,
|
||||
std::shared_ptr< Renderer > &r, std::shared_ptr< Font > font,
|
||||
const std::string &text, const std::string &color = "FFFFFF",
|
||||
const std::string &outline_color = "000000",
|
||||
double outline_size = -1, int flags = SDLPP_TEXT_CENTER );
|
||||
void setText( Font &font, const std::string &text,
|
||||
void setText( std::shared_ptr< Font > font, const std::string &text,
|
||||
const std::string &color = "FFFFFF",
|
||||
const std::string &outline_color = "000000",
|
||||
double outline_size = -1 );
|
||||
void setTextColor( Font &font, const std::string &color = "FFFFFF",
|
||||
void setTextColor( std::shared_ptr< Font > font,
|
||||
const std::string &color = "FFFFFF",
|
||||
const std::string &outline_color = "000000",
|
||||
double outline_size = -1 );
|
||||
// TODO maybe store Font and actually update texture here
|
||||
void changeText( const std::string &text );
|
||||
void setFlags( int flags );
|
||||
virtual void render() override;
|
||||
@@ -33,11 +33,19 @@ public:
|
||||
virtual std::shared_ptr< RenderObject > copySelf() override;
|
||||
|
||||
private:
|
||||
virtual void copyTo(std::shared_ptr<RenderObject> other) override;
|
||||
virtual void copyTo( std::shared_ptr< RenderObject > other ) override;
|
||||
void updateDstRect();
|
||||
void saveFontConfig( std::shared_ptr< Font > font, const std::string &color,
|
||||
const std::string &outline_color,
|
||||
double outline_size );
|
||||
|
||||
std::string _text{};
|
||||
int position_flags = 0;
|
||||
SDL_Rect dst_rect{};
|
||||
std::shared_ptr< Font > last_font;
|
||||
std::string last_color;
|
||||
std::string last_outline_color;
|
||||
double last_outline_size;
|
||||
};
|
||||
} // end of namespace SDLPP
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user