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-2024 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 "Rgb.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&, Rgb, Vec2 position);
18
19 void drawSelf(jngl::Mat3) 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::Rgb color;
36};
37
38} // namespace jngl
Contains jngl::Rgb class.
Contains jngl::TextLine class.
Contains jngl::Container class.
Font loaded from a TTF or OTF file.
Definition font.hpp:20
Simple Widget displaying a line of text.
Definition Label.hpp:15
void setAlpha(float alpha)
Set font color alpha from 0...1.
void drawSelf(jngl::Mat3) const override
Override this function to draw the widget.
void setAlign(Alignment)
How to align the label's text, default is CENTER.
float getWidth() const
Returns the width of the underlying jngl::TextLine.
3x3 matrix
Definition Mat3.hpp:18
Object representing a RGB color, new version of jngl::Color (which will be deprecated in the future)
Definition Rgb.hpp:15
Rectangle shaped text (in contrast to jngl::Text this only represents one line)
Definition TextLine.hpp:18
Two-dimensional vector.
Definition Vec2.hpp:36
jngl::Vec2 position
Center.
Definition Widget.hpp:59
JNGL's main namespace.
Alignment
How multiple lines should be aligned in a text block.
Definition text.hpp:17