41
41
namespace ads
42
42
{
43
43
// ============================================================================
44
- static QPixmap createDropIndicatorPixmap_old (const QPalette& pal, const QSizeF& size, DockWidgetArea DockWidgetArea)
44
+ static QPixmap createDropIndicatorPixmap (const QPalette& pal, const QSizeF& size, DockWidgetArea DockWidgetArea,
45
+ CDockOverlay::eMode Mode)
45
46
{
46
47
QColor borderColor = pal.color (QPalette::Active, QPalette::Highlight);
47
48
QColor backgroundColor = pal.color (QPalette::Active, QPalette::Base);
48
- QColor areaBackgroundColor = pal.color (QPalette::Active, QPalette::Highlight).lighter (150 );
49
49
50
50
QPixmap pm (size.width (), size.height ());
51
51
pm.fill (QColor (0 , 0 , 0 , 0 ));
@@ -59,114 +59,44 @@ static QPixmap createDropIndicatorPixmap_old(const QPalette& pal, const QSizeF&
59
59
60
60
// Fill
61
61
p.fillRect (ShadowRect, QColor (0 , 0 , 0 , 64 ));
62
- p.fillRect (baseRect, backgroundColor);
63
62
64
63
// Drop area rect.
65
64
p.save ();
66
65
QRectF areaRect;
67
66
QLineF areaLine;
68
- QLinearGradient gradient ;
67
+ QRectF nonAreaRect ;
69
68
switch (DockWidgetArea)
70
69
{
71
70
case TopDockWidgetArea:
72
71
areaRect = QRectF (baseRect.x (), baseRect.y (), baseRect.width (), baseRect.height () * .5f );
72
+ nonAreaRect = QRectF (baseRect.x (), ShadowRect.height () * .5f , baseRect.width (), baseRect.height () * .5f );
73
73
areaLine = QLineF (areaRect.bottomLeft (), areaRect.bottomRight ());
74
- gradient.setStart (areaRect.topLeft ());
75
- gradient.setFinalStop (areaRect.bottomLeft ());
76
74
break ;
77
75
case RightDockWidgetArea:
78
76
areaRect = QRectF (ShadowRect.width () * .5f , baseRect.y (), baseRect.width () * .5f , baseRect.height ());
77
+ nonAreaRect = QRectF (baseRect.x (), baseRect.y (), baseRect.width () * .5f , baseRect.height ());
79
78
areaLine = QLineF (areaRect.topLeft (), areaRect.bottomLeft ());
80
- gradient.setStart (areaRect.topLeft ());
81
- gradient.setFinalStop (areaRect.topRight ());
82
79
break ;
83
80
case BottomDockWidgetArea:
84
81
areaRect = QRectF (baseRect.x (), ShadowRect.height () * .5f , baseRect.width (), baseRect.height () * .5f );
82
+ nonAreaRect = QRectF (baseRect.x (), baseRect.y (), baseRect.width (), baseRect.height () * .5f );
85
83
areaLine = QLineF (areaRect.topLeft (), areaRect.topRight ());
86
- gradient.setStart (areaRect.topLeft ());
87
- gradient.setFinalStop (areaRect.bottomLeft ());
88
84
break ;
89
85
case LeftDockWidgetArea:
90
86
areaRect = QRectF (baseRect.x (), baseRect.y (), baseRect.width () * .5f , baseRect.height ());
87
+ nonAreaRect = QRectF (ShadowRect.width () * .5f , baseRect.y (), baseRect.width () * .5f , baseRect.height ());
91
88
areaLine = QLineF (areaRect.topRight (), areaRect.bottomRight ());
92
- gradient.setStart (areaRect.topLeft ());
93
- gradient.setFinalStop (areaRect.topRight ());
94
89
break ;
95
90
default :
96
91
break ;
97
92
}
98
- if (areaRect.isValid ())
99
- {
100
- gradient.setColorAt (0 .f , areaBackgroundColor);
101
- gradient.setColorAt (1 .f , areaBackgroundColor.lighter (120 ));
102
- p.fillRect (areaRect, gradient);
103
93
104
- pen = p.pen ();
105
- pen.setColor (borderColor);
106
- pen.setStyle (Qt::DashLine);
107
- p.setPen (pen);
108
- p.drawLine (areaLine);
94
+ if (CDockOverlay::ModeContainerOverlay == Mode)
95
+ {
96
+ baseRect = areaRect;
109
97
}
110
- p.restore ();
111
-
112
- p.save ();
113
- pen = p.pen ();
114
- pen.setColor (borderColor);
115
- pen.setWidth (1 );
116
-
117
- p.setPen (pen);
118
- p.drawRect (baseRect.adjusted (0 , 0 , -pen.width (), -pen.width ()));
119
- p.restore ();
120
- return pm;
121
- }
122
-
123
98
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
99
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
100
if (areaRect.isValid ())
171
101
{
172
102
pen = p.pen ();
@@ -186,32 +116,72 @@ static QPixmap createDropIndicatorPixmap(const QPalette& pal, const QSizeF& size
186
116
p.restore ();
187
117
188
118
p.save ();
119
+ // Draw outer border
189
120
pen = p.pen ();
190
121
pen.setColor (borderColor);
191
122
pen.setWidth (1 );
192
-
193
123
p.setBrush (Qt::NoBrush);
194
124
p.setPen (pen);
195
125
p.drawRect (baseRect);
196
126
127
+ // draw window title bar
197
128
p.setBrush (borderColor);
198
129
QRectF FrameRect (baseRect.topLeft (), QSizeF (baseRect.width (), baseRect.height () / 10 ));
199
130
p.drawRect (FrameRect);
200
131
p.restore ();
132
+
133
+ if (CDockOverlay::ModeContainerOverlay == Mode)
134
+ {
135
+ QRectF ArrowRect;
136
+ ArrowRect.setSize (ShadowRect.size () * 0.7 );
137
+ ArrowRect.setWidth (ArrowRect.width () / 4.6 );
138
+ ArrowRect.setHeight (ArrowRect.height () / 2 );
139
+ ArrowRect.moveCenter (QPointF (0 , 0 ));
140
+ QPolygonF Arrow;
141
+ Arrow << ArrowRect.topLeft ()
142
+ << QPointF ( ArrowRect.right (), ArrowRect.center ().y ())
143
+ << ArrowRect.bottomLeft ();
144
+ p.setPen (Qt::NoPen);
145
+ p.setBrush (backgroundColor);
146
+ p.setRenderHint (QPainter::Antialiasing, true );
147
+ p.translate (nonAreaRect.center ().x (), nonAreaRect.center ().y ());
148
+
149
+ switch (DockWidgetArea)
150
+ {
151
+ case TopDockWidgetArea:
152
+ p.rotate (-90 );
153
+ break ;
154
+ case RightDockWidgetArea:
155
+ break ;
156
+ case BottomDockWidgetArea:
157
+ p.rotate (90 );
158
+ break ;
159
+ case LeftDockWidgetArea:
160
+ p.rotate (180 );
161
+ break ;
162
+ default :
163
+ break ;
164
+ }
165
+
166
+ p.drawPolygon (Arrow);
167
+ }
168
+
201
169
return pm;
202
170
}
203
171
204
172
205
173
// ============================================================================
206
- QWidget* createDropIndicatorWidget (DockWidgetArea DockWidgetArea)
174
+ QWidget* createDropIndicatorWidget (DockWidgetArea DockWidgetArea,
175
+ CDockOverlay::eMode Mode)
207
176
{
208
177
QLabel* l = new QLabel ();
209
178
l->setObjectName (" DockWidgetAreaLabel" );
210
179
211
180
const qreal metric = static_cast <qreal>(l->fontMetrics ().height ()) * 3 .f ;
212
181
const QSizeF size (metric, metric);
213
182
214
- l->setPixmap (createDropIndicatorPixmap (l->palette (), size, DockWidgetArea));
183
+ l->setPixmap (createDropIndicatorPixmap (l->palette (), size, DockWidgetArea,
184
+ Mode));
215
185
l->setWindowFlags (Qt::Tool | Qt::FramelessWindowHint);
216
186
l->setAttribute (Qt::WA_TranslucentBackground);
217
187
return l;
@@ -230,6 +200,7 @@ struct DockOverlayPrivate
230
200
QRect TargetRect;
231
201
DockWidgetArea LastLocation = InvalidDockWidgetArea;
232
202
bool DropPreviewEnabled = true ;
203
+ CDockOverlay::eMode Mode = CDockOverlay::ModeDockAreaOverlay;
233
204
234
205
/* *
235
206
* Private data constructor
@@ -267,6 +238,7 @@ CDockOverlay::CDockOverlay(QWidget* parent, eMode Mode) :
267
238
QFrame (parent),
268
239
d (new DockOverlayPrivate(this ))
269
240
{
241
+ d->Mode = Mode;
270
242
d->Cross = new CDockOverlayCross (this );
271
243
setWindowFlags (Qt::Tool | Qt::FramelessWindowHint);
272
244
setWindowOpacity (1 );
@@ -359,8 +331,6 @@ DockWidgetArea CDockOverlay::showOverlay(QWidget* target)
359
331
resize (target->size ());
360
332
QPoint TopLeft = target->mapToGlobal (target->rect ().topLeft ());
361
333
move (TopLeft);
362
- std::cout << " Overlay top: " << TopLeft.x () << " left: " << TopLeft.y ()
363
- << std::endl;
364
334
show ();
365
335
return dropAreaUnderCursor ();
366
336
}
@@ -397,12 +367,16 @@ void CDockOverlay::paintEvent(QPaintEvent* event)
397
367
QRect r = rect ();
398
368
const DockWidgetArea da = dropAreaUnderCursor ();
399
369
// std::cout << "CursorLocation: " << dropAreaUnderCursor() << std::endl;
370
+
371
+ double Factor = (CDockOverlay::ModeContainerOverlay == d->Mode ) ?
372
+ 3 : 2 ;
373
+
400
374
switch (da)
401
375
{
402
- case TopDockWidgetArea: r.setHeight (r.height () / 2 ); break ;
403
- case RightDockWidgetArea: r.setX (r.width () / 2 ); break ;
404
- case BottomDockWidgetArea: r.setY (r.height () / 2 ); break ;
405
- case LeftDockWidgetArea: r.setWidth (r.width () / 2 ); break ;
376
+ case TopDockWidgetArea: r.setHeight (r.height () / Factor ); break ;
377
+ case RightDockWidgetArea: r.setX (r.width () * ( 1 - 1 / Factor) ); break ;
378
+ case BottomDockWidgetArea: r.setY (r.height () * ( 1 - 1 / Factor) ); break ;
379
+ case LeftDockWidgetArea: r.setWidth (r.width () / Factor ); break ;
406
380
case CenterDockWidgetArea: r = rect ();break ;
407
381
default : return ;
408
382
}
@@ -505,11 +479,11 @@ void CDockOverlayCross::setupOverlayCross(CDockOverlay::eMode Mode)
505
479
d->Mode = Mode;
506
480
507
481
QHash<DockWidgetArea, QWidget*> areaWidgets;
508
- areaWidgets.insert (TopDockWidgetArea, createDropIndicatorWidget (TopDockWidgetArea));
509
- areaWidgets.insert (RightDockWidgetArea, createDropIndicatorWidget (RightDockWidgetArea));
510
- areaWidgets.insert (BottomDockWidgetArea, createDropIndicatorWidget (BottomDockWidgetArea));
511
- areaWidgets.insert (LeftDockWidgetArea, createDropIndicatorWidget (LeftDockWidgetArea));
512
- areaWidgets.insert (CenterDockWidgetArea, createDropIndicatorWidget (CenterDockWidgetArea));
482
+ areaWidgets.insert (TopDockWidgetArea, createDropIndicatorWidget (TopDockWidgetArea, Mode ));
483
+ areaWidgets.insert (RightDockWidgetArea, createDropIndicatorWidget (RightDockWidgetArea, Mode ));
484
+ areaWidgets.insert (BottomDockWidgetArea, createDropIndicatorWidget (BottomDockWidgetArea, Mode ));
485
+ areaWidgets.insert (LeftDockWidgetArea, createDropIndicatorWidget (LeftDockWidgetArea, Mode ));
486
+ areaWidgets.insert (CenterDockWidgetArea, createDropIndicatorWidget (CenterDockWidgetArea, Mode ));
513
487
514
488
setAreaWidgets (areaWidgets);
515
489
}
0 commit comments