Plutonium framework API 0.3.0
UI framework libraries for libnx
elm_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
16
17namespace pu::ui::elm {
18
19 class TextBlock : public Element {
20 public:
21 static constexpr Color DefaultColor = { 0, 0, 0, 0xFF };
22
23 private:
24 i32 x;
25 i32 y;
26 Color clr;
27 std::string text;
28 sdl2::Texture text_tex;
29 std::string fnt_name;
30
31 public:
32 TextBlock(const i32 x, const i32 y, const std::string &text);
35
36 inline i32 GetX() override {
37 return this->x;
38 }
39
40 inline void SetX(const i32 x) {
41 this->x = x;
42 }
43
44 inline i32 GetY() override {
45 return this->y;
46 }
47
48 inline void SetY(const i32 y) {
49 this->y = y;
50 }
51
52 i32 GetWidth() override;
53 i32 GetHeight() override;
54
55 inline std::string GetText() {
56 return this->text;
57 }
58
59 void SetText(const std::string &text);
60 void SetFont(const std::string &font_name);
61
62 inline Color GetColor() {
63 return this->clr;
64 }
65
66 void SetColor(const Color clr);
67 void OnRender(render::Renderer::Ref &drawer, const i32 x, const i32 y) override;
68 void OnInput(const u64 keys_down, const u64 keys_up, const u64 keys_held, const TouchPoint touch_pos) override {}
69 };
70
71}
Definition: elm_Element.hpp:37
Definition: elm_TextBlock.hpp:19
static constexpr Color DefaultColor
Definition: elm_TextBlock.hpp:21
void OnInput(const u64 keys_down, const u64 keys_up, const u64 keys_held, const TouchPoint touch_pos) override
Definition: elm_TextBlock.hpp:68
void SetX(const i32 x)
Definition: elm_TextBlock.hpp:40
Color GetColor()
Definition: elm_TextBlock.hpp:62
TextBlock(const i32 x, const i32 y, const std::string &text)
void OnRender(render::Renderer::Ref &drawer, const i32 x, const i32 y) override
std::string GetText()
Definition: elm_TextBlock.hpp:55
i32 GetHeight() override
void SetText(const std::string &text)
void SetColor(const Color clr)
i32 GetY() override
Definition: elm_TextBlock.hpp:44
void SetFont(const std::string &font_name)
i32 GetWidth() override
void SetY(const i32 y)
Definition: elm_TextBlock.hpp:48
i32 GetX() override
Definition: elm_TextBlock.hpp:36
SDL_Texture * Texture
Definition: sdl2_Types.hpp:11
Definition: elm_Button.hpp:18
s32 i32
Definition: pu_Include.hpp:28
#define PU_SMART_CTOR(type)
Definition: pu_Include.hpp:19
Definition: ui_Types.hpp:44
Definition: ui_Types.hpp:62