Qt-Advanced-Docking-System/AdvancedDockingSystem/include/ads/DropOverlay.h

64 lines
1.4 KiB
C
Raw Normal View History

2015-12-09 19:21:38 +08:00
#ifndef DROP_OVERLAY_H
#define DROP_OVERLAY_H
#include <QPointer>
#include <QRect>
#include <QFrame>
2015-12-09 19:21:38 +08:00
#include "ads/API.h"
2015-12-09 19:21:38 +08:00
ADS_NAMESPACE_BEGIN
class DropSplitAreas;
2015-12-09 19:21:38 +08:00
// DropOverlay paints a translucent rectangle over another widget.
// It can also show different types of drop area indicators.
class DropOverlay : public QFrame
{
Q_OBJECT
public:
DropOverlay(QWidget* parent);
2015-12-09 19:21:38 +08:00
virtual ~DropOverlay();
void setDropAreas(DropAreas areas);
void setFullAreaDropEnabled(bool enabled) { _fullAreaDrop = enabled; }
2015-12-09 19:21:38 +08:00
DropArea cursorLocation() const;
DropArea showDropOverlay(QWidget* target, DropAreas areas = AllAreas);
void showDropOverlay(QWidget* target, const QRect& targetAreaRect, DropAreas areas = AllAreas);
void hideDropOverlay();
2015-12-09 19:21:38 +08:00
protected:
virtual void paintEvent(QPaintEvent *e);
virtual void resizeEvent(QResizeEvent* e);
virtual void moveEvent(QMoveEvent* e);
private:
DropSplitAreas* _splitAreas;
bool _fullAreaDrop;
2015-12-09 19:21:38 +08:00
QPointer<QWidget> _target;
QRect _targetRect;
DropArea _lastLocation;
2015-12-09 19:21:38 +08:00
};
// DropSplitAreas shows a cross with 5 different drop area possibilities.
class DropSplitAreas : public QWidget
2015-12-09 19:21:38 +08:00
{
Q_OBJECT
public:
DropSplitAreas(DropAreas areas, QWidget* parent);
DropArea cursorLocation() const;
2015-12-09 19:21:38 +08:00
private:
QWidget* _top;
QWidget* _right;
QWidget* _bottom;
QWidget* _left;
QWidget* _center;
};
ADS_NAMESPACE_END
#endif