--- --- TGUI: include/TGUI/Widget.hpp Source File
TGUI  1.x-dev
Loading...
Searching...
No Matches
Widget.hpp
1
2//
3// TGUI - Texus' Graphical User Interface
4// Copyright (C) 2012-2024 Bruno Van de Velde (vdv_b@tgui.eu)
5//
6// This software is provided 'as-is', without any express or implied warranty.
7// In no event will the authors be held liable for any damages arising from the use of this software.
8//
9// Permission is granted to anyone to use this software for any purpose,
10// including commercial applications, and to alter it and redistribute it freely,
11// subject to the following restrictions:
12//
13// 1. The origin of this software must not be misrepresented;
14// you must not claim that you wrote the original software.
15// If you use this software in a product, an acknowledgment
16// in the product documentation would be appreciated but is not required.
17//
18// 2. Altered source versions must be plainly marked as such,
19// and must not be misrepresented as being the original software.
20//
21// 3. This notice may not be removed or altered from any source distribution.
22//
24
25
26#ifndef TGUI_WIDGET_HPP
27#define TGUI_WIDGET_HPP
28
30
31#include <TGUI/Signal.hpp>
32#include <TGUI/Font.hpp>
33#include <TGUI/Sprite.hpp>
34#include <TGUI/Layout.hpp>
35#include <TGUI/String.hpp>
36#include <TGUI/Vector2.hpp>
37#include <TGUI/Duration.hpp>
38#include <TGUI/Cursor.hpp>
39#include <TGUI/Event.hpp>
40#include <TGUI/Any.hpp>
41#include <TGUI/Backend/Renderer/BackendRenderTarget.hpp>
42#include <TGUI/Loading/Theme.hpp>
43#include <TGUI/Loading/DataIO.hpp>
44#include <TGUI/Loading/Serializer.hpp>
45#include <TGUI/Loading/Deserializer.hpp>
46#include <TGUI/Renderers/WidgetRenderer.hpp>
47
48#if TGUI_USE_SYSTEM_AURORA
49 #include <Aurora/SmartPtr/CopiedPtr.hpp>
50 #include <Aurora/Tools/Downcast.hpp>
51#else
52 #include <TGUI/extlibs/Aurora/SmartPtr/CopiedPtr.hpp>
53 #include <TGUI/extlibs/Aurora/Tools/Downcast.hpp>
54#endif
55
56#if !TGUI_EXPERIMENTAL_USE_STD_MODULE
57 #include <unordered_set>
58#endif
59
61
62TGUI_MODULE_EXPORT namespace tgui
63{
64 class BackendGui;
65 class Container;
66
67 enum class ShowEffectType;
68}
69
70namespace tgui
71{
72 namespace priv
73 {
74 class Animation;
75 }
76}
77
78TGUI_MODULE_EXPORT namespace tgui
79{
83 class TGUI_API Widget : public std::enable_shared_from_this<Widget>
84 {
85 public:
86
87 using Ptr = std::shared_ptr<Widget>;
88 using ConstPtr = std::shared_ptr<const Widget>;
89
97 Widget(const char* typeName, bool initRenderer);
98
102 Widget(const Widget&);
103
107 Widget(Widget&&) noexcept;
108
112 virtual ~Widget();
113
117 Widget& operator=(const Widget&);
118
122 Widget& operator=(Widget&&) noexcept;
123
131 void setRenderer(std::shared_ptr<RendererData> rendererData);
132
137 TGUI_NODISCARD virtual WidgetRenderer* getSharedRenderer();
138 TGUI_NODISCARD virtual const WidgetRenderer* getSharedRenderer() const;
139
145 TGUI_NODISCARD virtual WidgetRenderer* getRenderer();
146
172 virtual void setPosition(const Layout2d& position);
173
188 void setPosition(Layout x, Layout y)
189 {
190 setPosition({std::move(x), std::move(y)});
191 }
192
198 TGUI_NODISCARD Vector2f getPosition() const
199 {
200 return m_position.getValue();
201 }
202
220 virtual void setSize(const Layout2d& size);
221
230 void setSize(Layout width, Layout height)
231 {
232 setSize({std::move(width), std::move(height)});
233 }
234
243 void setWidth(Layout width)
244 {
245 setSize({std::move(width), m_size.y});
246 }
247
256 void setHeight(Layout height)
257 {
258 setSize({m_size.x, std::move(height)});
259 }
260
266 TGUI_NODISCARD Vector2f getSize() const
267 {
268 return m_size.getValue();
269 }
270
279 TGUI_NODISCARD virtual Vector2f getFullSize() const;
280
288 TGUI_NODISCARD virtual Vector2f getAbsolutePosition(Vector2f offset = {}) const;
289
297 TGUI_NODISCARD virtual Vector2f getWidgetOffset() const;
298
307
315 TGUI_NODISCARD AutoLayout getAutoLayout() const;
316
327 void setOrigin(float x, float y)
328 {
329 setOrigin({x, y});
330 }
331
341 void setOrigin(Vector2f origin);
342
347 TGUI_NODISCARD Vector2f getOrigin() const
348 {
349 return m_origin;
350 }
351
363 void setScale(Vector2f scaleFactors);
364
376 void setScale(Vector2f scaleFactors, Vector2f origin);
377
389 void setScale(float scaleFactor)
390 {
391 setScale({scaleFactor, scaleFactor});
392 }
393
405 void setScale(float scaleFactor, Vector2f origin)
406 {
407 setScale({scaleFactor, scaleFactor}, origin);
408 }
409
415 TGUI_NODISCARD Vector2f getScale() const
416 {
417 return m_scaleFactors;
418 }
419
425 TGUI_NODISCARD Vector2f getScaleOrigin() const;
426
437 void setRotation(float angle);
438
449 void setRotation(float angle, Vector2f origin);
450
456 TGUI_NODISCARD float getRotation() const
457 {
458 return m_rotationDeg;
459 }
460
466 TGUI_NODISCARD Vector2f getRotationOrigin() const;
467
487
507
514 void moveWithAnimation(Layout2d position, Duration duration);
515
523
531 virtual void setVisible(bool visible);
532
541 TGUI_NODISCARD bool isVisible() const
542 {
543 return m_visible;
544 }
545
553 virtual void setEnabled(bool enabled);
554
563 TGUI_NODISCARD bool isEnabled() const
564 {
565 return m_enabled;
566 }
567
576 virtual void setFocused(bool focused);
577
583 TGUI_NODISCARD bool isFocused() const
584 {
585 return m_focused;
586 }
587
593 TGUI_NODISCARD const String& getWidgetType() const;
594
600 TGUI_NODISCARD Container* getParent() const
601 {
602 return m_parent;
603 }
604
610 TGUI_NODISCARD BackendGui* getParentGui() const
611 {
612 return m_parentGui;
613 }
614
620 TGUI_NODISCARD bool isAnimationPlaying() const;
621
628
635
646 void setUserData(Any userData)
647 {
648 m_userData = std::move(userData);
649 }
650
656 template <typename DataType>
657 TGUI_NODISCARD DataType getUserData() const
658 {
659 return AnyCast<DataType>(m_userData);
660 }
661
666 TGUI_NODISCARD bool hasUserData() const
667 {
668 return m_userData.has_value();
669 }
670
679 void setInheritedFont(const Font& font);
680
686 TGUI_NODISCARD const Font& getInheritedFont() const;
687
696 void setInheritedOpacity(float opacity);
697
703 TGUI_NODISCARD float getInheritedOpacity() const;
704
712 void setTextSize(unsigned int size);
713
722 TGUI_NODISCARD unsigned int getTextSize() const;
723
729 void setToolTip(Widget::Ptr toolTip);
730
736 TGUI_NODISCARD Widget::Ptr getToolTip() const;
737
750 void setWidgetName(const String& name);
751
757 TGUI_NODISCARD String getWidgetName() const;
758
767
773 TGUI_NODISCARD Cursor::Type getMouseCursor() const;
774
782 void setFocusable(bool focusable);
783
791 TGUI_NODISCARD bool isFocusable() const;
792
802 void setNavigationUp(const Widget::Ptr& widgetAbove);
803
811 TGUI_NODISCARD Widget::Ptr getNavigationUp() const;
812
822 void setNavigationDown(const Widget::Ptr& widgetBelow);
823
831 TGUI_NODISCARD Widget::Ptr getNavigationDown() const;
832
842 void setNavigationLeft(const Widget::Ptr& widgetLeft);
843
851 TGUI_NODISCARD Widget::Ptr getNavigationLeft() const;
852
862 void setNavigationRight(const Widget::Ptr& widgetRight);
863
871 TGUI_NODISCARD Widget::Ptr getNavigationRight() const;
872
885 void setIgnoreMouseEvents(bool ignore);
886
894 TGUI_NODISCARD bool getIgnoreMouseEvents() const;
895
900
907 TGUI_NODISCARD virtual bool canGainFocus() const;
908
913 TGUI_NODISCARD bool isContainer() const;
914
919 TGUI_NODISCARD bool isMouseDown() const;
920
930 TGUI_NODISCARD virtual Signal& getSignal(String signalName);
931
937 virtual void setParent(Container* parent);
938
943 virtual bool updateTime(Duration elapsedTime);
944
949 void setAutoLayoutUpdateEnabled(bool enabled);
950
955 TGUI_NODISCARD virtual bool isMouseOnWidget(Vector2f pos) const = 0;
956
964 virtual bool leftMousePressed(Vector2f pos);
965
969 virtual void leftMouseReleased(Vector2f pos);
970
974 virtual void rightMousePressed(Vector2f pos);
975
979 virtual void rightMouseReleased(Vector2f pos);
980
984 virtual void mouseReleased(Event::MouseButton button, Vector2f pos);
985
989 virtual void mouseMoved(Vector2f pos);
990
994 virtual void keyPressed(const Event::KeyEvent& event);
995
1005 virtual bool canHandleKeyPress(const Event::KeyEvent& event);
1006
1010 virtual void textEntered(char32_t key);
1011
1021 virtual bool scrolled(float delta, Vector2f pos, bool touch);
1022
1026 virtual void mouseNoLongerOnWidget();
1027
1031 virtual void leftMouseButtonNoLongerDown();
1032
1036 virtual void rightMouseButtonNoLongerDown();
1037
1040 // Show the tool tip when the widget is located below the mouse.
1041 // Returns its tool tip or the tool tip from a child widget if the mouse is on top of the widget.
1042 // A nullptr is returned when the mouse is not on top of the widget or when the tool tip is empty.
1044 TGUI_NODISCARD virtual Widget::Ptr askToolTip(Vector2f mousePos);
1045
1050 TGUI_NODISCARD const Layout2d& getPositionLayout() const
1051 {
1052 return m_position;
1053 }
1054
1059 TGUI_NODISCARD const Layout2d& getSizeLayout() const
1060 {
1061 return m_size;
1062 }
1063
1068 void bindPositionLayout(Layout* layout);
1069
1074 void unbindPositionLayout(Layout* layout);
1075
1080 void bindSizeLayout(Layout* layout);
1081
1086 void unbindSizeLayout(Layout* layout);
1087
1096 virtual void draw(BackendRenderTarget& target, RenderStates states) const = 0;
1097
1101 template <typename WidgetType>
1102 TGUI_NODISCARD std::shared_ptr<const WidgetType> cast() const
1103 {
1104 return std::dynamic_pointer_cast<const WidgetType>(shared_from_this());
1105 }
1106
1110 template <typename WidgetType>
1111 TGUI_NODISCARD std::shared_ptr<WidgetType> cast()
1112 {
1113 return std::dynamic_pointer_cast<WidgetType>(shared_from_this());
1114 }
1115
1124 TGUI_NODISCARD virtual Widget::Ptr clone() const = 0;
1125
1130 void rendererChangedCallback(const String& property);
1131
1136 virtual void updateTextSize();
1137
1139 protected:
1140
1141 using SavingRenderersMap = std::map<const Widget*, std::pair<std::unique_ptr<DataIO::Node>, String>>;
1142 using LoadingRenderersMap = std::map<String, std::shared_ptr<RendererData>>;
1143
1149 virtual void rendererChanged(const String& property);
1150
1154 TGUI_NODISCARD virtual std::unique_ptr<DataIO::Node> save(SavingRenderersMap& renderers) const;
1155
1159 virtual void load(const std::unique_ptr<DataIO::Node>& node, const LoadingRenderersMap& renderers);
1160
1164 virtual void mouseEnteredWidget();
1165
1169 virtual void mouseLeftWidget();
1170
1175
1180
1182 public:
1183
1184 SignalVector2f onPositionChange = {"PositionChanged"};
1185 SignalVector2f onSizeChange = {"SizeChanged"};
1186 Signal onFocus = {"Focused"};
1187 Signal onUnfocus = {"Unfocused"};
1188 Signal onMouseEnter = {"MouseEntered"};
1189 Signal onMouseLeave = {"MouseLeft"};
1190 SignalShowEffect onShowEffectFinish = {"ShowEffectFinished"};
1191
1198 SignalAnimationType onAnimationFinish = {"AnimationFinished"};
1199
1201 protected:
1202
1203 String m_type;
1204 String m_name;
1205
1210
1215 unsigned int m_textSize = 0; // This may be overwritten by the renderer, m_textSizeCached contains the actual text size
1216
1217 Vector2f m_origin;
1218 Optional<Vector2f> m_rotationOrigin;
1219 Optional<Vector2f> m_scaleOrigin;
1220 Vector2f m_scaleFactors = {1, 1};
1221 float m_rotationDeg = 0;
1222
1223 // The previous position and size have to be stored because when setPosition/setSize is called, the layout may already be
1224 // changed and there would be no way for the widget to detect whether the values changed or not.
1225 Vector2f m_prevPosition;
1226 Vector2f m_prevSize;
1227
1228 // Layouts that need to recalculate their value when the position or size of this widget changes
1229 std::unordered_set<Layout*> m_boundPositionLayouts;
1230 std::unordered_set<Layout*> m_boundSizeLayouts;
1231
1237 bool m_enabled = true;
1238
1244 bool m_visible = true;
1245
1246 // This will point to our parent widget. If there is no parent then this will be nullptr.
1247 Container* m_parent = nullptr;
1248 BackendGui* m_parentGui = nullptr;
1249
1250 // Is the mouse on top of the widget? Did the mouse go down on the widget?
1251 bool m_mouseHover = false;
1252 bool m_mouseDown = false;
1253
1254 // Is the widget focused?
1255 bool m_focused = false;
1256
1257 // Can the widget be focused?
1258 bool m_focusable = true;
1259
1260 // Widgets that can be navigated to from this widgets with the arrow keys
1261 std::weak_ptr<Widget> m_navWidgetUp;
1262 std::weak_ptr<Widget> m_navWidgetDown;
1263 std::weak_ptr<Widget> m_navWidgetRight;
1264 std::weak_ptr<Widget> m_navWidgetLeft;
1265
1266 // Keep track of the elapsed time.
1267 Duration m_animationTimeElapsed;
1268
1269 // This is set to true for widgets that store other widgets inside them
1270 bool m_containerWidget = false;
1271
1272 // The tool tip connected to the widget
1273 Widget::Ptr m_toolTip = nullptr;
1274
1275 // Renderer of the widget
1276 aurora::CopiedPtr<WidgetRenderer> m_renderer = nullptr;
1277
1278 // Show animations
1279 std::vector<std::unique_ptr<priv::Animation>> m_showAnimations;
1280
1281 // Renderer properties that can be passed from containers to their children
1282 Font m_inheritedFont;
1283 float m_inheritedOpacity = 1;
1284
1285 Any m_userData;
1286 Cursor::Type m_mouseCursor = Cursor::Type::Arrow;
1287 AutoLayout m_autoLayout = AutoLayout::Manual;
1288 bool m_autoLayoutUpdateEnabled = true;
1289 bool m_ignoreMouseEvents = false;
1290
1291 // Cached renderer properties
1292 Font m_fontCached = Font::getGlobalFont();
1293 float m_opacityCached = 1;
1294 bool m_transparentTextureCached = false;
1295 unsigned int m_textSizeCached = 0;
1296
1298
1299 friend class Container; // Container accesses save and load functions
1300 };
1301
1303}
1304
1306
1307#endif // TGUI_WIDGET_HPP
Base class for the Gui.
Definition BackendGui.hpp:47
Base class for render targets.
Definition BackendRenderTarget.hpp:48
Container widget.
Definition Container.hpp:49
Type
List of available cursors.
Definition Cursor.hpp:51
Wrapper for durations.
Definition Duration.hpp:56
Wrapper around the backend-specific font. All copies of the font will share the same internal font re...
Definition Font.hpp:61
Class to store the position or size of a widget.
Definition Layout.hpp:328
Class to store the left, top, width or height of a widget.
Definition Layout.hpp:93
Signal to which the user can subscribe to get callbacks from.
Definition Signal.hpp:1051
Signal to which the user can subscribe to get callbacks from.
Definition Signal.hpp:62
Signal to which the user can subscribe to get callbacks from.
Definition Signal.hpp:941
Wrapper class to store strings.
Definition String.hpp:101
The parent class for every widget.
Definition Widget.hpp:84
virtual TGUI_NODISCARD Vector2f getFullSize() const
Returns the entire size that the widget is using.
void showWithEffect(ShowEffectType type, Duration duration)
Shows the widget by introducing it with an animation.
void setSize(Layout width, Layout height)
Changes the size of the widget.
Definition Widget.hpp:230
void moveToFront()
Places the widget before all other widgets.
void setTextSize(unsigned int size)
Changes the character size of text in this widget if it uses text.
Layout2d m_size
Stores the size of this widget.
Definition Widget.hpp:1214
TGUI_NODISCARD bool isFocused() const
Returns true when the widget is focused and false otherwise.
Definition Widget.hpp:583
void setHeight(Layout height)
Changes the height of the widget.
Definition Widget.hpp:256
virtual TGUI_NODISCARD Widget::Ptr clone() const =0
Makes a copy of the widget if you don't know its exact type.
Layout2d m_position
Stores the position of this widget.
Definition Widget.hpp:1209
TGUI_NODISCARD bool getIgnoreMouseEvents() const
Returns whether the widget is ignoring mouse events and letting them pass to the widgets behind it.
TGUI_NODISCARD Widget::Ptr getNavigationUp() const
Returns which widget would become focused when navigating upwards from this widget.
TGUI_NODISCARD Widget::Ptr getNavigationDown() const
Returns which widget would become focused when navigating downwards from this widget.
void recalculateBoundPositionLayouts()
Calls recalculateValue() on each layout in m_boundPositionLayouts.
void resizeWithAnimation(Layout2d size, Duration duration)
Resizes the widget from its current size to the given size, over a given duration.
virtual TGUI_NODISCARD bool isMouseOnWidget(Vector2f pos) const =0
Returns whether the mouse position (which is relative to the parent widget) lies on top of the widget...
void setScale(float scaleFactor, Vector2f origin)
Sets the scaling to be applied to the widget.
Definition Widget.hpp:405
TGUI_NODISCARD Cursor::Type getMouseCursor() const
Returns which mouse cursor is shown when hovering over the widget.
void setScale(Vector2f scaleFactors, Vector2f origin)
Sets the scaling to be applied to the widget.
void setScale(Vector2f scaleFactors)
Sets the scaling to be applied to the widget.
TGUI_NODISCARD Vector2f getPosition() const
Gets the position of the widget.
Definition Widget.hpp:198
void setFocusable(bool focusable)
Changes whether a widget could be focused.
TGUI_NODISCARD bool isFocusable() const
Returns whether a widget could be focused.
void setNavigationRight(const Widget::Ptr &widgetRight)
Changes which widget should become focused when navigating to the right from this widget.
void setOrigin(float x, float y)
Sets the origin point on which the position, scale and rotation is based.
Definition Widget.hpp:327
virtual void draw(BackendRenderTarget &target, RenderStates states) const =0
Draw the widget to a render target.
TGUI_NODISCARD Vector2f getScaleOrigin() const
Returns the origin used for scaling.
TGUI_NODISCARD String getWidgetName() const
Returns the name of a widget.
virtual TGUI_NODISCARD bool canGainFocus() const
Returns whether the widget can currently gain focus.
TGUI_NODISCARD unsigned int getTextSize() const
Returns the character size of text in this widget.
void setNavigationUp(const Widget::Ptr &widgetAbove)
Changes which widget should become focused when navigating upwards from this widget.
void setRotation(float angle, Vector2f origin)
Sets the rotation to be applied to the widget.
TGUI_NODISCARD bool isVisible() const
Returns true when the widget is visible.
Definition Widget.hpp:541
TGUI_NODISCARD std::shared_ptr< const WidgetType > cast() const
Downcast const widget.
Definition Widget.hpp:1102
TGUI_NODISCARD DataType getUserData() const
Returns data stored in the widget.
Definition Widget.hpp:657
TGUI_NODISCARD bool isEnabled() const
Returns true when the widget is enabled.
Definition Widget.hpp:563
virtual void mouseEnteredWidget()
This function is called when the mouse enters the widget.
TGUI_NODISCARD bool isContainer() const
Returns whether the widget is a container widget or not.
void setAutoLayout(AutoLayout layout)
Sets how the position is determined compared to the other widgets in the parent.
TGUI_NODISCARD const Font & getInheritedFont() const
Returns the font of the widget that is used when no font is set in the renderer.
void setWidth(Layout width)
Changes the width of the widget.
Definition Widget.hpp:243
virtual void mouseLeftWidget()
This function is called when the mouse leaves the widget.
virtual void rendererChanged(const String &property)
Function called when one of the properties of the renderer is changed.
void moveToBack()
Places the widget behind all other widgets.
virtual TGUI_NODISCARD std::unique_ptr< DataIO::Node > save(SavingRenderersMap &renderers) const
Saves the widget as a tree node in order to save it to a file.
TGUI_NODISCARD Widget::Ptr getNavigationLeft() const
Returns which widget would become focused when navigating to the left from this widget.
TGUI_NODISCARD bool isMouseDown() const
Returns whether the left mouse button has been pressed on top of the widget.
Widget(Widget &&) noexcept
Move constructor.
virtual TGUI_NODISCARD Vector2f getWidgetOffset() const
Returns the distance between the position where the widget is drawn and where the widget is placed.
Widget(const Widget &)
Copy constructor.
virtual void load(const std::unique_ptr< DataIO::Node > &node, const LoadingRenderersMap &renderers)
Loads the widget from a tree of nodes.
std::shared_ptr< const Widget > ConstPtr
Shared constant widget pointer.
Definition Widget.hpp:88
std::shared_ptr< Widget > Ptr
Shared widget pointer.
Definition Widget.hpp:87
virtual bool scrolled(float delta, Vector2f pos, bool touch)
Called by the parent on scroll event (either from mouse wheel of from two finger scrolling on a touch...
TGUI_NODISCARD Vector2f getSize() const
Returns the size of the widget.
Definition Widget.hpp:266
void setWidgetName(const String &name)
Changes the name of a widget.
TGUI_NODISCARD Vector2f getOrigin() const
Returns the relative origin point on which the position, scale and rotation is based.
Definition Widget.hpp:347
TGUI_NODISCARD Vector2f getRotationOrigin() const
Returns the origin used for rotations.
virtual void setSize(const Layout2d &size)
Changes the size of the widget.
virtual bool canHandleKeyPress(const Event::KeyEvent &event)
Called by the parent of the widget to check if keyPressed would process the event.
void finishAllAnimations()
Makes all animations of the widget finish immediately.
TGUI_NODISCARD BackendGui * getParentGui() const
Returns a pointer to the gui to which this widget belongs.
Definition Widget.hpp:610
TGUI_NODISCARD Widget::Ptr getNavigationRight() const
Returns which widget would become focused when navigating to the right from this widget.
TGUI_NODISCARD Widget::Ptr getToolTip() const
Returns the tool tip that is displayed when hovering over the widget.
TGUI_NODISCARD const String & getWidgetType() const
Returns the type of the widget.
void setMouseCursor(Cursor::Type cursor)
Changes which mouse cursor is shown when hovering over the widget.
virtual bool leftMousePressed(Vector2f pos)
Called by the parent when the left mouse button goes down on top of the widget.
TGUI_NODISCARD bool hasUserData() const
Returns whether data stored in the widget.
Definition Widget.hpp:666
virtual void setFocused(bool focused)
Focus or unfocus the widget.
TGUI_NODISCARD float getRotation() const
Returns the rotation to be applied to the widget.
Definition Widget.hpp:456
void setIgnoreMouseEvents(bool ignore)
Sets whether the widget should completely ignore mouse events and let them pass to the widgets behind...
virtual void setVisible(bool visible)
Shows or hides a widget.
void setScale(float scaleFactor)
Sets the scaling to be applied to the widget.
Definition Widget.hpp:389
void setInheritedOpacity(float opacity)
Sets the opacity of the widget that will be multiplied with the opacity set in the renderer.
TGUI_NODISCARD float getInheritedOpacity() const
Returns the opacity of the widget that is multiplied with the opacity set in the renderer.
void setRotation(float angle)
Sets the rotation to be applied to the widget.
TGUI_NODISCARD AutoLayout getAutoLayout() const
Returns how the position is determined compared to the other widgets in the parent.
void setNavigationLeft(const Widget::Ptr &widgetLeft)
Changes which widget should become focused when navigating to the left from this widget.
TGUI_NODISCARD Container * getParent() const
Returns a pointer to the parent widget.
Definition Widget.hpp:600
TGUI_NODISCARD std::shared_ptr< WidgetType > cast()
Downcast widget.
Definition Widget.hpp:1111
void setUserData(Any userData)
Stores some data into the widget.
Definition Widget.hpp:646
void setToolTip(Widget::Ptr toolTip)
Sets the tool tip that should be displayed when hovering over the widget.
void setInheritedFont(const Font &font)
Sets the font of the widget that is used when no font is set in the renderer.
void moveWithAnimation(Layout2d position, Duration duration)
Moves the widget from its current position to the given position, over a given duration.
TGUI_NODISCARD Vector2f getScale() const
Returns the scaling to be applied to the widget.
Definition Widget.hpp:415
virtual TGUI_NODISCARD Signal & getSignal(String signalName)
Retrieves a signal based on its name.
void setNavigationDown(const Widget::Ptr &widgetBelow)
Changes which widget should become focused when navigating downwards from this widget.
void setOrigin(Vector2f origin)
Sets the origin point on which the position, scale and rotation is based.
virtual void setEnabled(bool enabled)
Enables or disables the widget.
virtual TGUI_NODISCARD Vector2f getAbsolutePosition(Vector2f offset={}) const
Get the absolute position of the widget instead of the relative position to its parent.
void recalculateBoundSizeLayouts()
Calls recalculateValue() on each layout in m_boundSizeLayouts.
void hideWithEffect(ShowEffectType type, Duration duration)
Hides the widget by making it leave with an animation.
TGUI_NODISCARD bool isAnimationPlaying() const
Returns whether there is an active animation (started with showWithEffect or hideWithEffect)
Base class for all renderer classes.
Definition WidgetRenderer.hpp:72
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:39
ShowEffectType
Type of effect to show/hide widget.
Definition Animation.hpp:47
AutoLayout
Alignments for how to position a widget in its parent.
Definition Layout.hpp:76
KeyPressed event parameters.
Definition Event.hpp:169
MouseButton
Mouse buttons.
Definition Event.hpp:150
States used for drawing.
Definition RenderStates.hpp:39
Shared data used in renderer classes.
Definition WidgetRenderer.hpp:50