JNGL
Easy to use cross-platform 2D game library
Loading...
Searching...
No Matches
Label.hpp
Go to the documentation of this file.
1// Copyright 2020-2022 Jan Niklas Hasse <jhasse@bixense.com>
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
12namespace jngl {
13
15class Label : public Widget {
16public:
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
30protected:
31 float alpha = 1.f;
32
33private:
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:28
Font loaded from a TTF or OTF file.
Definition: font.hpp:19
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:18
Two-dimensional vector.
Definition: Vec2.hpp:32
jngl::Vec2 position
Center.
Definition: Widget.hpp:58
JNGL's main namespace.
Definition: Achievement.hpp:10
Alignment
How multiple lines should be aligned in a text block.
Definition: text.hpp:16