SDLPP: Use FontConfiguration to store font configuration
With this it is possible to only store 1 configuration object as opposed to storing font configuration inside every TextRenderer
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "sdlpp_common.hpp"
|
||||
#include "sdlpp_rectrenderer.hpp"
|
||||
#include "sdlpp_fontconfiguration.hpp"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
@@ -18,14 +19,21 @@ public:
|
||||
const std::string &text, const std::string &color = "FFFFFF",
|
||||
const std::string &outline_color = "000000",
|
||||
double outline_size = -1, int flags = SDLPP_TEXT_CENTER );
|
||||
TextRenderer( double x, double y, double w, double h,
|
||||
std::shared_ptr< Renderer > &r, const std::string &text,
|
||||
std::shared_ptr< FontConfiguration > config,
|
||||
int flags = SDLPP_TEXT_CENTER );
|
||||
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 setText( const std::string &text,
|
||||
std::shared_ptr< FontConfiguration > config );
|
||||
void setTextColor( std::shared_ptr< Font > font,
|
||||
const std::string &color = "FFFFFF",
|
||||
const std::string &outline_color = "000000",
|
||||
double outline_size = -1 );
|
||||
void setTextColor( std::shared_ptr< FontConfiguration > config );
|
||||
void changeText( const std::string &text );
|
||||
void setFlags( int flags );
|
||||
virtual void render() override;
|
||||
@@ -38,14 +46,11 @@ private:
|
||||
void saveFontConfig( std::shared_ptr< Font > font, const std::string &color,
|
||||
const std::string &outline_color,
|
||||
double outline_size );
|
||||
|
||||
void saveFontConfig( std::shared_ptr< FontConfiguration > config );
|
||||
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;
|
||||
std::shared_ptr< FontConfiguration > _config;
|
||||
};
|
||||
} // end of namespace SDLPP
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user