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);
92 TGUI_NODISCARD
const LabelRenderer* getSharedRenderer()
const override;
116 using Widget::setSize;
252 TGUI_DEPRECATED(
"Use setIgnoreMouseEvents instead") void ignoreMouseEvents(
bool ignore = true);
259 TGUI_DEPRECATED("Use getIgnoreMouseEvents instead") TGUI_NODISCARD
bool isIgnoringMouseEvents() const;
266 void setParent(
Container* parent) override;
274 TGUI_NODISCARD
bool canGainFocus() const override;
280 TGUI_NODISCARD
bool isMouseOnWidget(
Vector2f pos) const override;
286 void leftMouseReleased(
Vector2f pos) override;
289 void mouseMoved(
Vector2f pos) override;
292 bool scrolled(
float delta,
Vector2f pos,
bool touch) override;
295 void mouseNoLongerOnWidget() override;
298 void leftMouseButtonNoLongerDown() override;
327 void rendererChanged(const
String& property) override;
332 TGUI_NODISCARD std::unique_ptr<DataIO::Node> save(SavingRenderersMap& renderers) const override;
337 void load(const std::unique_ptr<DataIO::Node>& node, const LoadingRenderersMap& renderers) override;
342 void updateTextSize() override;
347 bool updateTime(
Duration elapsedTime) override;
352 virtual
void rearrangeText();
357 void updateTextPiecePositions(
float maxWidth);
373 std::vector<std::vector<Text>> m_lines;
379 bool m_autoSize =
true;
381 float m_maximumTextWidth = 0;
383 bool m_ignoringMouseEvents =
false;
386 bool m_possibleDoubleClick =
false;
391 Sprite m_spriteBackground;
397 Color m_textColorCached;
398 Color m_borderColorCached;
399 Color m_backgroundColorCached;
400 Color m_textOutlineColorCached;
401 float m_textOutlineThicknessCached = 0;
Base class for render targets.
Definition BackendRenderTarget.hpp:46
Wrapper for colors.
Definition Color.hpp:73
Container widget.
Definition Container.hpp:48
Definition CopiedSharedPtr.hpp:42
Wrapper for durations.
Definition Duration.hpp:55
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.
TGUI_NODISCARD unsigned int getScrollbarMaxValue() const
Returns the maximum thumb position of the scrollbar.
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:35
Class to store the position or size of a widget.
Definition Layout.hpp:313
Definition Outline.hpp:38
Signal to which the user can subscribe to get callbacks from.
Definition Signal.hpp:61
Wrapper class to store strings.
Definition String.hpp:96
Wrapper for text styles.
Definition TextStyle.hpp:55
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:38
HorizontalAlignment
The horizontal alignment.
Definition Layout.hpp:61
@ Left
Align to the left side.
VerticalAlignment
The vertical alignment.
Definition Layout.hpp:72
States used for drawing.
Definition RenderStates.hpp:38