# Plutonium framework API: Plutonium/include/pu/ui/elm/elm_TextBlock.hpp Source File

elm_TextBlock.hpp
Go to the documentation of this file.
/*
Plutonium library
@file TextBlock.hpp
@brief A TextBlock is a very useful Element which is used to draw text on the screen.
@author XorTroll
@copyright Plutonium project - an easy-to-use UI framework for Nintendo Switch homebrew
*/
#pragma once
#include <pu/ui/elm/elm_Element.hpp>
namespace pu::ui::elm {
class TextBlock : public Element {
public:
static constexpr Color DefaultColor = { 0, 0, 0, 0xFF };
private:
i32 x;
i32 y;
Color clr;
std::string text;
sdl2::Texture text_tex;
std::string fnt_name;
public:
TextBlock(const i32 x, const i32 y, const std::string &text);
PU_SMART_CTOR(TextBlock)
~TextBlock();
inline i32 GetX() override {
return this->x;
}
inline void SetX(const i32 x) {
this->x = x;
}
inline i32 GetY() override {
return this->y;
}
inline void SetY(const i32 y) {
this->y = y;
}
i32 GetWidth() override;
i32 GetHeight() override;
inline std::string GetText() {
return this->text;
}
void SetText(const std::string &text);
void SetFont(const std::string &font_name);
inline Color GetColor() {
return this->clr;
}
void SetColor(const Color clr);
void OnRender(render::Renderer::Ref &drawer, const i32 x, const i32 y) override;
void OnInput(const u64 keys_down, const u64 keys_up, const u64 keys_held, const TouchPoint touch_pos) override {}
};
}
pu::ui::elm::Element
Definition: elm_Element.hpp:37
pu::ui::elm::TextBlock
Definition: elm_TextBlock.hpp:19
pu::ui::elm::TextBlock::DefaultColor
static constexpr Color DefaultColor
Definition: elm_TextBlock.hpp:21
pu::ui::elm::TextBlock::OnInput
void OnInput(const u64 keys_down, const u64 keys_up, const u64 keys_held, const TouchPoint touch_pos) override
Definition: elm_TextBlock.hpp:68
pu::ui::elm::TextBlock::SetX
void SetX(const i32 x)
Definition: elm_TextBlock.hpp:40
pu::ui::elm::TextBlock::GetColor
Color GetColor()
Definition: elm_TextBlock.hpp:62
pu::ui::elm::TextBlock::~TextBlock
~TextBlock()
pu::ui::elm::TextBlock::TextBlock
TextBlock(const i32 x, const i32 y, const std::string &text)
pu::ui::elm::TextBlock::OnRender
void OnRender(render::Renderer::Ref &drawer, const i32 x, const i32 y) override
pu::ui::elm::TextBlock::GetText
std::string GetText()
Definition: elm_TextBlock.hpp:55
pu::ui::elm::TextBlock::GetHeight
i32 GetHeight() override
pu::ui::elm::TextBlock::SetText
void SetText(const std::string &text)
pu::ui::elm::TextBlock::SetColor
void SetColor(const Color clr)
pu::ui::elm::TextBlock::GetY
i32 GetY() override
Definition: elm_TextBlock.hpp:44
pu::ui::elm::TextBlock::SetFont
void SetFont(const std::string &font_name)
pu::ui::elm::TextBlock::GetWidth
i32 GetWidth() override
pu::ui::elm::TextBlock::SetY
void SetY(const i32 y)
Definition: elm_TextBlock.hpp:48
pu::ui::elm::TextBlock::GetX
i32 GetX() override
Definition: elm_TextBlock.hpp:36
elm_Element.hpp
pu::sdl2::Texture
SDL_Texture * Texture
Definition: sdl2_Types.hpp:11
pu::ui::elm
Definition: elm_Button.hpp:18
pu::i32
s32 i32
Definition: pu_Include.hpp:28
PU_SMART_CTOR
#define PU_SMART_CTOR(type)
Definition: pu_Include.hpp:19
pu::ui::Color
Definition: ui_Types.hpp:44
pu::ui::TouchPoint
Definition: ui_Types.hpp:62