28#include <TGUI/Widgets/ClickableWidget.hpp>
29#include <TGUI/Renderers/LabelRenderer.hpp>
30#include <TGUI/Widgets/Scrollbar.hpp>
31#include <TGUI/Text.hpp>
35TGUI_MODULE_EXPORT
namespace tgui
44 using Ptr = std::shared_ptr<Label>;
47 static constexpr const char StaticWidgetType[] =
"Label";
66 Label(
const char* typeName = StaticWidgetType,
bool initRenderer =
true);
91 TGUI_NODISCARD
const LabelRenderer* getSharedRenderer()
const override;
115 using Widget::setSize;
171 TGUI_DEPRECATED(
"Use getScrollbar()->setPolicy(policy) instead") void setScrollbarPolicy(
Scrollbar::Policy policy);
177 TGUI_DEPRECATED("Use getScrollbar()->getPolicy() instead") TGUI_NODISCARD
Scrollbar::Policy getScrollbarPolicy() const;
184 TGUI_DEPRECATED("Use getScrollbar()->setValue(value) instead")
void setScrollbarValue(
unsigned int value);
191 TGUI_DEPRECATED("Use getScrollbar()->getValue() instead") TGUI_NODISCARD
unsigned int getScrollbarValue() const;
200 TGUI_DEPRECATED("Use getScrollbar()->getMaxValue() instead") TGUI_NODISCARD
unsigned int getScrollbarMaxValue() const;
212 void setAutoSize(
bool autoSize);
219 TGUI_NODISCARD
bool getAutoSize() const;
232 void setMaximumTextWidth(
float maximumWidth);
242 TGUI_NODISCARD
float getMaximumTextWidth() const;
251 TGUI_DEPRECATED("Use setIgnoreMouseEvents instead")
void ignoreMouseEvents(
bool ignore = true);
258 TGUI_DEPRECATED("Use getIgnoreMouseEvents instead") TGUI_NODISCARD
bool isIgnoringMouseEvents() const;
265 void setParent(
Container* parent) override;
273 TGUI_NODISCARD
bool canGainFocus() const override;
279 TGUI_NODISCARD
bool isMouseOnWidget(
Vector2f pos) const override;
285 void leftMouseReleased(
Vector2f pos) override;
288 void mouseMoved(
Vector2f pos) override;
291 bool scrolled(
float delta,
Vector2f pos,
bool touch) override;
294 void mouseNoLongerOnWidget() override;
297 void leftMouseButtonNoLongerDown() override;
326 void rendererChanged(const
String& property) override;
331 TGUI_NODISCARD std::unique_ptr<DataIO::Node> save(SavingRenderersMap& renderers) const override;
336 void load(const std::unique_ptr<DataIO::Node>& node, const LoadingRenderersMap& renderers) override;
341 void updateTextSize() override;
346 bool updateTime(
Duration elapsedTime) override;
351 void scrollbarPolicyChanged() override;
356 virtual
void rearrangeText();
361 void updateTextPiecePositions(
float maxWidth);
377 std::vector<std::vector<Text>> m_lines;
383 bool m_autoSize =
true;
385 float m_maximumTextWidth = 0;
387 bool m_ignoringMouseEvents =
false;
390 bool m_possibleDoubleClick =
false;
392 Sprite m_spriteBackground;
398 Color m_textColorCached;
399 Color m_borderColorCached;
400 Color m_backgroundColorCached;
401 Color m_textOutlineColorCached = Color::Black;
402 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
Wrapper for durations.
Definition Duration.hpp:55
Definition LabelRenderer.hpp:35
Label widget.
Definition Label.hpp:41
static Label::Ptr create(const String &text="")
Creates a new label widget.
std::shared_ptr< const Label > ConstPtr
Shared constant widget pointer.
Definition Label.hpp:45
static Label::Ptr copy(const Label::ConstPtr &label)
Makes a copy of another label.
LabelRenderer * getSharedRenderer() override
Returns the renderer, which gives access to functions that determine how the widget is displayed.
void setText(const String &text)
Changes the text.
void setHorizontalAlignment(tgui::HorizontalAlignment alignment)
Changes the horizontal text alignment.
LabelRenderer * getRenderer() override
Returns the renderer, which gives access to functions that determine how the widget is displayed.
tgui::VerticalAlignment getVerticalAlignment() const
Gets the current vertical text alignment.
void setSize(const Layout2d &size) override
Changes the area of the text that will be drawn.
const String & getText() const
Returns the text.
void setVerticalAlignment(tgui::VerticalAlignment alignment)
Changes the vertical text alignment.
tgui::HorizontalAlignment getHorizontalAlignment() const
Gets the current horizontal text alignment.
std::shared_ptr< Label > Ptr
Shared widget pointer.
Definition Label.hpp:44
Class to store the position or size of a widget.
Definition Layout.hpp:323
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:62
@ Left
Align to the left side.
VerticalAlignment
The vertical alignment.
Definition Layout.hpp:73
States used for drawing.
Definition RenderStates.hpp:38