Move DropArea into Controllers namespace

In preparation for View/Controller split.
This commit is contained in:
Sergio Martins
2022-04-23 12:14:30 +01:00
parent daa6afd14c
commit 860a1a1bb0
20 changed files with 55 additions and 44 deletions

View File

@@ -26,9 +26,9 @@ QT_END_NAMESPACE
namespace KDDockWidgets {
class DropIndicatorOverlayInterface;
class DropArea;
namespace Controllers {
class DropArea;
class Separator;
class TabBar;
class SideBar;
@@ -114,7 +114,7 @@ public:
///@brief Called internally by the framework to create a DropIndicatorOverlayInterface
/// Override to provide your own DropIndicatorOverlayInterface sub-class.
///@param dropArea Just forward to DropIndicatorOverlayInterface's constructor.
virtual DropIndicatorOverlayInterface *createDropIndicatorOverlay(DropArea *dropArea) const = 0;
virtual DropIndicatorOverlayInterface *createDropIndicatorOverlay(Controllers::DropArea *dropArea) const = 0;
///@brief Called internally by the framework to create a RubberBand to show as drop zone
/// Returns a rubber band

View File

@@ -39,7 +39,10 @@ namespace KDDockWidgets {
DOCKS_EXPORT
Q_NAMESPACE
class MultiSplitter;
namespace Controllers {
class DropArea;
}
enum Location {
Location_None,
@@ -173,7 +176,7 @@ private:
friend class Layouting::Item;
friend class Layouting::ItemBoxContainer;
friend class KDDockWidgets::MultiSplitter;
friend class KDDockWidgets::DropArea;
friend class KDDockWidgets::Controllers::DropArea;
InitialOption(DefaultSizeMode mode)
: sizeMode(mode)

View File

@@ -16,7 +16,10 @@
namespace KDDockWidgets {
namespace Controllers {
class DropArea;
}
/// @brief The base class for view wrappers
/// A view wrapper is a view that doesn't own the native GUI element(QWidget, QQuickItem etc.)
@@ -66,7 +69,7 @@ public:
void setMouseTracking(bool) override;
/// TODOv2: Remove
virtual DropArea *asDropArea() const
virtual Controllers::DropArea *asDropArea() const
{
return {};
};

View File

@@ -18,6 +18,7 @@
#ifndef KD_DROP_AREA_P_H
#define KD_DROP_AREA_P_H
#pragma once
#include "kddockwidgets/docks_export.h"
#include "kddockwidgets/KDDockWidgets.h"
@@ -30,13 +31,12 @@ class TestDocks;
namespace KDDockWidgets {
class Draggable;
struct WindowBeingDragged;
namespace Controllers {
class Frame;
class DockWidget;
}
class Draggable;
struct WindowBeingDragged;
/**
* @brief A MultiSplitter with support for drop indicators when hovering over.
@@ -59,10 +59,10 @@ public:
{
return m_dropIndicatorOverlay;
}
void addDockWidget(Controllers::DockWidget *, KDDockWidgets::Location location,
Controllers::DockWidget *relativeTo, InitialOption = {});
void addDockWidget(DockWidget *, KDDockWidgets::Location location,
DockWidget *relativeTo, InitialOption = {});
bool containsDockWidget(Controllers::DockWidget *) const;
bool containsDockWidget(DockWidget *) const;
/// Returns whether this layout has a single dock widget which is floating
/// Implies it's in a FloatingWindow and that it has only one dock widget
@@ -73,7 +73,7 @@ public:
bool hasSingleFrame() const;
QStringList affinities() const;
void layoutParentContainerEqually(Controllers::DockWidget *);
void layoutParentContainerEqually(DockWidget *);
/// When DockWidget::Option_MDINestable is used, docked MDI dock widgets will be wrapped inside a DropArea, so they accept drops
/// This DropArea is created implicitly while docking, and this function will return true
@@ -108,5 +108,6 @@ private:
Controllers::Frame *const m_centralFrame = nullptr;
};
}
}
#endif

View File

@@ -22,13 +22,13 @@
#include "kddockwidgets/docks_export.h"
namespace KDDockWidgets {
class DropArea;
class MultiSplitter;
class LayoutWidget;
}
namespace KDDockWidgets::Controllers {
class DropArea;
class Frame;
class MainWindow;
class TitleBar;

View File

@@ -32,13 +32,12 @@ class TestDocks;
namespace KDDockWidgets {
class DropArea;
class MDILayoutWidget;
class MultiSplitter;
class LayoutWidget;
class DropArea;
namespace Controllers {
class DropArea;
class Frame;
class SideBar;
class DockWidget;

View File

@@ -27,11 +27,14 @@ namespace KDDockWidgets {
class StateBase;
class StateNone;
class StateInternalMDIDragging;
class DropArea;
class Draggable;
class FallbackMouseGrabber;
class MinimalStateMachine;
namespace Controllers {
class DropArea;
}
class State : public QObject
{
Q_OBJECT
@@ -124,7 +127,7 @@ private:
DragController(QObject * = nullptr);
StateBase *activeState() const;
ViewWrapper::Ptr qtTopLevelUnderCursor() const;
DropArea *dropAreaUnderCursor() const;
Controllers::DropArea *dropAreaUnderCursor() const;
Draggable *draggableForQObject(QObject *o) const;
QPoint m_pressPos;
QPoint m_offset;
@@ -133,7 +136,7 @@ private:
Draggable *m_draggable = nullptr;
QPointer<QObject> m_draggableGuard; // Just so we know if the draggable was destroyed for some reason
std::unique_ptr<WindowBeingDragged> m_windowBeingDragged;
DropArea *m_currentDropArea = nullptr;
Controllers::DropArea *m_currentDropArea = nullptr;
bool m_nonClientDrag = false;
FallbackMouseGrabber *m_fallbackMouseGrabber = nullptr;
StateNone *m_stateNone = nullptr;
@@ -166,19 +169,19 @@ public:
}
// Only interesting for Wayland
virtual bool handleDragEnter(QDragEnterEvent *, DropArea *)
virtual bool handleDragEnter(QDragEnterEvent *, Controllers::DropArea *)
{
return false;
}
virtual bool handleDragLeave(DropArea *)
virtual bool handleDragLeave(Controllers::DropArea *)
{
return false;
}
virtual bool handleDragMove(QDragMoveEvent *, DropArea *)
virtual bool handleDragMove(QDragMoveEvent *, Controllers::DropArea *)
{
return false;
}
virtual bool handleDrop(QDropEvent *, DropArea *)
virtual bool handleDrop(QDropEvent *, Controllers::DropArea *)
{
return false;
}
@@ -252,10 +255,10 @@ public:
~StateDraggingWayland() override;
void onEntry() override;
bool handleMouseButtonRelease(QPoint globalPos) override;
bool handleDragEnter(QDragEnterEvent *, DropArea *) override;
bool handleDragMove(QDragMoveEvent *, DropArea *) override;
bool handleDragLeave(DropArea *) override;
bool handleDrop(QDropEvent *, DropArea *) override;
bool handleDragEnter(QDragEnterEvent *, Controllers::DropArea *) override;
bool handleDragMove(QDragMoveEvent *, Controllers::DropArea *) override;
bool handleDragLeave(Controllers::DropArea *) override;
bool handleDrop(QDropEvent *, Controllers::DropArea *) override;
bool m_inQDrag = false;
};

View File

@@ -21,7 +21,7 @@
using namespace KDDockWidgets;
using namespace KDDockWidgets::Controllers;
DropIndicatorOverlayInterface::DropIndicatorOverlayInterface(DropArea *dropArea)
DropIndicatorOverlayInterface::DropIndicatorOverlayInterface(Controllers::DropArea *dropArea)
: Views::View_qtwidgets<QWidget>(nullptr, Type::DropIndicatorOverlayInterface, dropArea)
, m_dropArea(dropArea)
{

View File

@@ -20,7 +20,9 @@
namespace KDDockWidgets {
class DropArea;
namespace Controllers {
class DropARea;
}
class DOCKS_EXPORT DropIndicatorOverlayInterface : public Views::View_qtwidgets<QWidget>
{
@@ -28,7 +30,7 @@ class DOCKS_EXPORT DropIndicatorOverlayInterface : public Views::View_qtwidgets<
Q_PROPERTY(QRect hoveredFrameRect READ hoveredFrameRect NOTIFY hoveredFrameRectChanged)
Q_PROPERTY(KDDockWidgets::DropLocation currentDropLocation READ currentDropLocation NOTIFY currentDropLocationChanged)
public:
explicit DropIndicatorOverlayInterface(DropArea *dropArea);
explicit DropIndicatorOverlayInterface(Controllers::DropArea *dropArea);
void setHoveredFrame(Controllers::Frame *);
void setWindowBeingDragged(bool);
QRect hoveredFrameRect() const;
@@ -71,7 +73,7 @@ protected:
virtual void updateVisibility() {};
Controllers::Frame *m_hoveredFrame = nullptr;
DropArea *const m_dropArea;
Controllers::DropArea *const m_dropArea;
bool m_draggedWindowIsHovering = false;
};

View File

@@ -32,7 +32,7 @@ static IndicatorWindow *createIndicatorWindow(ClassicIndicators *classicIndicato
return window;
}
ClassicIndicators::ClassicIndicators(DropArea *dropArea)
ClassicIndicators::ClassicIndicators(Controllers::DropArea *dropArea)
: DropIndicatorOverlayInterface(dropArea) // Is parented on the drop-area, not a toplevel.
, m_rubberBand(Config::self().frameworkWidgetFactory()->createRubberBand(rubberBandIsTopLevel() ? nullptr : dropArea))
, m_indicatorWindow(createIndicatorWindow(this))

View File

@@ -37,7 +37,7 @@ class DOCKS_EXPORT ClassicIndicators : public DropIndicatorOverlayInterface
Q_PROPERTY(bool tabIndicatorVisible READ tabIndicatorVisible NOTIFY indicatorsVisibleChanged)
public:
explicit ClassicIndicators(DropArea *dropArea);
explicit ClassicIndicators(Controllers::DropArea *dropArea);
~ClassicIndicators() override;
DropLocation hover_impl(QPoint globalPos) override;
QPoint posForIndicator(DropLocation) const override;

View File

@@ -13,7 +13,7 @@
namespace KDDockWidgets {
NullIndicators::NullIndicators(DropArea *dropArea)
NullIndicators::NullIndicators(Controllers::DropArea *dropArea)
: DropIndicatorOverlayInterface(dropArea)
{
}

View File

@@ -25,7 +25,7 @@ class DOCKS_EXPORT NullIndicators : public DropIndicatorOverlayInterface
{
Q_OBJECT
public:
explicit NullIndicators(DropArea *);
explicit NullIndicators(Controllers::DropArea *);
~NullIndicators() override;
DropLocation hover_impl(QPoint) override
{

View File

@@ -26,7 +26,7 @@ QColor SegmentedIndicators::s_segmentBrushColor = QColor(0xbb, 0xd5, 0xee, /*alp
QColor SegmentedIndicators::s_hoveredSegmentBrushColor = QColor(0x3574c5);
SegmentedIndicators::SegmentedIndicators(DropArea *dropArea)
SegmentedIndicators::SegmentedIndicators(Controllers::DropArea *dropArea)
: DropIndicatorOverlayInterface(dropArea)
{
// If the app didn't choose opacity then we choose a suitable default value.

View File

@@ -23,7 +23,7 @@ class DOCKS_EXPORT SegmentedIndicators : public DropIndicatorOverlayInterface
{
Q_OBJECT
public:
explicit SegmentedIndicators(DropArea *dropArea);
explicit SegmentedIndicators(Controllers::DropArea *dropArea);
~SegmentedIndicators() override;
DropLocation hover_impl(QPoint globalPos) override;

View File

@@ -96,7 +96,7 @@ View *DefaultWidgetFactory_qtwidgets::createFloatingWindow(Controllers::Floating
return new Views::FloatingWindow_qtwidgets(controller, mainwindow, windowFlags);
}
DropIndicatorOverlayInterface *DefaultWidgetFactory_qtwidgets::createDropIndicatorOverlay(DropArea *dropArea) const
DropIndicatorOverlayInterface *DefaultWidgetFactory_qtwidgets::createDropIndicatorOverlay(Controllers::DropArea *dropArea) const
{
#ifdef Q_OS_WASM
// On WASM windows don't support translucency, which is required for the classic indicators.

View File

@@ -34,9 +34,9 @@ class Widget;
namespace KDDockWidgets {
class DropIndicatorOverlayInterface;
class DropArea;
namespace Controllers {
class DropArea;
class Separator;
class TabBar;
class SideBar;
@@ -64,7 +64,7 @@ public:
View *createFloatingWindow(Controllers::FloatingWindow *,
Controllers::MainWindow *parent = nullptr,
Qt::WindowFlags windowFlags = {}) const override;
DropIndicatorOverlayInterface *createDropIndicatorOverlay(DropArea *) const override;
DropIndicatorOverlayInterface *createDropIndicatorOverlay(Controllers::DropArea *) const override;
QWidgetOrQuick *createRubberBand(QWidgetOrQuick *parent) const override;
View *createSideBar(Controllers::SideBar *, Controllers::MainWindow *parent) const override;

View File

@@ -300,9 +300,9 @@ bool ViewWrapper_qtwidgets::isNull() const
return m_widget.data() == nullptr;
}
DropArea *ViewWrapper_qtwidgets::asDropArea() const
Controllers::DropArea *ViewWrapper_qtwidgets::asDropArea() const
{
return qobject_cast<DropArea *>(m_widget);
return qobject_cast<Controllers::DropArea *>(m_widget);
}
QWidget *ViewWrapper_qtwidgets::widget() const

View File

@@ -57,7 +57,7 @@ public:
bool isNull() const override;
void setWindowTitle(const QString &title) override;
QPoint mapTo(View *, QPoint) const override;
DropArea *asDropArea() const override;
Controllers::DropArea *asDropArea() const override;
QWidget *widget() const;

View File

@@ -144,7 +144,7 @@ Controllers::DockWidget *createDockWidget(const QString &name, QWidgetOrQuick *w
bool show = true, const QString &affinityName = {});
Controllers::DockWidget *createDockWidget(const QString &name, QColor color = Qt::black);
void nestDockWidget(Controllers::DockWidget *dock, DropArea *dropArea, Controllers::Frame *relativeTo,
void nestDockWidget(Controllers::DockWidget *dock, Controllers::DropArea *dropArea, Controllers::Frame *relativeTo,
KDDockWidgets::Location location);
class MyWidget : public QWidgetOrQuick
@@ -422,7 +422,7 @@ inline void dragFloatingWindowTo(Controllers::FloatingWindow *fw, QPoint globalD
drag(draggable, draggable->mapToGlobal(QPoint(10, 10)), globalDest, buttonActions);
}
inline void dragFloatingWindowTo(Controllers::FloatingWindow *fw, DropArea *target, DropLocation dropLocation)
inline void dragFloatingWindowTo(Controllers::FloatingWindow *fw, Controllers::DropArea *target, DropLocation dropLocation)
{
auto draggable = draggableFor(fw->view());
Q_ASSERT(draggable);