2015-12-09 19:21:38 +08:00
|
|
|
#ifndef DROP_OVERLAY_H
|
|
|
|
#define DROP_OVERLAY_H
|
|
|
|
|
2016-04-15 14:21:23 +08:00
|
|
|
#include <QPointer>
|
2016-02-01 17:55:45 +08:00
|
|
|
#include <QRect>
|
2016-02-26 19:43:14 +08:00
|
|
|
#include <QFrame>
|
2015-12-09 19:21:38 +08:00
|
|
|
|
2016-02-02 22:01:48 +08:00
|
|
|
#include "ads/API.h"
|
2015-12-09 19:21:38 +08:00
|
|
|
|
|
|
|
ADS_NAMESPACE_BEGIN
|
2016-02-26 19:43:14 +08:00
|
|
|
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:
|
2016-04-15 14:21:23 +08:00
|
|
|
DropOverlay(QWidget* parent);
|
2015-12-09 19:21:38 +08:00
|
|
|
virtual ~DropOverlay();
|
2016-04-15 14:21:23 +08:00
|
|
|
|
|
|
|
void setDropAreas(DropAreas areas);
|
2016-02-03 17:50:34 +08:00
|
|
|
void setFullAreaDropEnabled(bool enabled) { _fullAreaDrop = enabled; }
|
2015-12-09 19:21:38 +08:00
|
|
|
DropArea cursorLocation() const;
|
|
|
|
|
2016-04-15 14:21:23 +08:00
|
|
|
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:
|
2016-02-26 19:43:14 +08:00
|
|
|
DropSplitAreas* _splitAreas;
|
2016-02-03 17:50:34 +08:00
|
|
|
bool _fullAreaDrop;
|
2015-12-09 19:21:38 +08:00
|
|
|
|
2016-04-15 14:21:23 +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.
|
2016-04-15 14:21:23 +08:00
|
|
|
class DropSplitAreas : public QWidget
|
2015-12-09 19:21:38 +08:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2016-02-03 17:50:34 +08:00
|
|
|
DropSplitAreas(DropAreas areas, QWidget* parent);
|
2016-04-15 14:21:23 +08:00
|
|
|
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
|