JNGL
text.hpp
Go to the documentation of this file.
1 // Copyright 2012-2020 Jan Niklas Hasse <[email protected]>
2 // For conditions of distribution and use, see copyright notice in LICENSE.txt
4 
5 #pragma once
6 
7 #include "Drawable.hpp"
8 
9 #include <memory>
10 #include <string>
11 #include <vector>
12 
13 namespace jngl {
14 
16 enum class Alignment { LEFT, RIGHT, CENTER };
17 
18 class Font;
19 class FontImpl;
20 class Line;
21 
23 class Text : public Drawable {
24 public:
26  explicit Text(const std::string& text = "");
27 
29  void setText(const std::string&);
30 
32  void setFont(Font&);
33 
36 
38  void step() override;
39 
41  void draw() const override;
42 
43 private:
46  Alignment align = Alignment::LEFT;
47 };
48 
49 } // namespace jngl
jngl::Text::Text
Text(const std::string &text="")
Constructor, text may contain \n newlines.
std::string
std::shared_ptr< FontImpl >
vector
jngl
JNGL's main namespace.
Definition: App.hpp:9
jngl::Drawable
Base class for drawable objects with a position and a rectangle size.
Definition: Drawable.hpp:12
jngl::Text::draw
void draw() const override
Simply draws the Text object.
jngl::Text::setAlign
void setAlign(Alignment)
Alignment of this text block.
memory
Drawable.hpp
Contains jngl::Drawable class.
jngl::Font
Font loaded from a TTF or OTF file.
Definition: font.hpp:18
jngl::Text
Rectangle shaped text block.
Definition: text.hpp:23
jngl::Text::setFont
void setFont(Font &)
Font family.
jngl::Alignment
Alignment
How multiple lines should be aligned in a text block.
Definition: text.hpp:16
jngl::Text::step
void step() override
Does nothing.
jngl::Text::setText
void setText(const std::string &)
The text to display (may contain \n newlines)
string