30#include <TGUI/Widgets/ClickableWidget.hpp>
31#include <TGUI/Renderers/LabelRenderer.hpp>
32#include <TGUI/CopiedSharedPtr.hpp>
33#include <TGUI/Widgets/Scrollbar.hpp>
34#include <TGUI/Text.hpp>
38TGUI_MODULE_EXPORT
namespace tgui
47 using Ptr = std::shared_ptr<Label>;
50 static constexpr const char StaticWidgetType[] =
"Label";
82 Label(
const char* typeName = StaticWidgetType,
bool initRenderer =
true);
112 TGUI_NODISCARD
const LabelRenderer* getSharedRenderer()
const override;
138 using Widget::setSize;
306 void setParent(
Container* parent)
override;
326 bool leftMousePressed(
Vector2f pos)
override;
329 void leftMouseReleased(
Vector2f pos)
override;
332 void mouseMoved(
Vector2f pos)
override;
335 bool scrolled(
float delta,
Vector2f pos,
bool touch)
override;
338 void mouseNoLongerOnWidget()
override;
341 void leftMouseButtonNoLongerDown()
override;
381 TGUI_NODISCARD std::unique_ptr<DataIO::Node>
save(SavingRenderersMap& renderers)
const override;
387 void load(
const std::unique_ptr<DataIO::Node>& node,
const LoadingRenderersMap& renderers)
override;
399 bool updateTime(
Duration elapsedTime)
override;
411 void updateTextPiecePositions(
float maxWidth);
430 std::vector<std::vector<Text>> m_lines;
432 HorizontalAlignment m_horizontalAlignment = HorizontalAlignment::Left;
433 VerticalAlignment m_verticalAlignment = VerticalAlignment::Top;
435 bool m_autoSize =
true;
437 float m_maximumTextWidth = 0;
439 bool m_ignoringMouseEvents =
false;
442 bool m_possibleDoubleClick =
false;
447 Sprite m_spriteBackground;
453 Color m_textColorCached;
454 Color m_borderColorCached;
455 Color m_backgroundColorCached;
456 Color m_textOutlineColorCached;
457 float m_textOutlineThicknessCached = 0;
Base class for render targets.
Definition BackendRenderTarget.hpp:48
Wrapper for colors.
Definition Color.hpp:72
Container widget.
Definition Container.hpp:49
Definition CopiedSharedPtr.hpp:45
Wrapper for durations.
Definition Duration.hpp:56
Definition LabelRenderer.hpp:37
Label widget.
Definition Label.hpp:44
void updateTextSize() override
Called when the text size is changed (either by setTextSize or via the renderer)
TGUI_NODISCARD bool isIgnoringMouseEvents() const
Returns whether the widget is ignoring mouse events and letting them pass to the widgets behind it.
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.
VerticalAlignment
The vertical text alignment.
Definition Label.hpp:68
void ignoreMouseEvents(bool ignore=true)
Sets whether the widget should completely ignore mouse events and let them pass to the widgets behind...
void draw(BackendRenderTarget &target, RenderStates states) const override
Draw the widget to a render target.
void load(const std::unique_ptr< DataIO::Node > &node, const LoadingRenderersMap &renderers) override
Loads the widget from a tree of nodes.
virtual void rearrangeText()
Rearrange the text (recreates m_textPieces), making use of the given size of maximum text width.
TGUI_NODISCARD Scrollbar::Policy getScrollbarPolicy() const
Returns when the vertical scrollbar should be displayed.
TGUI_NODISCARD bool isMouseOnWidget(Vector2f pos) const override
Returns whether the mouse position (which is relative to the parent widget) lies on top of the widget...
void setVerticalAlignment(VerticalAlignment alignment)
Changes the vertical text alignment.
std::shared_ptr< const Label > ConstPtr
Shared constant widget pointer.
Definition Label.hpp:48
TGUI_NODISCARD VerticalAlignment getVerticalAlignment() const
Gets the current vertical text alignment.
TGUI_NODISCARD Signal & getSignal(String signalName) override
Retrieves a signal based on its name.
void setScrollbarValue(unsigned int value)
Changes the thumb position of the scrollbar.
TGUI_NODISCARD bool canGainFocus() const override
Returns whether the widget can gain focus.
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 HorizontalAlignment getHorizontalAlignment() const
Gets the current horizontal text alignment.
TGUI_NODISCARD const String & getText() const
Returns the text.
TGUI_NODISCARD std::unique_ptr< DataIO::Node > save(SavingRenderersMap &renderers) const override
Saves the widget as a tree node in order to save it to a file.
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 Widget::Ptr clone() const override
Makes a copy of the widget if you don't know its exact type.
void rendererChanged(const String &property) override
Function called when one of the properties of the renderer is changed.
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:47
void setHorizontalAlignment(HorizontalAlignment alignment)
Changes the horizontal text alignment.
HorizontalAlignment
The horizontal text alignment.
Definition Label.hpp:57
Class to store the position or size of a widget.
Definition Layout.hpp:289
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
States used for drawing.
Definition RenderStates.hpp:39