Capycore Engine  0.1.0
A simple and lightweight game engine written in C++ based on the Unity API architecture.
Loading...
Searching...
No Matches
text.h
Go to the documentation of this file.
1#pragma once
2
7
8#include <string>
9
13enum TextAlignment : uint8_t {
14 Left = 0,
15 Center = 1,
16 Right = 2,
17};
18
32class Text : public Renderable {
33 public:
34 Text(std::string text, std::string font, std::string font_path, int font_size,
35 Color color);
36
37 void update(float dt) override {}
38
39 [[nodiscard]] const std::string& text() const;
40 Text& text(const std::string& text);
41
42 [[nodiscard]] const std::string& font() const;
43 Text& font(const std::string& font);
44
45 [[nodiscard]] const std::string& font_path() const;
46 Text& font_path(const std::string& font_path);
47
48 [[nodiscard]] int font_size() const;
50
51 [[nodiscard]] Color color() const;
53
54 [[nodiscard]] bool dirty() const;
55 void mark_dirty(bool dirty = true);
56
57 std::string type_name() const override;
58
59 [[nodiscard]] TextAlignment alignment() const;
61
62 [[nodiscard]] Point offset() const;
64
65 private:
66 std::string text_;
67 std::string font_;
68 std::string font_path_;
69
70 int font_size_;
71 Color color_;
72
73 TextAlignment alignment_{Center};
74 Point offset_{0, 0};
75
76 bool dirty_;
77};
Represents a color with red, green, blue, and alpha components. Each component is represented as an u...
Definition color.h:7
Represents a point in 2D space.
Definition point.h:6
Base class for renderable components in the engine.
Definition renderable.h:16
UI Text Component.
Definition text.h:32
int font_size() const
Text & font(const std::string &font)
Color color() const
const std::string & text() const
Text & font_size(int font_size)
Text & color(Color color)
Text & offset(Point offset)
void update(float dt) override
Definition text.h:37
bool dirty() const
Text(std::string text, std::string font, std::string font_path, int font_size, Color color)
const std::string & font_path() const
TextAlignment alignment() const
Text & font_path(const std::string &font_path)
Point offset() const
const std::string & font() const
void mark_dirty(bool dirty=true)
Text & alignment(TextAlignment alignment)
std::string type_name() const override
Provides a consistent type name for the component.
Text & text(const std::string &text)
TextAlignment
Text alignment options.
Definition text.h:13
@ Left
Definition text.h:14
@ Center
Definition text.h:15
@ Right
Definition text.h:16