diff --git a/AdvancedDockingSystem/AdvancedDockingSystem.pro b/AdvancedDockingSystem/AdvancedDockingSystem.pro index 65bc533..b62a1d9 100644 --- a/AdvancedDockingSystem/AdvancedDockingSystem.pro +++ b/AdvancedDockingSystem/AdvancedDockingSystem.pro @@ -1,4 +1,5 @@ include($$(cetoni_repository)/build/qt/qtprojectsettings/shared_library.pri) +include(src/v2/v2.pri) TARGET = $$qtLibraryTarget(AdvancedDockingSystem) TEMPLATE = lib diff --git a/AdvancedDockingSystem/src/v2/DockAreaWidget.cpp b/AdvancedDockingSystem/src/v2/DockAreaWidget.cpp new file mode 100644 index 0000000..3aaed2c --- /dev/null +++ b/AdvancedDockingSystem/src/v2/DockAreaWidget.cpp @@ -0,0 +1,72 @@ +//============================================================================ +/// \file DockAreaWidget.cpp +/// \author Uwe Kindler +/// \date 24.02.2017 +/// \brief Implementation of CDockAreaWidget class +//============================================================================ + +//============================================================================ +// INCLUDES +//============================================================================ +#include "DockAreaWidget.h" + +#include "DockContainerWidget.h" + +namespace ads +{ +/** + * Private data class of CDockAreaWidget class (pimpl) + */ +struct DockAreaWidgetPrivate +{ + CDockAreaWidget* _this; + + /** + * Private data constructor + */ + DockAreaWidgetPrivate(CDockAreaWidget* _public); +}; +// struct DockAreaWidgetPrivate + +//============================================================================ +DockAreaWidgetPrivate::DockAreaWidgetPrivate(CDockAreaWidget* _public) : + _this(_public) +{ + +} + +//============================================================================ +CDockAreaWidget::CDockAreaWidget(CDockManager* DockManager, CDockContainerWidget* parent) : + QFrame(parent), + d(new DockAreaWidgetPrivate(this)) +{ + +} + +//============================================================================ +CDockAreaWidget::~CDockAreaWidget() +{ + delete d; +} + + +//============================================================================ +CDockContainerWidget* CDockAreaWidget::dockContainerWidget() const +{ + QWidget* Parent = parentWidget(); + while (Parent) + { + CDockContainerWidget* Container = dynamic_cast(Parent); + if (Container) + { + return Container; + } + Parent = Parent->parentWidget(); + } + + return 0; +} +} // namespace ads + +//--------------------------------------------------------------------------- +// EOF DockAreaWidget.cpp diff --git a/AdvancedDockingSystem/src/v2/DockAreaWidget.h b/AdvancedDockingSystem/src/v2/DockAreaWidget.h new file mode 100644 index 0000000..8c36bd3 --- /dev/null +++ b/AdvancedDockingSystem/src/v2/DockAreaWidget.h @@ -0,0 +1,53 @@ +#ifndef DockAreaWidgetH +#define DockAreaWidgetH +//============================================================================ +/// \file DockAreaWidget.h +/// \author Uwe Kindler +/// \date 24.02.2017 +/// \brief Declaration of CDockAreaWidget class +//============================================================================ + +//============================================================================ +// INCLUDES +//============================================================================ +#include + +namespace ads +{ +struct DockAreaWidgetPrivate; +class CDockManager; +class CDockContainerWidget; + +/** + * DockAreaWidget manages multiple instances of DckWidgets. + * It displays a title tab, which is clickable and will switch to + * the contents associated to the title when clicked. + */ +class CDockAreaWidget : public QFrame +{ + Q_OBJECT +private: + DockAreaWidgetPrivate* d; ///< private data (pimpl) + friend class DockAreaWidgetPrivate; +protected: +public: + /** + * Default Constructor + */ + CDockAreaWidget(CDockManager* DockManager, CDockContainerWidget* parent); + + /** + * Virtual Destructor + */ + virtual ~CDockAreaWidget(); + + /** + * Returns the dock container widget this dock area widget belongs to or 0 + * if there is no + */ + CDockContainerWidget* dockContainerWidget() const; +}; // class DockAreaWidget +} + // namespace ads +//----------------------------------------------------------------------------- +#endif // DockAreaWidgetH diff --git a/AdvancedDockingSystem/src/v2/DockContainerWidget.cpp b/AdvancedDockingSystem/src/v2/DockContainerWidget.cpp new file mode 100644 index 0000000..a54fa06 --- /dev/null +++ b/AdvancedDockingSystem/src/v2/DockContainerWidget.cpp @@ -0,0 +1,122 @@ +//============================================================================ +/// \file DockContainerWidget.cpp +/// \author Uwe Kindler +/// \date 24.02.2017 +/// \brief Implementation of CDockContainerWidget class +//============================================================================ + +//============================================================================ +// INCLUDES +//============================================================================ +#include "DockContainerWidget.h" + +#include +#include +#include + +#include "DockManager.h" +#include "DockAreaWidget.h" + +namespace ads +{ +static unsigned int zOrderCounter = 0; + +/** + * Private data class of CDockContainerWidget class (pimpl) + */ +struct DockContainerWidgetPrivate +{ + CDockContainerWidget* _this; + CDockManager* DockManager = nullptr; + unsigned int zOrderIndex = 0; + QList DockAreas; + QGridLayout* Layout = nullptr; + + /** + * Private data constructor + */ + DockContainerWidgetPrivate(CDockContainerWidget* _public); + + /** + * Create a new dock area widget and adds it to the list of doc areas + */ + CDockAreaWidget* newDockAreaWidget() + { + auto DockAreaWidget = new CDockAreaWidget(DockManager, _this); + DockAreas.append(DockAreaWidget); + return DockAreaWidget; + } +}; // struct DockContainerWidgetPrivate + + +//============================================================================ +DockContainerWidgetPrivate::DockContainerWidgetPrivate(CDockContainerWidget* _public) : + _this(_public) +{ + +} + +//============================================================================ +CDockContainerWidget::CDockContainerWidget(CDockManager* DockManager, QWidget *parent) : + QFrame(parent), + d(new DockContainerWidgetPrivate(this)) +{ + d->DockManager = DockManager; + + d->Layout = new QGridLayout(); + d->Layout->setContentsMargins(0, 1, 0, 0); + d->Layout->setSpacing(0); + setLayout(d->Layout); +} + +//============================================================================ +CDockContainerWidget::~CDockContainerWidget() +{ + delete d; +} + + +//============================================================================ +void CDockContainerWidget::addDockWidget(DockWidgetArea area, CDockWidget* Dockwidget, + CDockAreaWidget* DockAreaWidget) +{ + if (d->DockAreas.isEmpty()) + { + + } +} + + +//============================================================================ +unsigned int CDockContainerWidget::zOrderIndex() const +{ + return d->zOrderIndex; +} + + +//============================================================================ +bool CDockContainerWidget::isInFrontOf(CDockContainerWidget* Other) const +{ + return this->zOrderIndex() > Other->zOrderIndex(); +} + + +//============================================================================ +bool CDockContainerWidget::event(QEvent *e) +{ + bool Result = QWidget::event(e); + if (e->type() == QEvent::WindowActivate) + { + d->zOrderIndex = ++zOrderCounter; + } + else if (e->type() == QEvent::Show && !d->zOrderIndex) + { + d->zOrderIndex = ++zOrderCounter; + } + + return Result; +} +} // namespace ads + +//--------------------------------------------------------------------------- +// EOF DockContainerWidget.cpp diff --git a/AdvancedDockingSystem/src/v2/DockContainerWidget.h b/AdvancedDockingSystem/src/v2/DockContainerWidget.h new file mode 100644 index 0000000..f2fa97b --- /dev/null +++ b/AdvancedDockingSystem/src/v2/DockContainerWidget.h @@ -0,0 +1,72 @@ +#ifndef DockContainerWidgetH +#define DockContainerWidgetH +//============================================================================ +/// \file DockContainerWidget.h +/// \author Uwe Kindler +/// \date 24.02.2017 +/// \brief Declaration of CDockContainerWidget class +//============================================================================ + +//============================================================================ +// INCLUDES +//============================================================================ +#include + +#include "ads_globals.h" + +namespace ads +{ +struct DockContainerWidgetPrivate; +class CDockAreaWidget; +class CDockWidget; +class CDockManager; + +/** + * Container that manages a number of dock areas with single dock widgets + * or tabyfied dock widtes in each area + */ +class CDockContainerWidget : public QFrame +{ + Q_OBJECT +private: + DockContainerWidgetPrivate* d; ///< private data (pimpl) + friend class DockContainerWidgetPrivate; +protected: + /** + * Handles activation events to update zOrderIndex + */ + virtual bool event(QEvent *e) override; + +public: + /** + * Default Constructor + */ + CDockContainerWidget(CDockManager* DockManager, QWidget* parent = 0); + + /** + * Virtual Destructor + */ + virtual ~CDockContainerWidget(); + + /** + * Adds dockwidget into the given area. + * If DockAreaWidget is not null, then the area parameter indicates the area + * into the DockAreaWidget. If DockAreaWidget is null, the Dockwidget will + * be dropped into the container. + */ + void addDockWidget(DockWidgetArea area, CDockWidget* Dockwidget, CDockAreaWidget* DockAreaWidget = nullptr); + + /** + * Returns the current zOrderIndex + */ + unsigned int zOrderIndex() const; + + /** + * This function returns true if this container widgets z order index is + * higher than the index of the container widget given in Other parameter + */ + bool isInFrontOf(CDockContainerWidget* Other) const; +}; // class DockContainerWidget +} // namespace ads +//----------------------------------------------------------------------------- +#endif // DockContainerWidgetH diff --git a/AdvancedDockingSystem/src/v2/DockManager.cpp b/AdvancedDockingSystem/src/v2/DockManager.cpp new file mode 100644 index 0000000..1764b2c --- /dev/null +++ b/AdvancedDockingSystem/src/v2/DockManager.cpp @@ -0,0 +1,19 @@ +//============================================================================ +/// \file DockManager.cpp +/// \author Uwe Kindler +/// \date 23.02.2017 +/// \brief Implementation of CDockManager +//============================================================================ + +//============================================================================ +// INCLUDES +//============================================================================ +#include "DockManager.h" + +namespace ads +{ + +} // namespace ads + +//--------------------------------------------------------------------------- +// EOF DockManager.cpp diff --git a/AdvancedDockingSystem/src/v2/DockManager.h b/AdvancedDockingSystem/src/v2/DockManager.h new file mode 100644 index 0000000..ad73772 --- /dev/null +++ b/AdvancedDockingSystem/src/v2/DockManager.h @@ -0,0 +1,28 @@ +#ifndef DockManagerH +#define DockManagerH +//============================================================================ +/// \file DockManager.h +/// \author Uwe Kindler +/// \date 23.02.2017 +/// \brief Declaration of CDockManager +//============================================================================ + +//============================================================================ +// INCLUDES +//============================================================================ +#include "DockContainerWidget.h" + +namespace ads +{ + +/** + * @brief + */ +class CDockManager : public CDockContainerWidget +{ +}; + +} // namespace ads + +//--------------------------------------------------------------------------- +#endif // DockManagerH diff --git a/AdvancedDockingSystem/src/v2/DockWidget.cpp b/AdvancedDockingSystem/src/v2/DockWidget.cpp new file mode 100644 index 0000000..77d49ec --- /dev/null +++ b/AdvancedDockingSystem/src/v2/DockWidget.cpp @@ -0,0 +1,19 @@ +//============================================================================ +/// \file DockWidget.cpp +/// \author Uwe Kindler +/// \date 23.02.2017 +/// \brief Implementation of CDockWidget +//============================================================================ + +//============================================================================ +// INCLUDES +//============================================================================ +#include "DockWidget.h" + +namespace ads +{ + +} // namespace ads + +//--------------------------------------------------------------------------- +// EOF DockWidget.cpp diff --git a/AdvancedDockingSystem/src/v2/DockWidget.h b/AdvancedDockingSystem/src/v2/DockWidget.h new file mode 100644 index 0000000..f094b9d --- /dev/null +++ b/AdvancedDockingSystem/src/v2/DockWidget.h @@ -0,0 +1,29 @@ +#ifndef DockWidgetH +#define DockWidgetH +//============================================================================ +/// \file DockWidget.h +/// \author Uwe Kindler +/// \date 23.02.2017 +/// \brief Declaration of CDockWidget +//============================================================================ + +//============================================================================ +// INCLUDES +//============================================================================ +#include + +namespace ads +{ + +/** + * @brief + */ +class CDockWidget : public QFrame +{ + Q_OBJECT +}; + +} // namespace ads + +//--------------------------------------------------------------------------- +#endif // DockWidgetH diff --git a/AdvancedDockingSystem/src/v2/DockWidgetTitleBar.cpp b/AdvancedDockingSystem/src/v2/DockWidgetTitleBar.cpp new file mode 100644 index 0000000..cb0eb3a --- /dev/null +++ b/AdvancedDockingSystem/src/v2/DockWidgetTitleBar.cpp @@ -0,0 +1,19 @@ +//============================================================================ +/// \file DockWidgetTitleBar.cpp +/// \author Uwe Kindler +/// \date 23.02.2017 +/// \brief Implementation of DockWidgetTitleBar +//============================================================================ + +//============================================================================ +// INCLUDES +//============================================================================ +#include "DockWidgetTitleBar.h" + +namespace ads +{ + +} // namespace ads + +//--------------------------------------------------------------------------- +// EOF DockWidgetTitleBar.cpp diff --git a/AdvancedDockingSystem/src/v2/DockWidgetTitleBar.h b/AdvancedDockingSystem/src/v2/DockWidgetTitleBar.h new file mode 100644 index 0000000..b04c764 --- /dev/null +++ b/AdvancedDockingSystem/src/v2/DockWidgetTitleBar.h @@ -0,0 +1,26 @@ +#ifndef DockWidgetTitleBarH +#define DockWidgetTitleBarH +//============================================================================ +/// \file DockWidgetTitleBar.h +/// \author Uwe Kindler +/// \date 23.02.2017 +/// \brief Declaration of DockWidgetTitleBar +//============================================================================ + +//============================================================================ +// INCLUDES +//============================================================================ +namespace ads +{ + +/** + * @brief + */ +class CDockWidgetTitleBar +{ +}; + +} // namespace ads + +//--------------------------------------------------------------------------- +#endif // DockWidgetTitleBarH diff --git a/AdvancedDockingSystem/src/v2/FloatingDockContainer.cpp b/AdvancedDockingSystem/src/v2/FloatingDockContainer.cpp new file mode 100644 index 0000000..1c28a22 --- /dev/null +++ b/AdvancedDockingSystem/src/v2/FloatingDockContainer.cpp @@ -0,0 +1,19 @@ +//============================================================================ +/// \file FloatingDockContainer.cpp +/// \author Uwe Kindler +/// \date 23.02.2017 +/// \brief Implementation of CFloatingDockContainer +//============================================================================ + +//============================================================================ +// INCLUDES +//============================================================================ +#include "FloatingDockContainer.h" + +namespace ads +{ + +} // namespace ads + +//--------------------------------------------------------------------------- +// EOF FloatingDockContainer.cpp diff --git a/AdvancedDockingSystem/src/v2/FloatingDockContainer.h b/AdvancedDockingSystem/src/v2/FloatingDockContainer.h new file mode 100644 index 0000000..ea8791d --- /dev/null +++ b/AdvancedDockingSystem/src/v2/FloatingDockContainer.h @@ -0,0 +1,26 @@ +#ifndef FloatingDockContainerH +#define FloatingDockContainerH +//============================================================================ +/// \file FloatingDockContainer.h +/// \author Uwe Kindler +/// \date 23.02.2017 +/// \brief Declaration of CFloatingDockContainer +//============================================================================ + +//============================================================================ +// INCLUDES +//============================================================================ +namespace ads +{ + +/** + * @brief + */ +class CFloatingDockContainer +{ +}; + +} // namespace ads + +//--------------------------------------------------------------------------- +#endif // FloatingDockContainerH diff --git a/AdvancedDockingSystem/src/v2/ads_globals.cpp b/AdvancedDockingSystem/src/v2/ads_globals.cpp new file mode 100644 index 0000000..7e1d7d4 --- /dev/null +++ b/AdvancedDockingSystem/src/v2/ads_globals.cpp @@ -0,0 +1,36 @@ +//============================================================================ +/// \file ads_globals.cpp +/// \author Uwe Kindler +/// \date 24.02.2017 +/// \brief Implementation of +//============================================================================ + + +//============================================================================ +// INCLUDES +//============================================================================ +#include +#include + +namespace ads +{ + +namespace internal +{ +QSplitter* newSplitter(Qt::Orientation orientation, QWidget* parent) +{ + QSplitter* s = new QSplitter(orientation, parent); + s->setProperty("ads-splitter", QVariant(true)); + s->setChildrenCollapsible(false); + s->setOpaqueResize(false); + return s; +} + + +} // namespace internal +} // namespace ads + + + +//--------------------------------------------------------------------------- +// EOF ads_globals.cpp diff --git a/AdvancedDockingSystem/src/v2/ads_globals.h b/AdvancedDockingSystem/src/v2/ads_globals.h new file mode 100644 index 0000000..6f1f8e3 --- /dev/null +++ b/AdvancedDockingSystem/src/v2/ads_globals.h @@ -0,0 +1,42 @@ +#ifndef ads_globalsH +#define ads_globalsH +//============================================================================ +/// \file ads_globals.h +/// \author Uwe Kindler +/// \date 24.02.2017 +/// \brief Declaration of +//============================================================================ + + +//============================================================================ +// INCLUDES +//============================================================================ +class QSplitter; + +namespace ads +{ +enum DockWidgetArea +{ + NoDockWidgetArea = 0x00, + LeftDockWidgetArea = 0x01, + RightDockWidgetArea = 0x02, + TopDockWidgetArea = 0x04, + BottomDockWidgetArea = 0x08, + CenterDockWidgetArea = 0x10, + + OuterAreas = TopDockWidgetArea | LeftDockWidgetArea | RightDockWidgetArea | BottomDockWidgetArea, + AllAreas = OuterAreas | CenterDockWidgetArea +}; +Q_DECLARE_FLAGS(DockWidgetAreas, DockWidgetArea) + +namespace internal +{ +/** + * Helper function to create new splitter widgets + */ +QSplitter* newSplitter(Qt::Orientation orientation, QWidget* parent); +} // namespace internal +} // namespace ads + +//--------------------------------------------------------------------------- +#endif // ads_globalsH diff --git a/AdvancedDockingSystemDemo/src/dialogs/SectionContentListModel.h b/AdvancedDockingSystemDemo/src/dialogs/SectionContentListModel.h index 0f8f936..b0aad42 100644 --- a/AdvancedDockingSystemDemo/src/dialogs/SectionContentListModel.h +++ b/AdvancedDockingSystemDemo/src/dialogs/SectionContentListModel.h @@ -5,9 +5,9 @@ #include #include #include +#include "../../../AdvancedDockingSystem/src/SectionContent.h" #include "MainContainerWidget.h" #include "API.h" -#include "SectionContent.h" namespace ads {class CMainContainerWidget;} diff --git a/AdvancedDockingSystemDemo/src/dialogs/SectionContentListWidget.h b/AdvancedDockingSystemDemo/src/dialogs/SectionContentListWidget.h index 6dafb12..255081d 100644 --- a/AdvancedDockingSystemDemo/src/dialogs/SectionContentListWidget.h +++ b/AdvancedDockingSystemDemo/src/dialogs/SectionContentListWidget.h @@ -2,11 +2,11 @@ #define SECTIONCONTENTLISTWIDGET #include +#include "../../../AdvancedDockingSystem/src/SectionContent.h" #include "MainContainerWidget.h" #include "ui_SectionContentListWidget.h" #include "API.h" -#include "SectionContent.h" class SectionContentListWidget : public QDialog { diff --git a/AdvancedDockingSystemDemo/src/mainwindow.h b/AdvancedDockingSystemDemo/src/mainwindow.h index 2a071b1..0405619 100644 --- a/AdvancedDockingSystemDemo/src/mainwindow.h +++ b/AdvancedDockingSystemDemo/src/mainwindow.h @@ -3,8 +3,8 @@ #include #include "../../AdvancedDockingSystem/src/MainContainerWidget.h" +#include "../../AdvancedDockingSystem/src/SectionContent.h" #include "API.h" -#include "SectionContent.h" namespace Ui { class MainWindow;