LeechCraft
0.6.70-15082-g543737046d
Modular cross-platform feature rich live environment.
|
Automatically moves a widget to fit a rectangle on resize. More...
#include "autoresizemixin.h"
Public Types | |
using | RectGetter_f = std::function< QRect()> |
A function type used to get the rect to fit widget in. More... | |
Public Member Functions | |
UTIL_GUI_API | AutoResizeMixin (const QPoint &point, RectGetter_f rect, QWidget *widget) |
Constructs the resize mixin. More... | |
UTIL_GUI_API | AutoResizeMixin (const QPoint &point, RectGetter_f rect, QWindow *window) |
Constructs the resize mixin. More... | |
bool | eventFilter (QObject *, QEvent *) override |
Listens for resize events and refits the widget. More... | |
Automatically moves a widget to fit a rectangle on resize.
An instance of this class manages a single widget and moves it automatically after the widget has been resized, so that it stays inside the given rectangle. The autoresize mixin never tries to resize the widget itself (despite the name perhaps).
This class also tries to keep a corner of the managed widget near a given point passed to the constructor. This is useful when the widget pops up in response to some mouse-initiated action so that it appears near the mouse cursor.
Most commonly this function is used to keep various popup widgets on screen, but it can also be used to prefer showing some popup inside the LeechCraft window, for example.
The rectangle into which the widget should be embedded is obtained via a functor returning the rectangle. The functor is invoked each time the widget is to be refit.
This class also supports Qt5's QWindow objects.
Definition at line 46 of file autoresizemixin.h.
using LC::Util::AutoResizeMixin::RectGetter_f = std::function<QRect ()> |
A function type used to get the rect to fit widget in.
Definition at line 54 of file autoresizemixin.h.
LC::Util::AutoResizeMixin::AutoResizeMixin | ( | const QPoint & | point, |
RectGetter_f | rect, | ||
QWidget * | widget | ||
) |
Constructs the resize mixin.
This function constructs the resize mixin managing the given widget, trying to fit it inside the rect, preferably with a corner of the widget sticking near the point.
[in] | point | The point near which the widget should be shown. |
[in] | rect | The functor returning the rectangle into which the widget should be fitted. |
[in] | widget | The widget to fit. |
Definition at line 23 of file autoresizemixin.cpp.
LC::Util::AutoResizeMixin::AutoResizeMixin | ( | const QPoint & | point, |
RectGetter_f | rect, | ||
QWindow * | window | ||
) |
Constructs the resize mixin.
This function constructs the resize mixin managing the given window, trying to fit it inside the rect, preferably with a corner of the window sticking near the point.
[in] | point | The point near which the window should be shown. |
[in] | rect | The functor returning the rectangle into which the window should be fitted. |
[in] | window | The widget to fit. |
Definition at line 33 of file autoresizemixin.cpp.
|
override |
Listens for resize events and refits the widget.
Definition at line 43 of file autoresizemixin.cpp.