JNGL
Label.hpp
Go to the documentation of this file.
1 // Copyright 2020-2022 Jan Niklas Hasse <[email protected]>
2 // For conditions of distribution and use, see copyright notice in LICENSE.txt
5 #pragma once
6 
7 #include "Color.hpp"
8 #include "TextLine.hpp"
9 #include "Widget.hpp"
10 #include "text.hpp"
11 
12 namespace jngl {
13 
15 class Label : public Widget {
16 public:
17  explicit Label(const std::string& str, Font&, Color, Vec2 position);
18 
19  void drawSelf() const override;
20 
22  void setAlpha(float alpha);
23 
26 
28  float getWidth() const;
29 
30 protected:
31  float alpha = 1.f;
32 
33 private:
34  jngl::TextLine text;
35  jngl::Color color;
36 };
37 
38 } // namespace jngl
Contains jngl::Color class.
Contains jngl::TextLine class.
Contains jngl::Container class.
Object representing a RGB color.
Definition: Color.hpp:25
Font loaded from a TTF or OTF file.
Definition: font.hpp:18
Simple Widget displaying a line of text.
Definition: Label.hpp:15
void setAlpha(float alpha)
Set font color alpha from 0...1.
void setAlign(Alignment)
How to align the label's text, default is CENTER.
float getWidth() const
Returns the width of the underlying jngl::TextLine.
void drawSelf() const override
Override this function to draw the widget.
Rectangle shaped text (in contrast to jngl::Text this only represents one line)
Definition: TextLine.hpp:17
Two-dimensional vector.
Definition: Vec2.hpp:35
jngl::Vec2 position
Center.
Definition: Widget.hpp:57
JNGL's main namespace.
Definition: App.hpp:10
Alignment
How multiple lines should be aligned in a text block.
Definition: text.hpp:16