Plutonium framework API 0.3.0
UI framework libraries for libnx
Loading...
Searching...
No Matches
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
15#include <pu/ui/elm/elm_Element.hpp>
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 PU_CLASS_POD_GET(Color, clr, Color)
63
64 void SetColor(const Color clr);
65 void OnRender(render::Renderer::Ref &drawer, const i32 x, const i32 y) override;
66 void OnInput(const u64 keys_down, const u64 keys_up, const u64 keys_held, const TouchPoint touch_pos) override {}
67 };
68
69}
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:66
void SetX(const i32 x)
Definition elm_TextBlock.hpp:40
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
Definition render_Renderer.hpp:127
Definition sdl2_Types.hpp:10
Definition render_Renderer.hpp:20
Definition elm_Button.hpp:18
#define PU_SMART_CTOR(type)
Definition pu_Include.hpp:20
#define PU_CLASS_POD_GET(fn_name, var_name, type)
Definition pu_Include.hpp:27
Definition ui_Types.hpp:44
Definition ui_Types.hpp:67