Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/origin/autohide_drag'
Browse files Browse the repository at this point in the history
  • Loading branch information
githubuser0xFFFF committed Jul 13, 2023
2 parents 6e642ec + 1a1352e commit f00ef60
Show file tree
Hide file tree
Showing 30 changed files with 1,367 additions and 216 deletions.
70 changes: 70 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,70 @@ integrated development environments (IDEs) such as Visual Studio.

## New and Noteworthy

Release [4.1](https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System/releases/latest) significantly improves the Auto-Hide functionality and also brings improvements
for Drag and Drop of dock widgets into dock area tabs. These are the highlights of the new version:

#### Drag & Drop to Auto-Hide

Now you can easily drag any dock widget or any floating widget to the
borders of a window to pin it as a auto-hide tab in one of the 4 sidebars.
If you drag a dock widget close the one of the four window borders, special
drop overlays will be shown to indicate the drop area for auto-hide widgets:

![Auo-Hide drag to Sidebar](doc/AutoHide_Drag_to_Sidebar.gif)

Of course, this also works with dock areas:

![Auo-Hide drag Dock Area](doc/AutoHide_Drag_DockArea.gif)

If you drag a dock widget or dock area into a sidebar, then you even have
control over where tabs are inserted. Simply drag your mouse over a specific
auto-hide tab, and your dragged dock widget will be inserted before this tab.
Drag to the sidebar area behind the last tab, and the dragged widget will be
appended as last tab. In the following screen capture, the **Image Viewer 1** will
be inserted before the **Table 0** Auto-Hide tab and the **Image Viewer 2**
is appende behind the last tab:

![Auo-Hide tab insert order](doc/AutoHide_Tab_Insert_Order.gif)

#### Auto-Hide Tab Insertion Order

It is also possible to drag Auto-Hide tabs to a new auto-hide position.
That means, you can drag them to a different border or sidebar:

![Auto-Hide change sidebar](doc/AutoHide_Change_Sidebar.gif)

#### Auto-Hide Tab Sorting

You can drag Auto-Hide tabs to a new position in the current sidebar
to sort them:

![Auo-Hide sort tabs](doc/AutoHide_Sort_Tabs.gif)

#### Auto-Hide Drag to Float / Dock

But that is not all. You can also simply move Auto-Hide tabs to another
floating widget or dock them via drag and drop:

![Auo-Hide drag to float or dock](doc/AutoHide_Drag_to_Float_or_Dock.gif)

#### Auto-Hide Context Menu

All Auto-Hide tabs now have a context menu, that provides all the functionality
that you know from Dock widget tabs. With the **Pin To...** item from the
context menu it is very easy to move an Auto-Hide tab to a different Auto-Hide
sidebar:

![Auo-Hide context menu](doc/AutoHide_Context_Menu.png)

#### Dock Area Tab Insert Order

And last but not least the new version also improves the docking of widgets
into the tabs of a Dock area. Just as with Auto-Hide tabs, you can now determine the position at which a tab is inserted by moving the mouse over an already existing tab (insertion before the tab) or behind the last tab
(appending):

![Dock area tab insert order](doc/DockArea_Tab_Insertion_Order.gif)

The [release 4.0](https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System/releases/latest)
adds the following features:

Expand Down Expand Up @@ -77,6 +141,12 @@ know it from Visual Studio.
### Overview

- [New and Noteworthy](#new-and-noteworthy)
- [Drag \& Drop to Auto-Hide](#drag--drop-to-auto-hide)
- [Auto-Hide Tab Insertion Order](#auto-hide-tab-insertion-order)
- [Auto-Hide Tab Sorting](#auto-hide-tab-sorting)
- [Auto-Hide Drag to Float / Dock](#auto-hide-drag-to-float--dock)
- [Auto-Hide Context Menu](#auto-hide-context-menu)
- [Dock Area Tab Insert Order](#dock-area-tab-insert-order)
- [Features](#features)
- [Overview](#overview)
- [Docking everywhere - no central widget](#docking-everywhere---no-central-widget)
Expand Down
8 changes: 5 additions & 3 deletions demo/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -448,8 +448,8 @@ void MainWindowPrivate::createContent()

// For this Special Dock Area we want to avoid dropping on the center of it (i.e. we don't want this widget to be ever tabbified):
{
SpecialDockArea->setAllowedAreas(ads::OuterDockAreas);
//SpecialDockArea->setAllowedAreas({ads::LeftDockWidgetArea, ads::RightDockWidgetArea}); // just for testing
//SpecialDockArea->setAllowedAreas(ads::OuterDockAreas);
SpecialDockArea->setAllowedAreas({ads::LeftDockWidgetArea, ads::RightDockWidgetArea, ads::TopDockWidgetArea}); // just for testing
}

DockWidget = createLongTextLabelDockWidget();
Expand Down Expand Up @@ -517,7 +517,9 @@ void MainWindowPrivate::createContent()

// Test dock area docking
auto RighDockArea = DockManager->addDockWidget(ads::RightDockWidgetArea, createLongTextLabelDockWidget(), TopDockArea);
DockManager->addDockWidget(ads::TopDockWidgetArea, createLongTextLabelDockWidget(), RighDockArea);
DockWidget = createLongTextLabelDockWidget();
DockWidget->setFeature(ads::CDockWidget::DockWidgetPinnable, false);
DockManager->addDockWidget(ads::TopDockWidgetArea, DockWidget, RighDockArea);
auto BottomDockArea = DockManager->addDockWidget(ads::BottomDockWidgetArea, createLongTextLabelDockWidget(), RighDockArea);
DockManager->addDockWidget(ads::CenterDockWidgetArea, createLongTextLabelDockWidget(), RighDockArea);
auto LabelDockWidget = createLongTextLabelDockWidget();
Expand Down
71 changes: 68 additions & 3 deletions src/AutoHideDockContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ struct AutoHideDockContainerPrivate
CResizeHandle* ResizeHandle = nullptr;
QSize Size; // creates invalid size
QPointer<CAutoHideTab> SideTab;
QSize SizeCache;

/**
* Private data constructor
Expand Down Expand Up @@ -215,6 +216,7 @@ CAutoHideDockContainer::CAutoHideDockContainer(CDockWidget* DockWidget, SideBarL
bool OpaqueResize = CDockManager::testConfigFlag(CDockManager::OpaqueSplitterResize);
d->ResizeHandle->setOpaqueResize(OpaqueResize);
d->Size = d->DockArea->size();
d->SizeCache = DockWidget->size();

addDockWidget(DockWidget);
parent->registerAutoHideWidget(this);
Expand All @@ -237,7 +239,6 @@ void CAutoHideDockContainer::updateSize()
}

auto rect = dockContainerParent->contentRect();

switch (sideBarLocation())
{
case SideBarLocation::SideBarTop:
Expand Down Expand Up @@ -271,6 +272,15 @@ void CAutoHideDockContainer::updateSize()
default:
break;
}

if (orientation() == Qt::Horizontal)
{
d->SizeCache.setHeight(this->height());
}
else
{
d->SizeCache.setWidth(this->width());
}
}

//============================================================================
Expand All @@ -294,7 +304,7 @@ CAutoHideDockContainer::~CAutoHideDockContainer()
}

//============================================================================
CAutoHideSideBar* CAutoHideDockContainer::sideBar() const
CAutoHideSideBar* CAutoHideDockContainer::autoHideSideBar() const
{
if (d->SideTab)
{
Expand All @@ -303,7 +313,7 @@ CAutoHideSideBar* CAutoHideDockContainer::sideBar() const
else
{
auto DockContainer = dockContainer();
return DockContainer ? DockContainer->sideTabBar(d->SideTabBarArea) : nullptr;
return DockContainer ? DockContainer->autoHideSideBar(d->SideTabBarArea) : nullptr;
}
}

Expand Down Expand Up @@ -344,6 +354,10 @@ void CAutoHideDockContainer::addDockWidget(CDockWidget* DockWidget)
}
d->DockArea->addDockWidget(DockWidget);
updateSize();
// The dock area is not visible and will not update the size when updateSize()
// is called for this auto hide container. Therefore we explicitely resize
// it here. As soon as it will become visible, it will get the right size
d->DockArea->resize(size());
}


Expand Down Expand Up @@ -643,5 +657,56 @@ bool CAutoHideDockContainer::event(QEvent* event)
return Super::event(event);
}


//============================================================================
Qt::Orientation CAutoHideDockContainer::orientation() const
{
return ads::internal::isHorizontalSideBarLocation(d->SideTabBarArea)
? Qt::Horizontal : Qt::Vertical;
}


//============================================================================
void CAutoHideDockContainer::resetToInitialDockWidgetSize()
{
if (orientation() == Qt::Horizontal)
{
setSize(d->SizeCache.height());
}
else
{
setSize(d->SizeCache.width());
}
}


//============================================================================
void CAutoHideDockContainer::moveToNewSideBarLocation(SideBarLocation NewSideBarLocation,
int TabIndex)
{
if (NewSideBarLocation == sideBarLocation() && TabIndex == this->tabIndex())
{
return;
}

auto OldOrientation = orientation();
auto SideBar = dockContainer()->autoHideSideBar(NewSideBarLocation);
SideBar->addAutoHideWidget(this, TabIndex);
// If we move a horizontal auto hide container to a vertical position
// then we resize it to the orginal dock widget size, to avoid
// an extremely streched dock widget after insertion
if (SideBar->orientation() != OldOrientation)
{
resetToInitialDockWidgetSize();
}
}


//============================================================================
int CAutoHideDockContainer::tabIndex() const
{
return d->SideTab->tabIndex();
}

}

31 changes: 30 additions & 1 deletion src/AutoHideDockContainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class ADS_EXPORT CAutoHideDockContainer : public QFrame
/**
* Get's the side tab bar
*/
CAutoHideSideBar* sideBar() const;
CAutoHideSideBar* autoHideSideBar() const;

/**
* Returns the side tab
Expand All @@ -105,6 +105,11 @@ class ADS_EXPORT CAutoHideDockContainer : public QFrame
*/
CDockWidget* dockWidget() const;

/**
* Returns the index of this container in the sidebar
*/
int tabIndex() const;

/**
* Adds a dock widget and removes the previous dock widget
*/
Expand Down Expand Up @@ -166,6 +171,30 @@ class ADS_EXPORT CAutoHideDockContainer : public QFrame
* of this auto hide container.
*/
void setSize(int Size);

/**
* Resets the with or hight to the initial dock widget size dependinng on
* the orientation.
* If the orientation is Qt::Horizontal, then the height is reset to
* the initial size and if orientation is Qt::Vertical, then the width is
* reset to the initial size
*/
void resetToInitialDockWidgetSize();

/**
* Returns orientation of this container.
* Left and right containers have a Qt::Vertical orientation and top / bottom
* containers have a Qt::Horizontal orientation.
* The function returns the orientation of the corresponding auto hide
* side bar.
*/
Qt::Orientation orientation() const;

/**
* Removes the AutoHide container from the current side bar and adds
* it to the new side bar given in SideBarLocation
*/
void moveToNewSideBarLocation(SideBarLocation SideBarLocation, int TabIndex = -1);
};
} // namespace ads

Expand Down
Loading

0 comments on commit f00ef60

Please sign in to comment.