TurtleBrains  0.3.5
High quality, portable, C++ framework for rapid 2D game development.
tbx_shadowed_text.hpp
1 
9 #ifndef TurtleBrainsExpress_ShadowedText_hpp
10 #define TurtleBrainsExpress_ShadowedText_hpp
11 
12 #include <turtle_brains/graphics/tb_graphic.hpp>
13 #include <turtle_brains/graphics/tb_text.hpp>
14 
15 namespace TurtleBrainsExpress
16 {
17  namespace Graphics
18  {
19 
24  class ShadowedText : public tbGraphics::Graphic //is a Noncopyable as of 2022-04-07
25  {
26  public:
27  explicit ShadowedText(const tbCore::tbString& text = tb_string(""), const float pointSize = tbGraphics::Text::kDefaultFontSize,
28  const tbCore::tbString& fontFilepath = tbGraphics::Text::kDefaultFontFile, const tbGraphics::Color& shadowColor = tbGraphics::Color(0xFF202020));
29 
30  virtual ~ShadowedText(void);
31 
32  tbCore::tbString GetText(void) const;
33  void SetText(const tbCore::tbString& text, const float pointSize, const tbCore::tbString& fontFilepath);
34  void SetText(const tbCore::tbString& text);
35 
36  virtual void SetColor(const tbGraphics::Color& newColor) override;
37  void SetColor(const tbGraphics::Color& topColor, const tbGraphics::Color& bottomColor);
38 
39  tbGraphics::Color GetShadowColor(void) const;
40  void SetShadowColor(const tbGraphics::Color& shadowColor);
41 
42  tbGraphics::PixelSpace GetShadowOffset(void);
43  void SetShadowOffset(const tbGraphics::PixelSpace& shadowOffset);
44 
45  virtual tbGraphics::PixelSpace GetPixelWidth(void) const override { return mText.GetPixelWidth(); }
46  virtual tbGraphics::PixelSpace GetPixelHeight(void) const override { return mText.GetPixelHeight(); }
47 
48  protected:
49  virtual void OnRender(void) const override;
50 
51  private:
52  mutable tbGraphics::Text mText;
53  tbGraphics::PixelSpace mShadowOffset;
54  tbGraphics::Color mShadowColor;
55  tbGraphics::Color mBottomColor;
56  };
57 
58  }; /* namespace Graphics */
59 }; /* namespace TurtleBrainsExpress */
60 
62 
63 #endif /* TurtleBrainsExpress_ShadowedText_hpp */
Definition: tb_graphic.hpp:61
virtual PixelSpace GetPixelWidth(void) const override
Definition: tbx_nine_slice.hpp:19
virtual tbGraphics::PixelSpace GetPixelHeight(void) const override
Definition: tbx_shadowed_text.hpp:46
A collection of objects and functions to express games quickly.
virtual PixelSpace GetPixelHeight(void) const override
static const float kDefaultFontSize
Definition: tb_text.hpp:48
Definition: tb_color.hpp:24
Definition: tbx_shadowed_text.hpp:24
tbCore::uint16 PixelSpace
Definition: tb_texture_manager.hpp:36
virtual tbGraphics::PixelSpace GetPixelWidth(void) const override
Definition: tbx_shadowed_text.hpp:45
Definition: tb_text.hpp:42
static const tbCore::tbString kDefaultFontFile
Definition: tb_text.hpp:53
#define tb_string(object)
Definition: tb_string.hpp:28
virtual void SetColor(const tbGraphics::Color &newColor) override
std::string tbString
Definition: tb_string.hpp:335
virtual void OnRender(void) const override