diff --git a/AdvancedDockingSystem/res/ads.qrc b/AdvancedDockingSystem/res/ads.qrc index c862541..e3dd656 100644 --- a/AdvancedDockingSystem/res/ads.qrc +++ b/AdvancedDockingSystem/res/ads.qrc @@ -1,17 +1,5 @@ - img/dnd-thumbnail.png - img/dock-bottom.png - img/dock-center.png - img/dock-left.png - img/dock-right.png - img/dock-top.png - img/split-bottom.png - img/split-left.png - img/split-right.png - img/split-top.png - img/splitter-horizontal.png - img/splitter-vertical.png stylesheets/default-windows.css stylesheets/vendor-partsolutions.css stylesheets/modern-windows.css diff --git a/AdvancedDockingSystem/res/img/dnd-thumbnail.png b/AdvancedDockingSystem/res/img/dnd-thumbnail.png deleted file mode 100644 index 9b3bdc2..0000000 Binary files a/AdvancedDockingSystem/res/img/dnd-thumbnail.png and /dev/null differ diff --git a/AdvancedDockingSystem/res/img/dock-bottom.png b/AdvancedDockingSystem/res/img/dock-bottom.png deleted file mode 100644 index 54144b6..0000000 Binary files a/AdvancedDockingSystem/res/img/dock-bottom.png and /dev/null differ diff --git a/AdvancedDockingSystem/res/img/dock-center.png b/AdvancedDockingSystem/res/img/dock-center.png deleted file mode 100644 index 7b510b3..0000000 Binary files a/AdvancedDockingSystem/res/img/dock-center.png and /dev/null differ diff --git a/AdvancedDockingSystem/res/img/dock-left.png b/AdvancedDockingSystem/res/img/dock-left.png deleted file mode 100644 index 737f1ee..0000000 Binary files a/AdvancedDockingSystem/res/img/dock-left.png and /dev/null differ diff --git a/AdvancedDockingSystem/res/img/dock-right.png b/AdvancedDockingSystem/res/img/dock-right.png deleted file mode 100644 index afed2e8..0000000 Binary files a/AdvancedDockingSystem/res/img/dock-right.png and /dev/null differ diff --git a/AdvancedDockingSystem/res/img/dock-top.png b/AdvancedDockingSystem/res/img/dock-top.png deleted file mode 100644 index e5789c6..0000000 Binary files a/AdvancedDockingSystem/res/img/dock-top.png and /dev/null differ diff --git a/AdvancedDockingSystem/res/img/split-bottom.png b/AdvancedDockingSystem/res/img/split-bottom.png deleted file mode 100644 index 9829f1f..0000000 Binary files a/AdvancedDockingSystem/res/img/split-bottom.png and /dev/null differ diff --git a/AdvancedDockingSystem/res/img/split-left.png b/AdvancedDockingSystem/res/img/split-left.png deleted file mode 100644 index eff4639..0000000 Binary files a/AdvancedDockingSystem/res/img/split-left.png and /dev/null differ diff --git a/AdvancedDockingSystem/res/img/split-right.png b/AdvancedDockingSystem/res/img/split-right.png deleted file mode 100644 index 6a11acf..0000000 Binary files a/AdvancedDockingSystem/res/img/split-right.png and /dev/null differ diff --git a/AdvancedDockingSystem/res/img/split-top.png b/AdvancedDockingSystem/res/img/split-top.png deleted file mode 100644 index cd089da..0000000 Binary files a/AdvancedDockingSystem/res/img/split-top.png and /dev/null differ diff --git a/AdvancedDockingSystem/res/img/splitter-horizontal.png b/AdvancedDockingSystem/res/img/splitter-horizontal.png deleted file mode 100644 index a10a87b..0000000 Binary files a/AdvancedDockingSystem/res/img/splitter-horizontal.png and /dev/null differ diff --git a/AdvancedDockingSystem/res/img/splitter-vertical.png b/AdvancedDockingSystem/res/img/splitter-vertical.png deleted file mode 100644 index f051691..0000000 Binary files a/AdvancedDockingSystem/res/img/splitter-vertical.png and /dev/null differ diff --git a/AdvancedDockingSystem/src/DropOverlay.cpp b/AdvancedDockingSystem/src/DropOverlay.cpp index ca112b6..e846a94 100644 --- a/AdvancedDockingSystem/src/DropOverlay.cpp +++ b/AdvancedDockingSystem/src/DropOverlay.cpp @@ -14,12 +14,104 @@ ADS_NAMESPACE_BEGIN // Helper ///////////////////////////////////////////////////////////// -static QWidget* createDropWidget(const QString& img) +static QPixmap createDropIndicatorPixmap(const QPalette& pal, const QSizeF& size, DropArea dropArea) { - QLabel* label = new QLabel(); - label->setObjectName("DropAreaLabel"); - label->setPixmap(QPixmap(img)); - return label; + const QColor borderColor = pal.color(QPalette::Active, QPalette::Highlight); + const QColor backgroundColor = pal.color(QPalette::Active, QPalette::Base); + const QColor areaBackgroundColor = pal.color(QPalette::Active, QPalette::Highlight).lighter(150); + + QPixmap pm(size.width(), size.height()); + pm.fill(QColor(0, 0, 0, 0)); + + QPainter p(&pm); + QPen pen = p.pen(); + QRectF baseRect(pm.rect()); + + // Fill + p.fillRect(baseRect, backgroundColor); + + // Drop area rect. + if (true) + { + p.save(); + QRectF areaRect; + QLineF areaLine; + QLinearGradient gradient; + switch (dropArea) + { + case TopDropArea: + areaRect = QRectF(baseRect.x(), baseRect.y(), baseRect.width(), baseRect.height() * .5f); + areaLine = QLineF(areaRect.bottomLeft(), areaRect.bottomRight()); + gradient.setStart(areaRect.topLeft()); + gradient.setFinalStop(areaRect.bottomLeft()); + gradient.setColorAt(0.f, areaBackgroundColor); + gradient.setColorAt(1.f, areaBackgroundColor.lighter(120)); + break; + case RightDropArea: + areaRect = QRectF(baseRect.width() * .5f, baseRect.y(), baseRect.width() * .5f, baseRect.height()); + areaLine = QLineF(areaRect.topLeft(), areaRect.bottomLeft()); + gradient.setStart(areaRect.topLeft()); + gradient.setFinalStop(areaRect.topRight()); + gradient.setColorAt(0.f, areaBackgroundColor.lighter(120)); + gradient.setColorAt(1.f, areaBackgroundColor); + break; + case BottomDropArea: + areaRect = QRectF(baseRect.x(), baseRect.height() * .5f, baseRect.width(), baseRect.height() * .5f); + areaLine = QLineF(areaRect.topLeft(), areaRect.topRight()); + gradient.setStart(areaRect.topLeft()); + gradient.setFinalStop(areaRect.bottomLeft()); + gradient.setColorAt(0.f, areaBackgroundColor.lighter(120)); + gradient.setColorAt(1.f, areaBackgroundColor); + break; + case LeftDropArea: + areaRect = QRectF(baseRect.x(), baseRect.y(), baseRect.width() * .5f, baseRect.height()); + areaLine = QLineF(areaRect.topRight(), areaRect.bottomRight()); + gradient.setStart(areaRect.topLeft()); + gradient.setFinalStop(areaRect.topRight()); + gradient.setColorAt(0.f, areaBackgroundColor); + gradient.setColorAt(1.f, areaBackgroundColor.lighter(120)); + break; + case CenterDropArea: + break; + } + if (areaRect.isValid()) + { + p.fillRect(areaRect, gradient); + + pen = p.pen(); + pen.setColor(borderColor); + pen.setStyle(Qt::DashLine); + p.setPen(pen); + p.drawLine(areaLine); + } + p.restore(); + } + + // Border + if (true) + { + p.save(); + pen = p.pen(); + pen.setColor(borderColor); + pen.setWidth(1); + + p.setPen(pen); + p.drawRect(baseRect.adjusted(0, 0, -pen.width(), -pen.width())); + p.restore(); + } + return pm; +} + +static QWidget* createDropIndicatorWidget(DropArea dropArea) +{ + QLabel* l = new QLabel(); + l->setObjectName("DropAreaLabel"); + + const qreal metric = static_cast(l->fontMetrics().height()) * 2.f; + const QSizeF size(metric, metric); + + l->setPixmap(createDropIndicatorPixmap(l->palette(), size, dropArea)); + return l; } /////////////////////////////////////////////////////////////////////// @@ -42,11 +134,11 @@ DropOverlay::DropOverlay(QWidget* parent) : // Cross with default drop area widgets. QHash areaWidgets; - areaWidgets.insert(ADS_NS::TopDropArea, createDropWidget(":/img/split-top.png")); - areaWidgets.insert(ADS_NS::RightDropArea, createDropWidget(":/img/split-right.png")); - areaWidgets.insert(ADS_NS::BottomDropArea, createDropWidget(":/img/split-bottom.png")); - areaWidgets.insert(ADS_NS::LeftDropArea, createDropWidget(":/img/split-left.png")); - areaWidgets.insert(ADS_NS::CenterDropArea, createDropWidget(":/img/dock-center.png")); + areaWidgets.insert(ADS_NS::TopDropArea, createDropIndicatorWidget(TopDropArea)); //createDropWidget(":/img/split-top.png")); + areaWidgets.insert(ADS_NS::RightDropArea, createDropIndicatorWidget(RightDropArea));//createDropWidget(":/img/split-right.png")); + areaWidgets.insert(ADS_NS::BottomDropArea, createDropIndicatorWidget(BottomDropArea));//createDropWidget(":/img/split-bottom.png")); + areaWidgets.insert(ADS_NS::LeftDropArea, createDropIndicatorWidget(LeftDropArea));//createDropWidget(":/img/split-left.png")); + areaWidgets.insert(ADS_NS::CenterDropArea, createDropIndicatorWidget(CenterDropArea));//createDropWidget(":/img/dock-center.png")); _cross->setAreaWidgets(areaWidgets); _cross->setVisible(false); diff --git a/README.md b/README.md index 738ba46..5b0d407 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,3 @@ This projects uses the [WTFPL license](http://www.wtfpl.net/) (Do **W**hat **T**he **F**uck You Want To **P**ublic **L**icense) Using it? Let us know by creating a [new issue](https://github.com/mfreiholz/qt-docks/issues/new) (You don't have to, of course). - -## Credits -- Drop indicator images from [Code Project Article](http://www.codeproject.com/Articles/140209/Building-a-Docking-Window-Management-Solution-in-W)