44 bool isReady()
const override {
return _font && _font->isReady(); }
46 void setText(
const std::string text)
override { _text = text; _dirty =
true; }
47 std::string
getText()
const override {
return _text; }
50 _font =
static_cast<SdlFont *
>(font);
54 void setFontSize(
unsigned int size)
override { _size = size; _dirty =
true; }
71 SDL_Texture *handle(SDL_Renderer *renderer)
const {
72 if (!renderer || !_font || !_font->isReady())
74 if (_texture && !_dirty && _owner == renderer)
79 const SDL_Color color{_color.r, _color.g, _color.b, _color.a};
83 SDL_Surface *surface = TTF_RenderUTF8_Blended_Wrapped(_font->
handle(_size), _text.c_str(), color, 0);
87 _texture = SDL_CreateTextureFromSurface(renderer, surface);
90 SDL_FreeSurface(surface);
99 SDL_DestroyTexture(_texture);
105 SdlFont *_font =
nullptr;
107 Color _color{255, 255, 255, 255};
109 float _rotation = 0.f;
114 mutable SDL_Texture *_texture =
nullptr;
115 mutable SDL_Renderer *_owner =
nullptr;
116 mutable bool _dirty =
true;
117 mutable int _width = 0;
118 mutable int _height = 0;
Une police ouverte a une taille donnee.
Definition SdlFont.hpp:32
TTF_Font * handle(unsigned size) const
La police, recalee sur size si besoin.
Definition SdlFont.hpp:51
void setRotation(float angle) override
Set the Rotation object.
Definition SdlText.hpp:64
void setText(const std::string text) override
Set the Text value.
Definition SdlText.hpp:46
float getRotation() const override
Get the Rotation object.
Definition SdlText.hpp:65
Vector2f getPosition() const override
Get the Position text.
Definition SdlText.hpp:61
friend class SdlWindow
Definition SdlText.hpp:67
void setFont(graphic::IFont *font) override
Set the Font value - a loaded IFont, not a path, so changing font never implies a reload from disk.
Definition SdlText.hpp:49
Color getTextColor() const override
Get the Text Color text.
Definition SdlText.hpp:58
SdlText(std::string data, SdlFont &font)
Definition SdlText.hpp:40
void setTextColor(Color color) override
Set the Text Color text.
Definition SdlText.hpp:57
~SdlText() override
Definition SdlText.hpp:42
void setPosition(Vector2f position) override
Set the Position text.
Definition SdlText.hpp:60
std::string getText() const override
Get the Text value.
Definition SdlText.hpp:47
bool isReady() const override
Definition SdlText.hpp:44
void setFontSize(unsigned int size) override
Set the Font Size text.
Definition SdlText.hpp:54
unsigned int getFontSize() const override
Get the Font Size text.
Definition SdlText.hpp:55
Loaded font data, independent of any IText that references it. Deleting every IText built with a font...
Definition IFont.hpp:22
Text interface.
Definition IText.hpp:26
Vector2< double > Vector2f
Definition Vector2.hpp:112