26 #ifndef TGUI_LABEL_HPP
27 #define TGUI_LABEL_HPP
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>
47 typedef std::shared_ptr<Label>
Ptr;
79 Label(
const char* typeName =
"Label",
bool initRenderer =
true);
297 void setParent(
Container* parent)
override;
317 void leftMousePressed(
Vector2f pos)
override;
320 void leftMouseReleased(
Vector2f pos)
override;
323 void mouseMoved(
Vector2f pos)
override;
326 bool mouseWheelScrolled(
float delta,
Vector2f pos)
override;
329 void mouseNoLongerOnWidget()
override;
332 void leftMouseButtonNoLongerDown()
override;
372 std::unique_ptr<DataIO::Node>
save(SavingRenderersMap& renderers)
const override;
378 void load(
const std::unique_ptr<DataIO::Node>& node,
const LoadingRenderersMap& renderers)
override;
384 bool updateTime(
Duration elapsedTime)
override;
390 void rearrangeText();
398 return std::make_shared<Label>(*
this);
412 std::vector<Text> m_lines;
414 HorizontalAlignment m_horizontalAlignment = HorizontalAlignment::Left;
415 VerticalAlignment m_verticalAlignment = VerticalAlignment::Top;
417 bool m_autoSize =
true;
419 float m_maximumTextWidth = 0;
421 bool m_ignoringMouseEvents =
false;
424 bool m_possibleDoubleClick =
false;
429 Sprite m_spriteBackground;
435 Color m_textColorCached;
436 Color m_borderColorCached;
437 Color m_backgroundColorCached;
438 Color m_textOutlineColorCached;
439 float m_textOutlineThicknessCached = 0;
Base class for render targets.
Definition: BackendRenderTarget.hpp:48
Wrapper for colors.
Definition: Color.hpp:52
Container widget.
Definition: Container.hpp:47
Definition: CopiedSharedPtr.hpp:40
Wrapper for durations.
Definition: Duration.hpp:52
Definition: LabelRenderer.hpp:37
Label widget.
Definition: Label.hpp:44
const String & getText() const
Returns the text.
void setTextSize(unsigned int size) override
Changes the character size of the text.
bool canGainFocus() const override
Returns whether the widget can gain focus.
void setAutoSize(bool autoSize)
Changes whether the label is auto-sized or not.
HorizontalAlignment getHorizontalAlignment() const
Gets the current horizontal text alignment.
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.
Widget::Ptr clone() const override
Makes a copy of the widget if you don't know its exact type.
Definition: Label.hpp:396
VerticalAlignment
The vertical text alignment.
Definition: Label.hpp:65
Signal & getSignal(String signalName) override
Retrieves a signal based on its name.
void ignoreMouseEvents(bool ignore=true)
Sets whether the widget should completely ignore mouse events and let them pass to the widgets behind...
void load(const std::unique_ptr< DataIO::Node > &node, const LoadingRenderersMap &renderers) override
Loads the widget from a tree of nodes.
float getMaximumTextWidth() const
Returns the maximum width that the text will have.
void draw(BackendRenderTargetBase &target, RenderStates states) const override
Draw the widget to a render target.
void setVerticalAlignment(VerticalAlignment alignment)
Changes the vertical text alignment.
bool isIgnoringMouseEvents() const
Returns whether the widget is ignoring mouse events and letting them pass to the widgets behind it.
std::shared_ptr< const Label > ConstPtr
Shared constant widget pointer.
Definition: Label.hpp:48
static Label::Ptr copy(Label::ConstPtr label)
Makes a copy of another label.
void setText(const String &text)
Changes the text.
std::shared_ptr< Label > Ptr
Shared widget pointer.
Definition: Label.hpp:47
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.
bool getAutoSize() const
Returns whether the label is auto-sized or not.
LabelRenderer * getRenderer()
Returns the renderer, which gives access to functions that determine how the widget is displayed.
VerticalAlignment getVerticalAlignment() const
Gets the current vertical text alignment.
Scrollbar::Policy getScrollbarPolicy() const
Returns when the vertical scrollbar should be displayed.
LabelRenderer * getSharedRenderer()
Returns the renderer, which gives access to functions that determine how the widget is displayed.
void setSize(const Layout2d &size) override
Changes the area of the text that will be drawn.
static Label::Ptr create(String text="")
Creates a new label widget.
void rendererChanged(const String &property) override
Function called when one of the properties of the renderer is changed.
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 setHorizontalAlignment(HorizontalAlignment alignment)
Changes the horizontal text alignment.
HorizontalAlignment
The horizontal text alignment.
Definition: Label.hpp:54
Class to store the position or size of a widget.
Definition: Layout.hpp:262
Definition: Outline.hpp:39
Signal to which the user can subscribe to get callbacks from.
Definition: Signal.hpp:58
Definition: Sprite.hpp:49
Wrapper class to store strings.
Definition: String.hpp:74
Wrapper for text styles.
Definition: TextStyle.hpp:58
Namespace that contains all TGUI functions and classes.
Definition: AbsoluteOrRelativeValue.hpp:36
States used for drawing.
Definition: RenderStates.hpp:39