TGUI  1.6.1
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
495
524
531 void moveWithAnimation(Layout2d position, Duration duration);
532
540
548 virtual void setVisible(bool visible);
549
558 TGUI_NODISCARD bool isVisible() const
559 {
560 return m_visible;
561 }
562
570 virtual void setEnabled(bool enabled);
571
580 TGUI_NODISCARD bool isEnabled() const
581 {
582 return m_enabled;
583 }
584
593 virtual void setFocused(bool focused);
594
600 TGUI_NODISCARD bool isFocused() const
601 {
602 return m_focused;
603 }
604
610 TGUI_NODISCARD const String& getWidgetType() const;
611
617 TGUI_NODISCARD Container* getParent() const
618 {
619 return m_parent;
620 }
621
627 TGUI_NODISCARD BackendGui* getParentGui() const
628 {
629 return m_parentGui;
630 }
631
637 TGUI_NODISCARD bool isAnimationPlaying() const;
638
645
652
663 void setUserData(Any userData)
664 {
665 m_userData = std::move(userData);
666 }
667
673 template <typename DataType>
674 TGUI_NODISCARD DataType getUserData() const
675 {
676 return AnyCast<DataType>(m_userData);
677 }
678
683 TGUI_NODISCARD bool hasUserData() const
684 {
685 return m_userData.has_value();
686 }
687
696 void setInheritedFont(const Font& font);
697
703 TGUI_NODISCARD const Font& getInheritedFont() const;
704
713 void setInheritedOpacity(float opacity);
714
720 TGUI_NODISCARD float getInheritedOpacity() const;
721
729 void setTextSize(unsigned int size);
730
739 TGUI_NODISCARD unsigned int getTextSize() const;
740
746 void setToolTip(Widget::Ptr toolTip);
747
753 TGUI_NODISCARD Widget::Ptr getToolTip() const;
754
767 void setWidgetName(const String& name);
768
774 TGUI_NODISCARD String getWidgetName() const;
775
784
790 TGUI_NODISCARD Cursor::Type getMouseCursor() const;
791
799 void setFocusable(bool focusable);
800
808 TGUI_NODISCARD bool isFocusable() const;
809
819 void setNavigationUp(const Widget::Ptr& widgetAbove);
820
828 TGUI_NODISCARD Widget::Ptr getNavigationUp() const;
829
839 void setNavigationDown(const Widget::Ptr& widgetBelow);
840
848 TGUI_NODISCARD Widget::Ptr getNavigationDown() const;
849
859 void setNavigationLeft(const Widget::Ptr& widgetLeft);
860
868 TGUI_NODISCARD Widget::Ptr getNavigationLeft() const;
869
879 void setNavigationRight(const Widget::Ptr& widgetRight);
880
888 TGUI_NODISCARD Widget::Ptr getNavigationRight() const;
889
902 void setIgnoreMouseEvents(bool ignore);
903
911 TGUI_NODISCARD bool getIgnoreMouseEvents() const;
912
917
924 TGUI_NODISCARD virtual bool canGainFocus() const;
925
930 TGUI_NODISCARD bool isContainer() const;
931
936 TGUI_NODISCARD bool isMouseDown() const;
937
947 TGUI_NODISCARD virtual Signal& getSignal(String signalName);
948
954 virtual void setParent(Container* parent);
955
960 virtual bool updateTime(Duration elapsedTime);
961
966 void setAutoLayoutUpdateEnabled(bool enabled);
967
972 TGUI_NODISCARD virtual bool isMouseOnWidget(Vector2f pos) const = 0;
973
981 virtual bool leftMousePressed(Vector2f pos);
982
986 virtual void leftMouseReleased(Vector2f pos);
987
991 virtual void rightMousePressed(Vector2f pos);
992
996 virtual void rightMouseReleased(Vector2f pos);
997
1001 virtual void mouseReleased(Event::MouseButton button, Vector2f pos);
1002
1006 virtual void mouseMoved(Vector2f pos);
1007
1011 virtual void keyPressed(const Event::KeyEvent& event);
1012
1022 virtual bool canHandleKeyPress(const Event::KeyEvent& event);
1023
1027 virtual void textEntered(char32_t key);
1028
1038 virtual bool scrolled(float delta, Vector2f pos, bool touch);
1039
1043 virtual void mouseNoLongerOnWidget();
1044
1048 virtual void leftMouseButtonNoLongerDown();
1049
1053 virtual void rightMouseButtonNoLongerDown();
1054
1057 // Show the tool tip when the widget is located below the mouse.
1058 // Returns its tool tip or the tool tip from a child widget if the mouse is on top of the widget.
1059 // A nullptr is returned when the mouse is not on top of the widget or when the tool tip is empty.
1061 TGUI_NODISCARD virtual Widget::Ptr askToolTip(Vector2f mousePos);
1062
1067 TGUI_NODISCARD const Layout2d& getPositionLayout() const
1068 {
1069 return m_position;
1070 }
1071
1076 TGUI_NODISCARD const Layout2d& getSizeLayout() const
1077 {
1078 return m_size;
1079 }
1080
1085 void bindPositionLayout(Layout* layout);
1086
1091 void unbindPositionLayout(Layout* layout);
1092
1097 void bindSizeLayout(Layout* layout);
1098
1103 void unbindSizeLayout(Layout* layout);
1104
1113 virtual void draw(BackendRenderTarget& target, RenderStates states) const = 0;
1114
1118 template <typename WidgetType>
1119 TGUI_NODISCARD std::shared_ptr<const WidgetType> cast() const
1120 {
1121 return std::dynamic_pointer_cast<const WidgetType>(shared_from_this());
1122 }
1123
1127 template <typename WidgetType>
1128 TGUI_NODISCARD std::shared_ptr<WidgetType> cast()
1129 {
1130 return std::dynamic_pointer_cast<WidgetType>(shared_from_this());
1131 }
1132
1141 TGUI_NODISCARD virtual Widget::Ptr clone() const = 0;
1142
1147 void rendererChangedCallback(const String& property);
1148
1153 virtual void updateTextSize();
1154
1156 protected:
1157
1158 using SavingRenderersMap = std::map<const Widget*, std::pair<std::unique_ptr<DataIO::Node>, String>>;
1159 using LoadingRenderersMap = std::map<String, std::shared_ptr<RendererData>>;
1160
1166 virtual void rendererChanged(const String& property);
1167
1171 TGUI_NODISCARD virtual std::unique_ptr<DataIO::Node> save(SavingRenderersMap& renderers) const;
1172
1176 virtual void load(const std::unique_ptr<DataIO::Node>& node, const LoadingRenderersMap& renderers);
1177
1181 virtual void mouseEnteredWidget();
1182
1186 virtual void mouseLeftWidget();
1187
1192
1197
1199 public:
1200
1201 SignalVector2f onPositionChange = {"PositionChanged"};
1202 SignalVector2f onSizeChange = {"SizeChanged"};
1203 Signal onFocus = {"Focused"};
1204 Signal onUnfocus = {"Unfocused"};
1205 Signal onMouseEnter = {"MouseEntered"};
1206 Signal onMouseLeave = {"MouseLeft"};
1207 SignalShowEffect onShowEffectFinish = {"ShowEffectFinished"};
1208
1215 SignalAnimationType onAnimationFinish = {"AnimationFinished"};
1216
1218 protected:
1219
1220 String m_type;
1221 String m_name;
1222
1227
1232 unsigned int m_textSize = 0; // This may be overwritten by the renderer, m_textSizeCached contains the actual text size
1233
1234 Vector2f m_origin;
1235 Optional<Vector2f> m_rotationOrigin;
1236 Optional<Vector2f> m_scaleOrigin;
1237 Vector2f m_scaleFactors = {1, 1};
1238 float m_rotationDeg = 0;
1239
1240 // The previous position and size have to be stored because when setPosition/setSize is called, the layout may already be
1241 // changed and there would be no way for the widget to detect whether the values changed or not.
1242 Vector2f m_prevPosition;
1243 Vector2f m_prevSize;
1244
1245 // Layouts that need to recalculate their value when the position or size of this widget changes
1246 std::unordered_set<Layout*> m_boundPositionLayouts;
1247 std::unordered_set<Layout*> m_boundSizeLayouts;
1248
1254 bool m_enabled = true;
1255
1261 bool m_visible = true;
1262
1263 // This will point to our parent widget. If there is no parent then this will be nullptr.
1264 Container* m_parent = nullptr;
1265 BackendGui* m_parentGui = nullptr;
1266
1267 // Is the mouse on top of the widget? Did the mouse go down on the widget?
1268 bool m_mouseHover = false;
1269 bool m_mouseDown = false;
1270
1271 // Is the widget focused?
1272 bool m_focused = false;
1273
1274 // Can the widget be focused?
1275 bool m_focusable = true;
1276
1277 // Widgets that can be navigated to from this widgets with the arrow keys
1278 std::weak_ptr<Widget> m_navWidgetUp;
1279 std::weak_ptr<Widget> m_navWidgetDown;
1280 std::weak_ptr<Widget> m_navWidgetRight;
1281 std::weak_ptr<Widget> m_navWidgetLeft;
1282
1283 // Keep track of the elapsed time.
1284 Duration m_animationTimeElapsed;
1285
1286 // This is set to true for widgets that store other widgets inside them
1287 bool m_containerWidget = false;
1288
1289 // The tool tip connected to the widget
1290 Widget::Ptr m_toolTip = nullptr;
1291
1292 // Renderer of the widget
1293 aurora::CopiedPtr<WidgetRenderer> m_renderer = nullptr;
1294
1295 // Show animations
1296 std::vector<std::unique_ptr<priv::Animation>> m_showAnimations;
1297
1298 // Renderer properties that can be passed from containers to their children
1299 Font m_inheritedFont;
1300 float m_inheritedOpacity = 1;
1301
1302 Any m_userData;
1303 Cursor::Type m_mouseCursor = Cursor::Type::Arrow;
1304 AutoLayout m_autoLayout = AutoLayout::Manual;
1305 bool m_autoLayoutUpdateEnabled = true;
1306 bool m_ignoreMouseEvents = false;
1307
1308 // Cached renderer properties
1309 Font m_fontCached = Font::getGlobalFont();
1310 float m_opacityCached = 1;
1311 bool m_transparentTextureCached = false;
1312 unsigned int m_textSizeCached = 0;
1313
1315
1316 friend class Container; // Container accesses save and load functions
1317 };
1318
1320}
1321
1323
1324#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:323
Class to store the left, top, width or height of a widget.
Definition Layout.hpp:102
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:884
Signal to which the user can subscribe to get callbacks from.
Definition Signal.hpp:61
Wrapper class to store strings.
Definition String.hpp:96
Base class for all renderer classes.
Definition WidgetRenderer.hpp:69
The parent class for every widget.
Definition Widget.hpp:83
void showWithEffect(ShowEffectType type, Duration duration)
Shows the widget by introducing it with an animation.
Widget::Ptr getNavigationUp() const
Returns which widget would become focused when navigating upwards from this widget.
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:1231
void setHeight(Layout height)
Changes the height of the widget.
Definition Widget.hpp:255
const String & getWidgetType() const
Returns the type of the widget.
Layout2d m_position
Stores the position of this widget.
Definition Widget.hpp:1226
std::shared_ptr< WidgetType > cast()
Downcast widget.
Definition Widget.hpp:1128
virtual Widget::Ptr clone() const =0
Makes a copy of the widget if you don't know its exact type.
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.
void setScale(float scaleFactor, Vector2f origin)
Sets the scaling to be applied to the widget.
Definition Widget.hpp:404
AutoLayout getAutoLayout() const
Returns how the position is determined compared to the other widgets in the parent.
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.
Vector2f getScale() const
Returns the scaling to be applied to the widget.
Definition Widget.hpp:414
void setFocusable(bool focusable)
Changes 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.
unsigned int getTextSize() const
Returns the character size of text in this widget.
DataType getUserData() const
Returns data stored in the widget.
Definition Widget.hpp:674
virtual bool canGainFocus() const
Returns whether the widget can currently gain focus.
String getWidgetName() const
Returns the name of a widget.
Container * getParent() const
Returns a pointer to the parent widget.
Definition Widget.hpp:617
Cursor::Type getMouseCursor() const
Returns which mouse cursor is shown when hovering over the widget.
void setNavigationUp(const Widget::Ptr &widgetAbove)
Changes which widget should become focused when navigating upwards from this widget.
bool isVisible() const
Returns true when the widget is visible.
Definition Widget.hpp:558
bool isFocusable() const
Returns whether a widget could be focused.
void setRotation(float angle, Vector2f origin)
Sets the rotation to be applied to the widget.
float getRotation() const
Returns the rotation to be applied to the widget.
Definition Widget.hpp:455
Vector2f getScaleOrigin() const
Returns the origin used for scaling.
bool isContainer() const
Returns whether the widget is a container widget or not.
virtual void mouseEnteredWidget()
This function is called when the mouse enters the widget.
void setAutoLayout(AutoLayout layout)
Sets how the position is determined compared to the other widgets in the parent.
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 std::unique_ptr< DataIO::Node > save(SavingRenderersMap &renderers) const
Saves the widget as a tree node in order to save it to a file.
Widget(Widget &&) noexcept
Move constructor.
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
virtual Signal & getSignal(String signalName)
Retrieves a signal based on its name.
Widget::Ptr getNavigationDown() const
Returns which widget would become focused when navigating downwards from this widget.
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...
bool isMouseDown() const
Returns whether the left mouse button has been pressed on top of the widget.
void setWidgetName(const String &name)
Changes the name of a widget.
Widget::Ptr getNavigationRight() const
Returns which widget would become focused when navigating to the right from this widget.
bool isAnimationPlaying() const
Returns whether there is an active animation (started with showWithEffect or hideWithEffect)
bool isEnabled() const
Returns true when the widget is enabled.
Definition Widget.hpp:580
Vector2f getOrigin() const
Returns the relative origin point on which the position, scale and rotation is based.
Definition Widget.hpp:346
virtual void setSize(const Layout2d &size)
Changes the size of the widget.
Vector2f getSize() const
Returns the size of the widget.
Definition Widget.hpp:265
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.
virtual bool isMouseOnWidget(Vector2f pos) const =0
Returns whether the mouse position (which is relative to the parent widget) lies on top of the widget...
Widget::Ptr getToolTip() const
Returns the tool tip that is displayed when hovering over the widget.
BackendGui * getParentGui() const
Returns a pointer to the gui to which this widget belongs.
Definition Widget.hpp:627
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.
virtual void setFocused(bool focused)
Focus or unfocus the widget.
virtual Vector2f getFullSize() const
Returns the entire size that the widget is using.
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.
bool getIgnoreMouseEvents() const
Returns whether the widget is ignoring mouse events and letting them pass to the widgets behind it.
void setRotation(float angle)
Sets the rotation to be applied to the widget.
void setNavigationLeft(const Widget::Ptr &widgetLeft)
Changes which widget should become focused when navigating to the left from this widget.
bool hasUserData() const
Returns whether data stored in the widget.
Definition Widget.hpp:683
void setUserData(Any userData)
Stores some data into the widget.
Definition Widget.hpp:663
Widget::Ptr getNavigationLeft() const
Returns which widget would become focused when navigating to the left from this widget.
void setToolTip(Widget::Ptr toolTip)
Sets the tool tip that should be displayed when hovering over the widget.
virtual Vector2f getAbsolutePosition(Vector2f offset={}) const
Get the absolute position of the widget instead of the relative position to its parent.
void setInheritedFont(const Font &font)
Sets the font of the widget that is used when no font is set in the renderer.
virtual Vector2f getWidgetOffset() const
Returns the distance between the position where the widget is drawn and where the widget is placed.
void moveWithAnimation(Layout2d position, Duration duration)
Moves the widget from its current position to the given position, over a given duration.
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.
std::shared_ptr< const WidgetType > cast() const
Downcast const widget.
Definition Widget.hpp:1119
virtual void setEnabled(bool enabled)
Enables or disables the widget.
void recalculateBoundSizeLayouts()
Calls recalculateValue() on each layout in m_boundSizeLayouts.
float getInheritedOpacity() const
Returns the opacity of the widget that is multiplied with the opacity set in the renderer.
Vector2f getPosition() const
Gets the position of the widget.
Definition Widget.hpp:197
void hideWithEffect(ShowEffectType type, Duration duration)
Hides the widget by making it leave with an animation.
Vector2f getRotationOrigin() const
Returns the origin used for rotations.
bool isFocused() const
Returns true when the widget is focused and false otherwise.
Definition Widget.hpp:600
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:85
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