Skip to content

Commit c532c24

Browse files
author
Uwe Kindler
committed
Improved indicator pixmaps
1 parent c5ea5c8 commit c532c24

File tree

1 file changed

+86
-6
lines changed

1 file changed

+86
-6
lines changed

src/DockOverlay.cpp

Lines changed: 86 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
namespace ads
4242
{
4343
//============================================================================
44-
static QPixmap createDropIndicatorPixmap(const QPalette& pal, const QSizeF& size, DockWidgetArea DockWidgetArea)
44+
static QPixmap createDropIndicatorPixmap_old(const QPalette& pal, const QSizeF& size, DockWidgetArea DockWidgetArea)
4545
{
4646
QColor borderColor = pal.color(QPalette::Active, QPalette::Highlight);
4747
QColor backgroundColor = pal.color(QPalette::Active, QPalette::Base);
@@ -121,6 +121,87 @@ static QPixmap createDropIndicatorPixmap(const QPalette& pal, const QSizeF& size
121121
}
122122

123123

124+
//============================================================================
125+
static QPixmap createDropIndicatorPixmap(const QPalette& pal, const QSizeF& size, DockWidgetArea DockWidgetArea)
126+
{
127+
QColor borderColor = pal.color(QPalette::Active, QPalette::Highlight);
128+
QColor backgroundColor = pal.color(QPalette::Active, QPalette::Base);
129+
//QColor areaBackgroundColor = pal.color(QPalette::Active, QPalette::Highlight).lighter(150);
130+
131+
QPixmap pm(size.width(), size.height());
132+
pm.fill(QColor(0, 0, 0, 0));
133+
134+
QPainter p(&pm);
135+
QPen pen = p.pen();
136+
QRectF ShadowRect(pm.rect());
137+
QRectF baseRect;
138+
baseRect.setSize(ShadowRect.size() * 0.7);
139+
baseRect.moveCenter(ShadowRect.center());
140+
141+
// Fill
142+
p.fillRect(ShadowRect, QColor(0, 0, 0, 64));
143+
p.fillRect(baseRect, backgroundColor);
144+
145+
// Drop area rect.
146+
p.save();
147+
QRectF areaRect;
148+
QLineF areaLine;
149+
switch (DockWidgetArea)
150+
{
151+
case TopDockWidgetArea:
152+
areaRect = QRectF(baseRect.x(), baseRect.y(), baseRect.width(), baseRect.height() * .5f);
153+
areaLine = QLineF(areaRect.bottomLeft(), areaRect.bottomRight());
154+
break;
155+
case RightDockWidgetArea:
156+
areaRect = QRectF(ShadowRect.width() * .5f, baseRect.y(), baseRect.width() * .5f, baseRect.height());
157+
areaLine = QLineF(areaRect.topLeft(), areaRect.bottomLeft());
158+
break;
159+
case BottomDockWidgetArea:
160+
areaRect = QRectF(baseRect.x(), ShadowRect.height() * .5f, baseRect.width(), baseRect.height() * .5f);
161+
areaLine = QLineF(areaRect.topLeft(), areaRect.topRight());
162+
break;
163+
case LeftDockWidgetArea:
164+
areaRect = QRectF(baseRect.x(), baseRect.y(), baseRect.width() * .5f, baseRect.height());
165+
areaLine = QLineF(areaRect.topRight(), areaRect.bottomRight());
166+
break;
167+
default:
168+
break;
169+
}
170+
if (areaRect.isValid())
171+
{
172+
pen = p.pen();
173+
pen.setColor(borderColor);
174+
QColor Color = borderColor;
175+
Color.setAlpha(64);
176+
p.setBrush(Color);
177+
p.setPen(Qt::NoPen);
178+
p.drawRect(areaRect);
179+
180+
pen = p.pen();
181+
pen.setColor(borderColor);
182+
pen.setStyle(Qt::DashLine);
183+
p.setPen(pen);
184+
p.drawLine(areaLine);
185+
}
186+
p.restore();
187+
188+
p.save();
189+
pen = p.pen();
190+
pen.setColor(borderColor);
191+
pen.setWidth(1);
192+
193+
p.setBrush(Qt::NoBrush);
194+
p.setPen(pen);
195+
p.drawRect(baseRect);
196+
197+
p.setBrush(borderColor);
198+
QRectF FrameRect(baseRect.topLeft(), QSizeF(baseRect.width(), baseRect.height() / 10));
199+
p.drawRect(FrameRect);
200+
p.restore();
201+
return pm;
202+
}
203+
204+
124205
//============================================================================
125206
QWidget* createDropIndicatorWidget(DockWidgetArea DockWidgetArea)
126207
{
@@ -334,19 +415,18 @@ void CDockOverlay::paintEvent(QPaintEvent* event)
334415

335416

336417
//============================================================================
337-
void CDockOverlay::showEvent(QShowEvent*)
418+
void CDockOverlay::showEvent(QShowEvent* e)
338419
{
339420
d->Cross->show();
340-
QWidget* w = parentWidget() ? parentWidget() : d->TargetWidget.data();
341-
QRect WidgetRect = w->rect();
342-
QPoint Pos(WidgetRect.left(), WidgetRect.center().y());
421+
QFrame::showEvent(e);
343422
}
344423

345424

346425
//============================================================================
347-
void CDockOverlay::hideEvent(QHideEvent*)
426+
void CDockOverlay::hideEvent(QHideEvent* e)
348427
{
349428
d->Cross->hide();
429+
QFrame::hideEvent(e);
350430
}
351431

352432

0 commit comments

Comments
 (0)