GigaPasjans
Loading...
Searching...
No Matches
TextComponent.h
1// Plik utworzony przez Piotra ChudziƄskiego w dniu 11.04.2025
2#pragma once
3
4#include "andromenda/Component.h"
5
6namespace Andromenda
7{
12 class TextComponent : public Component
13 {
14 protected:
16 Int2 getSize() override
17 {
18 return Int2{Text.GetLength(), 2};
19 }
20
21 public:
27
28 explicit TextComponent(const WideString &text)
29 : Text(text)
30 {
31 }
32
34 bool IsSelectable() const override
35 {
36 return false;
37 }
38
40 void ProvideActions(ActionRegistry &registry) override
41 {
42
43 }
44
46 void Draw(DrawContext &context) override
47 {
48 context.StyleStack.Push(TerminalStyle{Color::White, m_IsActive ? Color::Green : Color::Black});
49 context.Put(Text, GetBounds().GetPosition());
50 context.StyleStack.Pop();
51 }
52 };
53}
Represent registry of Action objects.
Definition ActionRegistry.h:74
Represents a renderable identified object.
Definition Component.h:23
bool m_IsActive
A value indicating, whether object is being pointed by pointer.
Definition Component.h:32
Box GetBounds()
Returns Component bounds. Position is already aligned.
Definition Components.cpp:27
void Pop()
Pops style at the top.
Definition TerminalBase.cpp:45
void Push(const TerminalStyle &style)
Pushes given style to the top.
Definition TerminalBase.cpp:43
void ProvideActions(ActionRegistry &registry) override
Provides own actions to the ActionRegistry.
Definition TextComponent.h:40
bool IsSelectable() const override
Returns value indicating, whether component is selectable.
Definition TextComponent.h:34
WideString Text
Text that should be drawed on screen.
Definition TextComponent.h:26
Int2 getSize() override
Returns size of a component.
Definition TextComponent.h:16
void Draw(DrawContext &context) override
Draws self.
Definition TextComponent.h:46
Represents a mutable sequence of utf-16 characters, providing various member functions for string man...
Definition WideString.h:14
A utility which contains all essential class instances and functions for rendering objects.
Definition DrawContext.h:14
void Put(const String &text, Int2 position)
Puts a UTF-8 text at given position and with given text.
Definition DrawContext.cpp:7
StyleStack StyleStack
Style stack.
Definition DrawContext.h:31
Represents terminal text style, described by background and foreground color.
Definition Terminal.h:20
Represents a two component vector. Components are 32-bit and they are signed.
Definition Int2.h:11