Plutonium framework API  0.1
Simple UI framework for libnx and SDL2
TextBlock.hpp
Go to the documentation of this file.
1 
2 /*
3 
4  Plutonium library
5 
6  @file TextBlock.hpp
7  @brief A TextBlock is a very useful Element which is used to draw text on the screen.
8  @author XorTroll
9 
10  @copyright Plutonium project - an easy-to-use UI framework for Nintendo Switch homebrew
11 
12 */
13 
14 #pragma once
15 #include <pu/element/Element.hpp>
16 
17 namespace pu::element
18 {
19  enum class TextAlign
20  {
23  CenterAll,
24  };
25 
26  class TextBlock : public Element
27  {
28  public:
29  TextBlock(u32 X, u32 Y, std::string Text, u32 FontSize = 25);
30  ~TextBlock();
31  u32 GetX();
32  void SetX(u32 X);
33  u32 GetY();
34  void SetY(u32 Y);
35  u32 GetWidth();
36  u32 GetHeight();
37  std::string GetText();
38  void SetText(std::string Text);
39  void SetTextAlign(TextAlign Align);
40  void RemoveTextAlign();
41  bool HasTextAlign();
44  void SetColor(draw::Color Color);
45  void OnRender(render::Renderer *Drawer);
46  void OnInput(u64 Down, u64 Up, u64 Held, bool Touch, bool Focus);
47  private:
48  bool halign;
49  TextAlign talign;
50  std::string text;
51  u32 x;
52  u32 y;
54  u32 fsize;
55  draw::Color clr;
57  };
58 }
Definition: Renderer.hpp:22
void OnInput(u64 Down, u64 Up, u64 Held, bool Touch, bool Focus)
draw::Color GetColor()
Font
Definition: Font.hpp:18
void OnRender(render::Renderer *Drawer)
TTF_Font * NativeFont
Definition: SDL2.hpp:17
Definition: Button.hpp:18
void SetTextAlign(TextAlign Align)
Definition: Element.hpp:27
void SetColor(draw::Color Color)
TextBlock(u32 X, u32 Y, std::string Text, u32 FontSize=25)
void SetFont(render::NativeFont Font)
std::string GetText()
void SetText(std::string Text)
SDL_Texture * NativeTexture
Definition: SDL2.hpp:16
Definition: TextBlock.hpp:26
Definition: Color.hpp:19
TextAlign
Definition: TextBlock.hpp:19