LeechCraft  %{LEECHCRAFT_VERSION}
Modular cross-platform feature rich live environment.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
LeechCraft::Util::AutoResizeMixin Class Reference

Automatically moves a widget to fit a rectangle on resize. More...

#include "autoresizemixin.h"

+ Inheritance diagram for LeechCraft::Util::AutoResizeMixin:
+ Collaboration diagram for LeechCraft::Util::AutoResizeMixin:

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...
 

Detailed Description

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.

Member Typedef Documentation

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.

Constructor & Destructor Documentation

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.

Parameters
[in]pointThe point near which the widget should be shown.
[in]rectThe functor returning the rectangle into which the widget should be fitted.
[in]widgetThe widget to fit.

Definition at line 40 of file autoresizemixin.cpp.

Member Function Documentation

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.


The documentation for this class was generated from the following files: