38
38
39
39
#include " DockAreaWidget.h"
40
40
#include " DockAreaTitleBar.h"
41
+ #include " DockContainerWidget.h"
42
+ #include " AutoHideSideBar.h"
43
+ #include " DockManager.h"
41
44
42
45
#include < iostream>
43
46
44
47
namespace ads
45
48
{
49
+ static const int AutoHideAreaWidth = 32 ;
46
50
47
51
/* *
48
52
* Private data class of CDockOverlay
@@ -62,6 +66,12 @@ struct DockOverlayPrivate
62
66
* Private data constructor
63
67
*/
64
68
DockOverlayPrivate (CDockOverlay* _public) : _this(_public) {}
69
+
70
+ /* *
71
+ * Returns the overlay width / height depending on the visibility
72
+ * of the sidebar
73
+ */
74
+ int sideBarOverlaySize (SideBarLocation sideBarLocation);
65
75
};
66
76
67
77
/* *
@@ -155,8 +165,20 @@ struct DockOverlayCrossPrivate
155
165
QLabel* l = new QLabel ();
156
166
l->setObjectName (" DockWidgetAreaLabel" );
157
167
158
- const qreal metric = dropIndicatiorWidth (l);
159
- const QSizeF size (metric, metric);
168
+ qreal metric = dropIndicatiorWidth (l);
169
+ QSizeF size (metric, metric);
170
+ if (internal::isSideBarArea (DockWidgetArea))
171
+ {
172
+ auto SideBarLocation = internal::toSideBarLocation (DockWidgetArea);
173
+ if (internal::isHorizontalSideBarLocation (SideBarLocation))
174
+ {
175
+ size.setHeight (size.height () / 2 );
176
+ }
177
+ else
178
+ {
179
+ size.setWidth (size.width () / 2 );
180
+ }
181
+ }
160
182
161
183
l->setPixmap (createHighDpiDropIndicatorPixmap (size, DockWidgetArea, Mode));
162
184
l->setWindowFlags (Qt::Tool | Qt::FramelessWindowHint);
@@ -283,7 +305,7 @@ struct DockOverlayCrossPrivate
283
305
p.restore ();
284
306
285
307
// Draw arrow for outer container drop indicators
286
- if (CDockOverlay::ModeContainerOverlay == Mode && DockWidgetArea != CenterDockWidgetArea)
308
+ /* if (CDockOverlay::ModeContainerOverlay == Mode && DockWidgetArea != CenterDockWidgetArea)
287
309
{
288
310
QRectF ArrowRect;
289
311
ArrowRect.setSize(baseSize);
@@ -317,7 +339,7 @@ struct DockOverlayCrossPrivate
317
339
}
318
340
319
341
p.drawPolygon(Arrow);
320
- }
342
+ }*/
321
343
322
344
pm.setDevicePixelRatio (DevicePixelRatio);
323
345
return pm;
@@ -326,6 +348,22 @@ struct DockOverlayCrossPrivate
326
348
};
327
349
328
350
351
+ // ============================================================================
352
+ int DockOverlayPrivate::sideBarOverlaySize (SideBarLocation sideBarLocation)
353
+ {
354
+ auto Container = qobject_cast<CDockContainerWidget*>(TargetWidget.data ());
355
+ auto SideBar = Container->sideTabBar (sideBarLocation);
356
+ if (!SideBar || !SideBar->isVisibleTo (Container))
357
+ {
358
+ return AutoHideAreaWidth;
359
+ }
360
+ else
361
+ {
362
+ return (SideBar->orientation () == Qt::Horizontal) ? SideBar->height () : SideBar->width ();
363
+ }
364
+ }
365
+
366
+
329
367
// ============================================================================
330
368
CDockOverlay::CDockOverlay (QWidget* parent, eMode Mode) :
331
369
QFrame (parent),
@@ -375,15 +413,42 @@ DockWidgetAreas CDockOverlay::allowedAreas() const
375
413
// ============================================================================
376
414
DockWidgetArea CDockOverlay::dropAreaUnderCursor () const
377
415
{
416
+ if (!d->TargetWidget )
417
+ {
418
+ return InvalidDockWidgetArea;
419
+ }
420
+
378
421
DockWidgetArea Result = d->Cross ->cursorLocation ();
379
422
if (Result != InvalidDockWidgetArea)
380
423
{
381
424
return Result;
382
425
}
383
426
384
- CDockAreaWidget* DockArea = qobject_cast<CDockAreaWidget*>(d->TargetWidget .data ());
427
+ auto DockArea = qobject_cast<CDockAreaWidget*>(d->TargetWidget .data ());
385
428
if (!DockArea)
386
429
{
430
+ /* auto Rect = rect();
431
+ const QPoint pos = mapFromGlobal(QCursor::pos());
432
+ if (pos.x() < d->sideBarOverlaySize(SideBarLeft))
433
+ {
434
+ return LeftAutoHideArea;
435
+ }
436
+ else if (pos.x() > (Rect.width() - d->sideBarOverlaySize(SideBarRight)))
437
+ {
438
+ return RightAutoHideArea;
439
+ }
440
+ else if (pos.y() < d->sideBarOverlaySize(SideBarTop))
441
+ {
442
+ return TopAutoHideArea;
443
+ }
444
+ else if (pos.y() > (Rect.height() - d->sideBarOverlaySize(SideBarBottom)))
445
+ {
446
+ return BottomAutoHideArea;
447
+ }
448
+ else
449
+ {
450
+ return Result;
451
+ }*/
387
452
return Result;
388
453
}
389
454
@@ -490,6 +555,10 @@ void CDockOverlay::paintEvent(QPaintEvent* event)
490
555
case BottomDockWidgetArea: r.setY (r.height () * (1 - 1 / Factor)); break ;
491
556
case LeftDockWidgetArea: r.setWidth (r.width () / Factor); break ;
492
557
case CenterDockWidgetArea: r = rect ();break ;
558
+ case LeftAutoHideArea: r.setWidth (d->sideBarOverlaySize (SideBarLeft)); break ;
559
+ case RightAutoHideArea: r.setX (r.width () - d->sideBarOverlaySize (SideBarRight)); break ;
560
+ case TopAutoHideArea: r.setHeight (d->sideBarOverlaySize (SideBarTop)); break ;
561
+ case BottomAutoHideArea: r.setY (r.height () - d->sideBarOverlaySize (SideBarBottom)); break ;
493
562
default : return ;
494
563
}
495
564
QPainter painter (this );
@@ -574,6 +643,23 @@ QPoint DockOverlayCrossPrivate::areaGridPosition(const DockWidgetArea area)
574
643
default : return QPoint ();
575
644
}
576
645
}
646
+ else if (CDockManager::autoHideConfigFlags ().testFlag (CDockManager::AutoHideFeatureEnabled))
647
+ {
648
+ switch (area)
649
+ {
650
+ case TopDockWidgetArea: return QPoint (1 , 3 );
651
+ case RightDockWidgetArea: return QPoint (3 , 5 );
652
+ case BottomDockWidgetArea: return QPoint (5 , 3 );
653
+ case LeftDockWidgetArea: return QPoint (3 , 1 );
654
+ case CenterDockWidgetArea: return QPoint (3 , 3 );
655
+
656
+ case TopAutoHideArea: return QPoint (0 , 3 );
657
+ case RightAutoHideArea: return QPoint (3 , 6 );
658
+ case BottomAutoHideArea: return QPoint (6 , 3 );
659
+ case LeftAutoHideArea: return QPoint (3 , 0 );
660
+ default : return QPoint ();
661
+ }
662
+ }
577
663
else
578
664
{
579
665
switch (area)
@@ -627,6 +713,16 @@ void CDockOverlayCross::setupOverlayCross(CDockOverlay::eMode Mode)
627
713
areaWidgets.insert (BottomDockWidgetArea, d->createDropIndicatorWidget (BottomDockWidgetArea, Mode));
628
714
areaWidgets.insert (LeftDockWidgetArea, d->createDropIndicatorWidget (LeftDockWidgetArea, Mode));
629
715
areaWidgets.insert (CenterDockWidgetArea, d->createDropIndicatorWidget (CenterDockWidgetArea, Mode));
716
+
717
+ if (CDockManager::autoHideConfigFlags ().testFlag (CDockManager::AutoHideFeatureEnabled)
718
+ && CDockOverlay::ModeContainerOverlay == Mode)
719
+ {
720
+ areaWidgets.insert (TopAutoHideArea, d->createDropIndicatorWidget (TopAutoHideArea, Mode));
721
+ areaWidgets.insert (RightAutoHideArea, d->createDropIndicatorWidget (RightAutoHideArea, Mode));
722
+ areaWidgets.insert (BottomAutoHideArea, d->createDropIndicatorWidget (BottomAutoHideArea, Mode));
723
+ areaWidgets.insert (LeftAutoHideArea, d->createDropIndicatorWidget (LeftAutoHideArea, Mode));
724
+ }
725
+
630
726
#if QT_VERSION >= 0x050600
631
727
d->LastDevicePixelRatio = devicePixelRatioF ();
632
728
#else
@@ -713,6 +809,26 @@ void CDockOverlayCross::setAreaWidgets(const QHash<DockWidgetArea, QWidget*>& wi
713
809
d->GridLayout ->setColumnStretch (3 , 0 );
714
810
d->GridLayout ->setColumnStretch (4 , 1 );
715
811
}
812
+ else if (CDockManager::autoHideConfigFlags ().testFlag (CDockManager::AutoHideFeatureEnabled))
813
+ {
814
+ d->GridLayout ->setContentsMargins (4 , 4 , 4 , 4 );
815
+ d->GridLayout ->setSpacing (4 );
816
+ d->GridLayout ->setRowStretch (0 , 0 );
817
+ d->GridLayout ->setRowStretch (1 , 0 );
818
+ d->GridLayout ->setRowStretch (2 , 1 );
819
+ d->GridLayout ->setRowStretch (3 , 1 );
820
+ d->GridLayout ->setRowStretch (4 , 1 );
821
+ d->GridLayout ->setRowStretch (5 , 0 );
822
+ d->GridLayout ->setRowStretch (6 , 0 );
823
+
824
+ d->GridLayout ->setColumnStretch (0 , 0 );
825
+ d->GridLayout ->setColumnStretch (1 , 0 );
826
+ d->GridLayout ->setColumnStretch (2 , 1 );
827
+ d->GridLayout ->setColumnStretch (3 , 1 );
828
+ d->GridLayout ->setColumnStretch (4 , 1 );
829
+ d->GridLayout ->setColumnStretch (5 , 0 );
830
+ d->GridLayout ->setColumnStretch (6 , 0 );
831
+ }
716
832
else
717
833
{
718
834
d->GridLayout ->setContentsMargins (4 , 4 , 4 , 4 );
0 commit comments