--- --- 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#ifndef TGUI_WIDGET_HPP
26#define TGUI_WIDGET_HPP
27
29
30#include <TGUI/Signal.hpp>
31#include <TGUI/Font.hpp>
32#include <TGUI/Sprite.hpp>
33#include <TGUI/Layout.hpp>
34#include <TGUI/String.hpp>
35#include <TGUI/Vector2.hpp>
36#include <TGUI/Duration.hpp>
37#include <TGUI/Cursor.hpp>
38#include <TGUI/Event.hpp>
39#include <TGUI/Any.hpp>
40#include <TGUI/Backend/Renderer/BackendRenderTarget.hpp>
41#include <TGUI/Loading/Theme.hpp>
42#include <TGUI/Loading/DataIO.hpp>
43#include <TGUI/Loading/Serializer.hpp>
44#include <TGUI/Loading/Deserializer.hpp>
45#include <TGUI/Renderers/WidgetRenderer.hpp>
46
47#if TGUI_USE_SYSTEM_AURORA
48 #include <Aurora/SmartPtr/CopiedPtr.hpp>
49 #include <Aurora/Tools/Downcast.hpp>
50#else
51 #include <TGUI/extlibs/Aurora/SmartPtr/CopiedPtr.hpp>
52 #include <TGUI/extlibs/Aurora/Tools/Downcast.hpp>
53#endif
54
55#if !TGUI_EXPERIMENTAL_USE_STD_MODULE
56 #include <unordered_set>
57#endif
58
60
61TGUI_MODULE_EXPORT namespace tgui
62{
63 class BackendGui;
64 class Container;
65
66 enum class ShowEffectType;
67}
68
69namespace tgui
70{
71 namespace priv
72 {
73 class Animation;
74 }
75}
76
77TGUI_MODULE_EXPORT namespace tgui
78{
82 class TGUI_API Widget : public std::enable_shared_from_this<Widget>
83 {
84 public:
85
86 using Ptr = std::shared_ptr<Widget>;
87 using ConstPtr = std::shared_ptr<const Widget>;
88
96 Widget(const char* typeName, bool initRenderer);
97
101 Widget(const Widget&);
102
106 Widget(Widget&&) noexcept;
107
111 virtual ~Widget();
112
116 Widget& operator=(const Widget&);
117
121 Widget& operator=(Widget&&) noexcept;
122
130 void setRenderer(std::shared_ptr<RendererData> rendererData);
131
136 TGUI_NODISCARD virtual WidgetRenderer* getSharedRenderer();
137 TGUI_NODISCARD virtual const WidgetRenderer* getSharedRenderer() const;
138
144 TGUI_NODISCARD virtual WidgetRenderer* getRenderer();
145
171 virtual void setPosition(const Layout2d& position);
172
187 void setPosition(Layout x, Layout y)
188 {
189 setPosition({std::move(x), std::move(y)});
190 }
191
197 TGUI_NODISCARD Vector2f getPosition() const
198 {
199 return m_position.getValue();
200 }
201
219 virtual void setSize(const Layout2d& size);
220
229 void setSize(Layout width, Layout height)
230 {
231 setSize({std::move(width), std::move(height)});
232 }
233
242 void setWidth(Layout width)
243 {
244 setSize({std::move(width), m_size.y});
245 }
246
255 void setHeight(Layout height)
256 {
257 setSize({m_size.x, std::move(height)});
258 }
259
265 TGUI_NODISCARD Vector2f getSize() const
266 {
267 return m_size.getValue();
268 }
269
278 TGUI_NODISCARD virtual Vector2f getFullSize() const;
279
287 TGUI_NODISCARD virtual Vector2f getAbsolutePosition(Vector2f offset = {}) const;
288
296 TGUI_NODISCARD virtual Vector2f getWidgetOffset() const;
297
306
314 TGUI_NODISCARD AutoLayout getAutoLayout() const;
315
326 void setOrigin(float x, float y)
327 {
328 setOrigin({x, y});
329 }
330
340 void setOrigin(Vector2f origin);
341
346 TGUI_NODISCARD Vector2f getOrigin() const
347 {
348 return m_origin;
349 }
350
362 void setScale(Vector2f scaleFactors);
363
375 void setScale(Vector2f scaleFactors, Vector2f origin);
376
388 void setScale(float scaleFactor)
389 {
390 setScale({scaleFactor, scaleFactor});
391 }
392
404 void setScale(float scaleFactor, Vector2f origin)
405 {
406 setScale({scaleFactor, scaleFactor}, origin);
407 }
408
414 TGUI_NODISCARD Vector2f getScale() const
415 {
416 return m_scaleFactors;
417 }
418
424 TGUI_NODISCARD Vector2f getScaleOrigin() const;
425
436 void setRotation(float angle);
437
448 void setRotation(float angle, Vector2f origin);
449
455 TGUI_NODISCARD float getRotation() const
456 {
457 return m_rotationDeg;
458 }
459
465 TGUI_NODISCARD Vector2f getRotationOrigin() const;
466
486
506
513 void moveWithAnimation(Layout2d position, Duration duration);
514
522
530 virtual void setVisible(bool visible);
531
540 TGUI_NODISCARD bool isVisible() const
541 {
542 return m_visible;
543 }
544
552 virtual void setEnabled(bool enabled);
553
562 TGUI_NODISCARD bool isEnabled() const
563 {
564 return m_enabled;
565 }
566
575 virtual void setFocused(bool focused);
576
582 TGUI_NODISCARD bool isFocused() const
583 {
584 return m_focused;
585 }
586
592 TGUI_NODISCARD const String& getWidgetType() const;
593
599 TGUI_NODISCARD Container* getParent() const
600 {
601 return m_parent;
602 }
603
609 TGUI_NODISCARD BackendGui* getParentGui() const
610 {
611 return m_parentGui;
612 }
613
619 TGUI_NODISCARD bool isAnimationPlaying() const;
620
627
634
645 void setUserData(Any userData)
646 {
647 m_userData = std::move(userData);
648 }
649
655 template <typename DataType>
656 TGUI_NODISCARD DataType getUserData() const
657 {
658 return AnyCast<DataType>(m_userData);
659 }
660
665 TGUI_NODISCARD bool hasUserData() const
666 {
667 return m_userData.has_value();
668 }
669
678 void setInheritedFont(const Font& font);
679
685 TGUI_NODISCARD const Font& getInheritedFont() const;
686
695 void setInheritedOpacity(float opacity);
696
702 TGUI_NODISCARD float getInheritedOpacity() const;
703
711 void setTextSize(unsigned int size);
712
721 TGUI_NODISCARD unsigned int getTextSize() const;
722
728 void setToolTip(Widget::Ptr toolTip);
729
735 TGUI_NODISCARD Widget::Ptr getToolTip() const;
736
749 void setWidgetName(const String& name);
750
756 TGUI_NODISCARD String getWidgetName() const;
757
766
772 TGUI_NODISCARD Cursor::Type getMouseCursor() const;
773
781 void setFocusable(bool focusable);
782
790 TGUI_NODISCARD bool isFocusable() const;
791
801 void setNavigationUp(const Widget::Ptr& widgetAbove);
802
810 TGUI_NODISCARD Widget::Ptr getNavigationUp() const;
811
821 void setNavigationDown(const Widget::Ptr& widgetBelow);
822
830 TGUI_NODISCARD Widget::Ptr getNavigationDown() const;
831
841 void setNavigationLeft(const Widget::Ptr& widgetLeft);
842
850 TGUI_NODISCARD Widget::Ptr getNavigationLeft() const;
851
861 void setNavigationRight(const Widget::Ptr& widgetRight);
862
870 TGUI_NODISCARD Widget::Ptr getNavigationRight() const;
871
884 void setIgnoreMouseEvents(bool ignore);
885
893 TGUI_NODISCARD bool getIgnoreMouseEvents() const;
894
899
906 TGUI_NODISCARD virtual bool canGainFocus() const;
907
912 TGUI_NODISCARD bool isContainer() const;
913
918 TGUI_NODISCARD bool isMouseDown() const;
919
929 TGUI_NODISCARD virtual Signal& getSignal(String signalName);
930
936 virtual void setParent(Container* parent);
937
942 virtual bool updateTime(Duration elapsedTime);
943
948 void setAutoLayoutUpdateEnabled(bool enabled);
949
954 TGUI_NODISCARD virtual bool isMouseOnWidget(Vector2f pos) const = 0;
955
963 virtual bool leftMousePressed(Vector2f pos);
964
968 virtual void leftMouseReleased(Vector2f pos);
969
973 virtual void rightMousePressed(Vector2f pos);
974
978 virtual void rightMouseReleased(Vector2f pos);
979
983 virtual void mouseReleased(Event::MouseButton button, Vector2f pos);
984
988 virtual void mouseMoved(Vector2f pos);
989
993 virtual void keyPressed(const Event::KeyEvent& event);
994
1004 virtual bool canHandleKeyPress(const Event::KeyEvent& event);
1005
1009 virtual void textEntered(char32_t key);
1010
1020 virtual bool scrolled(float delta, Vector2f pos, bool touch);
1021
1025 virtual void mouseNoLongerOnWidget();
1026
1030 virtual void leftMouseButtonNoLongerDown();
1031
1035 virtual void rightMouseButtonNoLongerDown();
1036
1039 // Show the tool tip when the widget is located below the mouse.
1040 // Returns its tool tip or the tool tip from a child widget if the mouse is on top of the widget.
1041 // A nullptr is returned when the mouse is not on top of the widget or when the tool tip is empty.
1043 TGUI_NODISCARD virtual Widget::Ptr askToolTip(Vector2f mousePos);
1044
1049 TGUI_NODISCARD const Layout2d& getPositionLayout() const
1050 {
1051 return m_position;
1052 }
1053
1058 TGUI_NODISCARD const Layout2d& getSizeLayout() const
1059 {
1060 return m_size;
1061 }
1062
1067 void bindPositionLayout(Layout* layout);
1068
1073 void unbindPositionLayout(Layout* layout);
1074
1079 void bindSizeLayout(Layout* layout);
1080
1085 void unbindSizeLayout(Layout* layout);
1086
1095 virtual void draw(BackendRenderTarget& target, RenderStates states) const = 0;
1096
1100 template <typename WidgetType>
1101 TGUI_NODISCARD std::shared_ptr<const WidgetType> cast() const
1102 {
1103 return std::dynamic_pointer_cast<const WidgetType>(shared_from_this());
1104 }
1105
1109 template <typename WidgetType>
1110 TGUI_NODISCARD std::shared_ptr<WidgetType> cast()
1111 {
1112 return std::dynamic_pointer_cast<WidgetType>(shared_from_this());
1113 }
1114
1123 TGUI_NODISCARD virtual Widget::Ptr clone() const = 0;
1124
1129 void rendererChangedCallback(const String& property);
1130
1135 virtual void updateTextSize();
1136
1138 protected:
1139
1140 using SavingRenderersMap = std::map<const Widget*, std::pair<std::unique_ptr<DataIO::Node>, String>>;
1141 using LoadingRenderersMap = std::map<String, std::shared_ptr<RendererData>>;
1142
1148 virtual void rendererChanged(const String& property);
1149
1153 TGUI_NODISCARD virtual std::unique_ptr<DataIO::Node> save(SavingRenderersMap& renderers) const;
1154
1158 virtual void load(const std::unique_ptr<DataIO::Node>& node, const LoadingRenderersMap& renderers);
1159
1163 virtual void mouseEnteredWidget();
1164
1168 virtual void mouseLeftWidget();
1169
1174
1179
1181 public:
1182
1183 SignalVector2f onPositionChange = {"PositionChanged"};
1184 SignalVector2f onSizeChange = {"SizeChanged"};
1185 Signal onFocus = {"Focused"};
1186 Signal onUnfocus = {"Unfocused"};
1187 Signal onMouseEnter = {"MouseEntered"};
1188 Signal onMouseLeave = {"MouseLeft"};
1189 SignalShowEffect onShowEffectFinish = {"ShowEffectFinished"};
1190
1197 SignalAnimationType onAnimationFinish = {"AnimationFinished"};
1198
1200 protected:
1201
1202 String m_type;
1203 String m_name;
1204
1209
1214 unsigned int m_textSize = 0; // This may be overwritten by the renderer, m_textSizeCached contains the actual text size
1215
1216 Vector2f m_origin;
1217 Optional<Vector2f> m_rotationOrigin;
1218 Optional<Vector2f> m_scaleOrigin;
1219 Vector2f m_scaleFactors = {1, 1};
1220 float m_rotationDeg = 0;
1221
1222 // The previous position and size have to be stored because when setPosition/setSize is called, the layout may already be
1223 // changed and there would be no way for the widget to detect whether the values changed or not.
1224 Vector2f m_prevPosition;
1225 Vector2f m_prevSize;
1226
1227 // Layouts that need to recalculate their value when the position or size of this widget changes
1228 std::unordered_set<Layout*> m_boundPositionLayouts;
1229 std::unordered_set<Layout*> m_boundSizeLayouts;
1230
1236 bool m_enabled = true;
1237
1243 bool m_visible = true;
1244
1245 // This will point to our parent widget. If there is no parent then this will be nullptr.
1246 Container* m_parent = nullptr;
1247 BackendGui* m_parentGui = nullptr;
1248
1249 // Is the mouse on top of the widget? Did the mouse go down on the widget?
1250 bool m_mouseHover = false;
1251 bool m_mouseDown = false;
1252
1253 // Is the widget focused?
1254 bool m_focused = false;
1255
1256 // Can the widget be focused?
1257 bool m_focusable = true;
1258
1259 // Widgets that can be navigated to from this widgets with the arrow keys
1260 std::weak_ptr<Widget> m_navWidgetUp;
1261 std::weak_ptr<Widget> m_navWidgetDown;
1262 std::weak_ptr<Widget> m_navWidgetRight;
1263 std::weak_ptr<Widget> m_navWidgetLeft;
1264
1265 // Keep track of the elapsed time.
1266 Duration m_animationTimeElapsed;
1267
1268 // This is set to true for widgets that store other widgets inside them
1269 bool m_containerWidget = false;
1270
1271 // The tool tip connected to the widget
1272 Widget::Ptr m_toolTip = nullptr;
1273
1274 // Renderer of the widget
1275 aurora::CopiedPtr<WidgetRenderer> m_renderer = nullptr;
1276
1277 // Show animations
1278 std::vector<std::unique_ptr<priv::Animation>> m_showAnimations;
1279
1280 // Renderer properties that can be passed from containers to their children
1281 Font m_inheritedFont;
1282 float m_inheritedOpacity = 1;
1283
1284 Any m_userData;
1285 Cursor::Type m_mouseCursor = Cursor::Type::Arrow;
1286 AutoLayout m_autoLayout = AutoLayout::Manual;
1287 bool m_autoLayoutUpdateEnabled = true;
1288 bool m_ignoreMouseEvents = false;
1289
1290 // Cached renderer properties
1291 Font m_fontCached = Font::getGlobalFont();
1292 float m_opacityCached = 1;
1293 bool m_transparentTextureCached = false;
1294 unsigned int m_textSizeCached = 0;
1295
1297
1298 friend class Container; // Container accesses save and load functions
1299 };
1300
1302}
1303
1305
1306#endif // TGUI_WIDGET_HPP
Base class for the Gui.
Definition BackendGui.hpp:47
Base class for render targets.
Definition BackendRenderTarget.hpp:46
Container widget.
Definition Container.hpp:48
Type
List of available cursors.
Definition Cursor.hpp:50
Wrapper for durations.
Definition Duration.hpp:55
Wrapper around the backend-specific font. All copies of the font will share the same internal font re...
Definition Font.hpp:58
Class to store the position or size of a widget.
Definition Layout.hpp:313
Class to store the left, top, width or height of a widget.
Definition Layout.hpp:101
Signal to which the user can subscribe to get callbacks from.
Definition Signal.hpp:986
Signal to which the user can subscribe to get callbacks from.
Definition Signal.hpp:61
Signal to which the user can subscribe to get callbacks from.
Definition Signal.hpp:884
Wrapper class to store strings.
Definition String.hpp:96
The parent class for every widget.
Definition Widget.hpp:83
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:229
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:1213
TGUI_NODISCARD bool isFocused() const
Returns true when the widget is focused and false otherwise.
Definition Widget.hpp:582
void setHeight(Layout height)
Changes the height of the widget.
Definition Widget.hpp:255
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:1208
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:404
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:197
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:326
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:540
TGUI_NODISCARD std::shared_ptr< const WidgetType > cast() const
Downcast const widget.
Definition Widget.hpp:1101
TGUI_NODISCARD DataType getUserData() const
Returns data stored in the widget.
Definition Widget.hpp:656
TGUI_NODISCARD bool isEnabled() const
Returns true when the widget is enabled.
Definition Widget.hpp:562
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:242
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:87
std::shared_ptr< Widget > Ptr
Shared widget pointer.
Definition Widget.hpp:86
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:265
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:346
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:609
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:665
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:455
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:388
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:599
TGUI_NODISCARD std::shared_ptr< WidgetType > cast()
Downcast widget.
Definition Widget.hpp:1110
void setUserData(Any userData)
Stores some data into the widget.
Definition Widget.hpp:645
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:414
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:69
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:38
ShowEffectType
Type of effect to show/hide widget.
Definition Animation.hpp:46
AutoLayout
Alignments for how to position a widget in its parent.
Definition Layout.hpp:84
KeyPressed event parameters.
Definition Event.hpp:168
MouseButton
Mouse buttons.
Definition Event.hpp:149
States used for drawing.
Definition RenderStates.hpp:38
Shared data used in renderer classes.
Definition WidgetRenderer.hpp:48