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

66 lines
1.5 KiB
C
Raw Normal View History

2015-12-09 19:21:38 +08:00
#ifndef DROP_OVERLAY_H
#define DROP_OVERLAY_H
#include <QFrame>
#include <QRect>
2015-12-09 19:21:38 +08:00
#include "ads/API.h"
2015-12-09 19:21:38 +08:00
ADS_NAMESPACE_BEGIN
// 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(DropAreas areas, QWidget* parent);
2015-12-09 19:21:38 +08:00
virtual ~DropOverlay();
void setFullAreaDropEnabled(bool enabled) { _fullAreaDrop = enabled; }
2015-12-09 19:21:38 +08:00
DropArea cursorLocation() const;
protected:
virtual void paintEvent(QPaintEvent *e);
virtual void resizeEvent(QResizeEvent* e);
virtual void moveEvent(QMoveEvent* e);
private:
class DropSplitAreas* _splitAreas;
bool _fullAreaDrop;
2015-12-09 19:21:38 +08:00
};
// AbstractDropAreas is used as base for drop area indicator widgets.
class AbstractDropAreas : public QWidget
{
public:
AbstractDropAreas(QWidget* parent) : QWidget(parent) {}
virtual DropArea cursorLocation() const = 0;
};
// DropSplitAreas shows a cross with 5 different drop area possibilities.
class DropSplitAreas : public AbstractDropAreas
{
Q_OBJECT
public:
DropSplitAreas(DropAreas areas, QWidget* parent);
2015-12-09 19:21:38 +08:00
virtual DropArea cursorLocation() const;
private:
QWidget* _top;
QWidget* _right;
QWidget* _bottom;
QWidget* _left;
QWidget* _center;
};
DropArea showDropOverlay(QWidget* parent, DropAreas areas = DropArea::AllAreas);
void showDropOverlay(QWidget* parent, const QRect& areaRect, DropAreas areas = DropArea::AllAreas);
2015-12-09 19:21:38 +08:00
void hideDropOverlay();
ADS_NAMESPACE_END
#endif