28#include <TGUI/Widgets/ClickableWidget.hpp>
29#include <TGUI/Renderers/LabelRenderer.hpp>
30#include <TGUI/CopiedSharedPtr.hpp>
31#include <TGUI/Widgets/Scrollbar.hpp>
32#include <TGUI/Text.hpp>
36TGUI_MODULE_EXPORT
namespace tgui
45 using Ptr = std::shared_ptr<Label>;
48 static constexpr const char StaticWidgetType[] =
"Label";
67 Label(
const char* typeName = StaticWidgetType,
bool initRenderer =
true);
94 TGUI_NODISCARD
const LabelRenderer* getSharedRenderer()
const override;
119 using Widget::setSize;
256 TGUI_DEPRECATED(
"Use setIgnoreMouseEvents instead") void ignoreMouseEvents(
bool ignore = true);
263 TGUI_DEPRECATED("Use getIgnoreMouseEvents instead") TGUI_NODISCARD
bool isIgnoringMouseEvents() const;
270 void setParent(
Container* parent) override;
278 TGUI_NODISCARD
bool canGainFocus() const override;
284 TGUI_NODISCARD
bool isMouseOnWidget(
Vector2f pos) const override;
290 void leftMouseReleased(
Vector2f pos) override;
293 void mouseMoved(
Vector2f pos) override;
296 bool scrolled(
float delta,
Vector2f pos,
bool touch) override;
299 void mouseNoLongerOnWidget() override;
302 void leftMouseButtonNoLongerDown() override;
333 void rendererChanged(const
String& property) override;
338 TGUI_NODISCARD std::unique_ptr<DataIO::Node> save(SavingRenderersMap& renderers) const override;
343 void load(const std::unique_ptr<DataIO::Node>& node, const LoadingRenderersMap& renderers) override;
348 void updateTextSize() override;
353 bool updateTime(
Duration elapsedTime) override;
358 virtual
void rearrangeText();
363 void updateTextPiecePositions(
float maxWidth);
379 std::vector<std::vector<Text>> m_lines;
385 bool m_autoSize =
true;
387 float m_maximumTextWidth = 0;
389 bool m_ignoringMouseEvents =
false;
392 bool m_possibleDoubleClick =
false;
397 Sprite m_spriteBackground;
403 Color m_textColorCached;
404 Color m_borderColorCached;
405 Color m_backgroundColorCached;
406 Color m_textOutlineColorCached;
407 float m_textOutlineThicknessCached = 0;
Base class for render targets.
Definition BackendRenderTarget.hpp:48
Wrapper for colors.
Definition Color.hpp:74
Container widget.
Definition Container.hpp:49
Definition CopiedSharedPtr.hpp:45
Wrapper for durations.
Definition Duration.hpp:56
Label widget.
Definition Label.hpp:42
void setAutoSize(bool autoSize)
Changes whether the label is auto-sized or not.
void setMaximumTextWidth(float maximumWidth)
Changes the maximum width that the text will have when auto-sizing.
void setScrollbarPolicy(Scrollbar::Policy policy)
Changes when the vertical scrollbar should be displayed.
static TGUI_NODISCARD Label::Ptr create(const String &text="")
Creates a new label widget.
TGUI_NODISCARD tgui::HorizontalAlignment getHorizontalAlignment() const
Gets the current horizontal text alignment.
TGUI_NODISCARD Scrollbar::Policy getScrollbarPolicy() const
Returns when the vertical scrollbar should be displayed.
TGUI_NODISCARD tgui::VerticalAlignment getVerticalAlignment() const
Gets the current vertical text alignment.
std::shared_ptr< const Label > ConstPtr
Shared constant widget pointer.
Definition Label.hpp:46
void setScrollbarValue(unsigned int value)
Changes the thumb position of the scrollbar.
void setText(const String &text)
Changes the text.
TGUI_NODISCARD unsigned int getScrollbarValue() const
Returns the thumb position of the scrollbar.
TGUI_NODISCARD LabelRenderer * getRenderer() override
Returns the renderer, which gives access to functions that determine how the widget is displayed.
TGUI_NODISCARD const String & getText() const
Returns the text.
void setHorizontalAlignment(tgui::HorizontalAlignment alignment)
Changes the horizontal text alignment.
TGUI_NODISCARD bool getAutoSize() const
Returns whether the label is auto-sized or not.
void setSize(const Layout2d &size) override
Changes the area of the text that will be drawn.
TGUI_NODISCARD LabelRenderer * getSharedRenderer() override
Returns the renderer, which gives access to functions that determine how the widget is displayed.
TGUI_NODISCARD float getMaximumTextWidth() const
Returns the maximum width that the text will have.
void setVerticalAlignment(tgui::VerticalAlignment alignment)
Changes the vertical text alignment.
static TGUI_NODISCARD Label::Ptr copy(const Label::ConstPtr &label)
Makes a copy of another label.
std::shared_ptr< Label > Ptr
Shared widget pointer.
Definition Label.hpp:45
Definition LabelRenderer.hpp:37
Class to store the position or size of a widget.
Definition Layout.hpp:328
Definition Outline.hpp:39
Signal to which the user can subscribe to get callbacks from.
Definition Signal.hpp:62
Wrapper class to store strings.
Definition String.hpp:101
Wrapper for text styles.
Definition TextStyle.hpp:57
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:39
HorizontalAlignment
The horizontal alignment.
Definition Layout.hpp:52
@ Left
Align to the left side.
VerticalAlignment
The vertical alignment.
Definition Layout.hpp:64
States used for drawing.
Definition RenderStates.hpp:39