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 TurtleBrains::Express::Graphics
16 {
17 
26  class ShadowedText : public tbGraphics::Graphic //is a Noncopyable as of 2022-04-07 (no it isn't!!! 2025-03-19)
27  {
28  public:
29  explicit ShadowedText(const tbCore::String& text = tb_string(""), const tbGraphics::FontSize pointSize =
31  const tbGraphics::Color& shadowColor = tbGraphics::Color(0xFF202020));
32 
33  virtual ~ShadowedText(void);
34 
35  tbCore::String GetText(void) const;
36  void SetText(const tbCore::String& text, const tbGraphics::FontSize pointSize, const tbCore::String& fontFilepath);
37  void SetText(const tbCore::String& text);
38 
39  virtual void SetColor(const tbGraphics::Color& newColor) override;
40  void SetColor(const tbGraphics::Color& topColor, const tbGraphics::Color& bottomColor);
41 
42  tbGraphics::Color GetShadowColor(void) const;
43  void SetShadowColor(const tbGraphics::Color& shadowColor);
44 
45 #if defined(TURTLEBRAINS_SDF_FONTS)
46  tbMath::Vector2 GetShadowOffset(void) const;
47  void SetShadowOffset(const tbMath::Vector2& shadowOffset);
48  void SetShadowOffset(const float offsetX, const float offsetY);
49 #else
50  tbGraphics::PixelSpace GetShadowOffset(void) const;
51  void SetShadowOffset(const tbGraphics::PixelSpace& shadowOffset);
52 
53 #endif
54 
55  virtual tbGraphics::PixelSpace GetPixelWidth(void) const override { return mText.GetPixelWidth(); }
56  virtual tbGraphics::PixelSpace GetPixelHeight(void) const override { return mText.GetPixelHeight(); }
57 
58  protected:
59  virtual void OnRender(void) const override;
60 
61  private:
62 #if defined(TURTLEBRAINS_SDF_FONTS)
63  mutable tbGraphics::Text mText;
64  tbGraphics::Color mBottomColor;
65 #else
66  mutable tbGraphics::Text mText;
67  tbGraphics::PixelSpace mShadowOffset;
68  tbGraphics::Color mShadowColor;
69  tbGraphics::Color mBottomColor;
70 #endif
71  };
72 
73 }; /* namespace TurtleBrains::Express::Graphics */
74 
75 namespace tbxGraphics = TurtleBrains::Express::Graphics;
76 
77 #endif /* TurtleBrainsExpress_ShadowedText_hpp */
Definition: tbx_shadowed_text.hpp:27
virtual void SetColor(const tbGraphics::Color &newColor) override
virtual tbGraphics::PixelSpace GetPixelWidth(void) const override
Definition: tbx_shadowed_text.hpp:55
virtual void OnRender(void) const override
virtual tbGraphics::PixelSpace GetPixelHeight(void) const override
Definition: tbx_shadowed_text.hpp:56
Definition: tb_color.hpp:24
Definition: tb_graphic.hpp:50
Definition: tb_text.hpp:57
static const String & DefaultFontFile(void)
virtual PixelSpace GetPixelHeight(void) const override
static FontSize DefaultFontSize(void)
virtual PixelSpace GetPixelWidth(void) const override
Definition: tb_vector.hpp:99
#define tb_string(object)
Definition: tb_string.hpp:30
std::string String
Definition: tb_string.hpp:302
tbCore::uint16 PixelSpace
Definition: tb_texture_manager.hpp:34