Aether
SDL2 based UI Framework for NX
Text.hpp
1 #ifndef AETHER_TEXT_HPP
2 #define AETHER_TEXT_HPP
3 
4 #include "Aether/base/BaseText.hpp"
5 
6 // Forward declare the timer class
7 namespace Aether {
8  class Timer;
9 };
10 
11 namespace Aether {
15  class Text : public BaseText {
16  private:
20  struct ScrollVars {
21  bool allowed;
22  float position;
23  int speed;
24  Timer * timer;
25  int waitInterval;
26  } scroll;
27 
31  Drawable * renderDrawable();
32 
33  public:
43  Text(const int x, const int y, const std::string & str, const unsigned int size, const Render type = Render::Sync);
44 
54  static std::pair<int, int> getDimensions(const std::string & str, const unsigned int size);
55 
61  bool canScroll();
62 
68  void setCanScroll(const bool scroll);
69 
75  void setScrollPause(const unsigned int ms);
76 
82  void setScrollSpeed(const int pps);
83 
89  void setString(const std::string & str);
90 
96  void setFontSize(const unsigned int size);
97 
104  void update(unsigned int dt);
105 
112  void setW(const int w);
113 
117  ~Text();
118  };
119 };
120 
121 #endif
void update(unsigned int dt)
Called internally. Overrides Element&#39;s update in order to scroll the text if needed.
void setString(const std::string &str)
Set a new string. Will cause an immediate redraw.
Element for rendering a single line of text. It can optionally scroll when overflowing.
Definition: Text.hpp:15
Small utility class to measure time.
Definition: Timer.hpp:10
void setW(const int w)
Adjust the overall element&#39;s width. This will cause the text to clip if it doesn&#39;t fit and scrolling ...
void setScrollSpeed(const int pps)
Set the scroll speed of the text.
int w()
Returns width of element.
Stores either a surface or texture which can be drawn on screen by providing a renderer to render()...
Definition: Drawable.hpp:22
int x()
Returns x-coordinate of element.
BaseText is an abstract class storing relevant information to render a text element.
Definition: BaseText.hpp:12
Base namespace for all Aether related classes and functions.
Text(const int x, const int y, const std::string &str, const unsigned int size, const Render type=Render::Sync)
Constructs a new Text element.
bool canScroll()
Returns whether the text is allowed to scroll when needed.
static std::pair< int, int > getDimensions(const std::string &str, const unsigned int size)
Returns the dimensions of the given string if it were to be rendered, without performing any slow ren...
void setFontSize(const unsigned int size)
Set the render font size for text.
void setScrollPause(const unsigned int ms)
Set how long the text should &#39;pause&#39; for when it finishes scrolling.
void setCanScroll(const bool scroll)
Set whether the text will scroll when overflowing.
~Text()
Destroys the Text element.
Render
Supported "on create" texture rendering options.
Definition: Texture.hpp:11
int y()
Returns y-coordinate of element.