![]() |
LeechCraft
%{LEECHCRAFT_VERSION}
Modular cross-platform feature rich live environment.
|
Automatically moves a widget to fit a rectangle on resize. More...
#include "autoresizemixin.h"
Public Types | |
typedef std::function< QRect()> | RectGetter_f |
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... | |
bool | eventFilter (QObject *, QEvent *) |
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.
Definition at line 66 of file autoresizemixin.h.
typedef std::function<QRect ()> LeechCraft::Util::AutoResizeMixin::RectGetter_f |
A function type used to get the rect to fit widget in.
Definition at line 73 of file autoresizemixin.h.
LeechCraft::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 40 of file autoresizemixin.cpp.
bool LeechCraft::Util::AutoResizeMixin::eventFilter | ( | QObject * | , |
QEvent * | event | ||
) |
Listens for resize events and refits the widget.
Definition at line 51 of file autoresizemixin.cpp.
References LeechCraft::Util::Resize.