mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-11-15 13:15:43 +08:00
refactor: Renames DropSplitAreas => DropOverlayCross
mod: Uses QPalette::Highlight color, instead of in-source fixed color, for area overlay painting.
This commit is contained in:
parent
0bd5dc57fa
commit
86c23c6269
@ -10,14 +10,14 @@ class QGridLayout;
|
||||
#include "ads/API.h"
|
||||
|
||||
ADS_NAMESPACE_BEGIN
|
||||
class DropSplitAreas;
|
||||
class DropOverlayCross;
|
||||
|
||||
// DropOverlay paints a translucent rectangle over another widget.
|
||||
// It can also show different types of drop area indicators.
|
||||
class DropOverlay : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
friend class DropSplitAreas;
|
||||
friend class DropOverlayCross;
|
||||
|
||||
public:
|
||||
DropOverlay(QWidget* parent);
|
||||
@ -41,7 +41,7 @@ protected:
|
||||
|
||||
private:
|
||||
DropAreas _allowedAreas;
|
||||
DropSplitAreas* _splitAreas;
|
||||
DropOverlayCross* _splitAreas;
|
||||
|
||||
bool _fullAreaDrop;
|
||||
QPointer<QWidget> _target;
|
||||
@ -50,12 +50,12 @@ private:
|
||||
};
|
||||
|
||||
// DropSplitAreas shows a cross with 5 different drop area possibilities.
|
||||
class DropSplitAreas : public QWidget
|
||||
class DropOverlayCross : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DropSplitAreas(DropOverlay* overlay);
|
||||
DropOverlayCross(DropOverlay* overlay);
|
||||
void reset();
|
||||
DropArea cursorLocation() const;
|
||||
void setWidgetForArea(QWidget* widget, DropArea area);
|
||||
|
@ -27,7 +27,7 @@ static QWidget* createDropWidget(const QString& img)
|
||||
DropOverlay::DropOverlay(QWidget* parent) :
|
||||
QFrame(parent),
|
||||
_allowedAreas(InvalidDropArea),
|
||||
_splitAreas(new DropSplitAreas(this)),
|
||||
_splitAreas(new DropOverlayCross(this)),
|
||||
_fullAreaDrop(false),
|
||||
_lastLocation(InvalidDropArea)
|
||||
{
|
||||
@ -46,8 +46,6 @@ DropOverlay::DropOverlay(QWidget* parent) :
|
||||
|
||||
DropOverlay::~DropOverlay()
|
||||
{
|
||||
delete _splitAreas;
|
||||
_splitAreas = NULL;
|
||||
}
|
||||
|
||||
void DropOverlay::setAllowedAreas(DropAreas areas)
|
||||
@ -143,13 +141,14 @@ void DropOverlay::hideDropOverlay()
|
||||
void DropOverlay::paintEvent(QPaintEvent*)
|
||||
{
|
||||
QPainter p(this);
|
||||
const QColor areaColor = palette().color(QPalette::Active, QPalette::Highlight);//QColor(0, 100, 255)
|
||||
|
||||
// Always draw drop-rect over the entire rect()
|
||||
if (_fullAreaDrop)
|
||||
{
|
||||
QRect r = rect();
|
||||
p.fillRect(r, QBrush(QColor(0, 100, 255), Qt::Dense4Pattern));
|
||||
p.setBrush(QBrush(QColor(0, 100, 255)));
|
||||
p.fillRect(r, QBrush(areaColor, Qt::Dense4Pattern));
|
||||
p.setBrush(QBrush(areaColor));
|
||||
p.drawRect(r);
|
||||
return;
|
||||
}
|
||||
@ -179,8 +178,8 @@ void DropOverlay::paintEvent(QPaintEvent*)
|
||||
}
|
||||
if (!r.isNull())
|
||||
{
|
||||
p.fillRect(r, QBrush(QColor(0, 100, 255), Qt::Dense4Pattern));
|
||||
p.setBrush(QBrush(QColor(0, 100, 255)));
|
||||
p.fillRect(r, QBrush(areaColor, Qt::Dense4Pattern));
|
||||
p.setBrush(QBrush(areaColor));
|
||||
p.drawRect(r);
|
||||
}
|
||||
|
||||
@ -216,7 +215,7 @@ void DropOverlay::moveEvent(QMoveEvent* e)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
DropSplitAreas::DropSplitAreas(DropOverlay* overlay) :
|
||||
DropOverlayCross::DropOverlayCross(DropOverlay* overlay) :
|
||||
QWidget(overlay->parentWidget()),
|
||||
_overlay(overlay),
|
||||
_widgets()
|
||||
@ -246,7 +245,7 @@ DropSplitAreas::DropSplitAreas(DropOverlay* overlay) :
|
||||
bl1->addStretch(1);
|
||||
}
|
||||
|
||||
void DropSplitAreas::reset()
|
||||
void DropOverlayCross::reset()
|
||||
{
|
||||
const DropAreas areas = _overlay->allowedAreas();
|
||||
|
||||
@ -276,7 +275,7 @@ void DropSplitAreas::reset()
|
||||
setWidgetForArea(NULL, ADS_NS::CenterDropArea);
|
||||
}
|
||||
|
||||
DropArea DropSplitAreas::cursorLocation() const
|
||||
DropArea DropOverlayCross::cursorLocation() const
|
||||
{
|
||||
const QPoint pos = mapFromGlobal(QCursor::pos());
|
||||
QHashIterator<DropArea, QWidget*> i(_widgets);
|
||||
@ -294,7 +293,7 @@ DropArea DropSplitAreas::cursorLocation() const
|
||||
return InvalidDropArea;
|
||||
}
|
||||
|
||||
void DropSplitAreas::setWidgetForArea(QWidget* widget, DropArea area)
|
||||
void DropOverlayCross::setWidgetForArea(QWidget* widget, DropArea area)
|
||||
{
|
||||
QWidget* oldWidget = _widgets.take(area);
|
||||
if (oldWidget)
|
||||
@ -327,7 +326,6 @@ void DropSplitAreas::setWidgetForArea(QWidget* widget, DropArea area)
|
||||
return;
|
||||
}
|
||||
_widgets.insert(area, widget);
|
||||
_grid->invalidate();
|
||||
|
||||
// if (area == ADS_NS::TopDropArea)
|
||||
// {
|
||||
@ -356,7 +354,7 @@ void DropSplitAreas::setWidgetForArea(QWidget* widget, DropArea area)
|
||||
// }
|
||||
}
|
||||
|
||||
void DropSplitAreas::showEvent(QShowEvent* e)
|
||||
void DropOverlayCross::showEvent(QShowEvent*)
|
||||
{
|
||||
resize(_overlay->size());
|
||||
move(_overlay->pos());
|
||||
|
Loading…
Reference in New Issue
Block a user