diff --git a/src/private/indicators/ClassicIndicators.cpp b/src/private/indicators/ClassicIndicators.cpp deleted file mode 100644 index 33904004..00000000 --- a/src/private/indicators/ClassicIndicators.cpp +++ /dev/null @@ -1,241 +0,0 @@ -/* - This file is part of KDDockWidgets. - - SPDX-FileCopyrightText: 2019-2022 Klarälvdalens Datakonsult AB, a KDAB Group company - Author: Sérgio Martins - - SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only - - Contact KDAB at for commercial licensing options. -*/ - -#include "ClassicIndicators_p.h" -#include "Config.h" -#include "FrameworkWidgetFactory.h" -#include "ClassicIndicatorsWindow_p.h" - -#include "controllers/DropArea.h" -#include "private/DragController_p.h" -#include "private/Logging_p.h" -#include "private/DockRegistry_p.h" -#include "private/Utils_p.h" - -#include "controllers/Frame.h" - -using namespace KDDockWidgets; -using namespace KDDockWidgets::Controllers; - -static IndicatorWindow *createIndicatorWindow(ClassicIndicators *classicIndicators) -{ - auto window = new IndicatorWindow(classicIndicators); - window->setObjectName(QStringLiteral("_docks_IndicatorWindow_Overlay")); - - return window; -} - -ClassicIndicators::ClassicIndicators(Controllers::DropArea *dropArea) - : DropIndicatorOverlay(dropArea) // Is parented on the drop-area, not a toplevel. - , m_rubberBand(Config::self().frameworkWidgetFactory()->createRubberBand(rubberBandIsTopLevel() ? nullptr : dropArea->view())) - , m_indicatorWindow(createIndicatorWindow(this)) -{ - if (rubberBandIsTopLevel()) - m_rubberBand->setWindowOpacity(0.5); -} - -ClassicIndicators::~ClassicIndicators() -{ - delete m_indicatorWindow; -} - -DropLocation ClassicIndicators::hover_impl(QPoint globalPos) -{ - return m_indicatorWindow->hover(globalPos); -} - -QPoint ClassicIndicators::posForIndicator(DropLocation loc) const -{ - return m_indicatorWindow->posForIndicator(loc); -} - -bool ClassicIndicators::innerLeftIndicatorVisible() const -{ - return dropIndicatorVisible(DropLocation_Left); -} - -bool ClassicIndicators::innerRightIndicatorVisible() const -{ - return dropIndicatorVisible(DropLocation_Right); -} - -bool ClassicIndicators::innerTopIndicatorVisible() const -{ - return dropIndicatorVisible(DropLocation_Top); -} - -bool ClassicIndicators::innerBottomIndicatorVisible() const -{ - return dropIndicatorVisible(DropLocation_Bottom); -} - -bool ClassicIndicators::outterLeftIndicatorVisible() const -{ - return dropIndicatorVisible(DropLocation_OutterLeft); -} - -bool ClassicIndicators::outterRightIndicatorVisible() const -{ - return dropIndicatorVisible(DropLocation_OutterRight); -} - -bool ClassicIndicators::outterTopIndicatorVisible() const -{ - return dropIndicatorVisible(DropLocation_OutterTop); -} - -bool ClassicIndicators::outterBottomIndicatorVisible() const -{ - return dropIndicatorVisible(DropLocation_OutterBottom); -} - -bool ClassicIndicators::tabIndicatorVisible() const -{ - return dropIndicatorVisible(DropLocation_Center); -} - -bool ClassicIndicators::onResize(QSize) -{ - m_indicatorWindow->resize(window()->size()); - return false; -} - -void ClassicIndicators::updateVisibility() -{ - if (isHovered()) { - m_indicatorWindow->updatePositions(); - m_indicatorWindow->setVisible(true); - updateWindowPosition(); - raiseIndicators(); - } else { - m_rubberBand->setVisible(false); - m_indicatorWindow->setVisible(false); - } - - Q_EMIT indicatorsVisibleChanged(); -} - -void ClassicIndicators::raiseIndicators() -{ - m_indicatorWindow->raise(); -} - -KDDockWidgets::Location locationToMultisplitterLocation(DropLocation location) -{ - switch (location) { - case DropLocation_Left: - return KDDockWidgets::Location_OnLeft; - case DropLocation_Top: - return KDDockWidgets::Location_OnTop; - case DropLocation_Right: - return KDDockWidgets::Location_OnRight; - case DropLocation_Bottom: - return KDDockWidgets::Location_OnBottom; - case DropLocation_OutterLeft: - return KDDockWidgets::Location_OnLeft; - case DropLocation_OutterTop: - return KDDockWidgets::Location_OnTop; - case DropLocation_OutterRight: - return KDDockWidgets::Location_OnRight; - case DropLocation_OutterBottom: - return KDDockWidgets::Location_OnBottom; - default: - return KDDockWidgets::Location_None; - } -} - -void ClassicIndicators::setDropLocation(DropLocation location) -{ - setCurrentDropLocation(location); - - if (location == DropLocation_None) { - m_rubberBand->setVisible(false); - return; - } - - if (location == DropLocation_Center) { - m_rubberBand->setGeometry(geometryForRubberband(m_hoveredFrame ? m_hoveredFrame->view()->geometry() : rect())); - m_rubberBand->setVisible(true); - if (rubberBandIsTopLevel()) { - m_rubberBand->raise(); - raiseIndicators(); - } - - return; - } - - KDDockWidgets::Location multisplitterLocation = locationToMultisplitterLocation(location); - Controllers::Frame *relativeToFrame = nullptr; - - switch (location) { - case DropLocation_Left: - case DropLocation_Top: - case DropLocation_Right: - case DropLocation_Bottom: - if (!m_hoveredFrame) { - qWarning() << "ClassicIndicators::setCurrentDropLocation: frame is null. location=" << location - << "; isHovered=" << isHovered() - << "; dropArea->widgets=" << m_dropArea->items(); - Q_ASSERT(false); - return; - } - relativeToFrame = m_hoveredFrame; - break; - case DropLocation_OutterLeft: - case DropLocation_OutterTop: - case DropLocation_OutterRight: - case DropLocation_OutterBottom: - break; - default: - break; - } - - auto windowBeingDragged = DragController::instance()->windowBeingDragged(); - - QRect rect = m_dropArea->rectForDrop(windowBeingDragged, multisplitterLocation, - m_dropArea->itemForFrame(relativeToFrame)); - - m_rubberBand->setGeometry(geometryForRubberband(rect)); - m_rubberBand->setVisible(true); - if (rubberBandIsTopLevel()) { - m_rubberBand->raise(); - raiseIndicators(); - } -} - -void ClassicIndicators::updateWindowPosition() -{ - QRect rect = this->rect(); - if (KDDockWidgets::isWindow(m_indicatorWindow)) { - // On all non-wayland platforms it's a top-level. - QPoint pos = mapToGlobal(QPoint(0, 0)); - rect.moveTo(pos); - } - m_indicatorWindow->setGeometry(rect); -} - -bool ClassicIndicators::rubberBandIsTopLevel() const -{ - return Config::self().internalFlags() & Config::InternalFlag_TopLevelIndicatorRubberBand; -} - -QRect ClassicIndicators::geometryForRubberband(QRect localRect) const -{ - if (!rubberBandIsTopLevel()) - return localRect; - - QPoint topLeftLocal = localRect.topLeft(); - QPoint topLeftGlobal = m_dropArea->mapToGlobal(topLeftLocal); - - localRect.moveTopLeft(topLeftGlobal); - - return localRect; -} diff --git a/src/private/indicators/ClassicIndicators_p.h b/src/private/indicators/ClassicIndicators_p.h deleted file mode 100644 index 918fdb1b..00000000 --- a/src/private/indicators/ClassicIndicators_p.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - This file is part of KDDockWidgets. - - SPDX-FileCopyrightText: 2019-2022 Klarälvdalens Datakonsult AB, a KDAB Group company - Author: Sérgio Martins - - SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only - - Contact KDAB at for commercial licensing options. -*/ - -#ifndef KD_INDICATORS_CLASSICINDICATORS_P_H -#define KD_INDICATORS_CLASSICINDICATORS_P_H - -#include "../DropIndicatorOverlay.h" - -namespace KDDockWidgets { - -class IndicatorWindow; -class Indicator; - -namespace Controllers { - -class DOCKS_EXPORT ClassicIndicators : public DropIndicatorOverlay -{ - Q_OBJECT - - // Properties for QML - Q_PROPERTY(bool innerLeftIndicatorVisible READ innerLeftIndicatorVisible NOTIFY indicatorsVisibleChanged) - Q_PROPERTY(bool innerRightIndicatorVisible READ innerRightIndicatorVisible NOTIFY indicatorsVisibleChanged) - Q_PROPERTY(bool innerTopIndicatorVisible READ innerTopIndicatorVisible NOTIFY indicatorsVisibleChanged) - Q_PROPERTY(bool innerBottomIndicatorVisible READ innerBottomIndicatorVisible NOTIFY indicatorsVisibleChanged) - - Q_PROPERTY(bool outterLeftIndicatorVisible READ outterLeftIndicatorVisible NOTIFY indicatorsVisibleChanged) - Q_PROPERTY(bool outterRightIndicatorVisible READ outterRightIndicatorVisible NOTIFY indicatorsVisibleChanged) - Q_PROPERTY(bool outterTopIndicatorVisible READ outterTopIndicatorVisible NOTIFY indicatorsVisibleChanged) - Q_PROPERTY(bool outterBottomIndicatorVisible READ outterBottomIndicatorVisible NOTIFY indicatorsVisibleChanged) - - Q_PROPERTY(bool tabIndicatorVisible READ tabIndicatorVisible NOTIFY indicatorsVisibleChanged) - -public: - explicit ClassicIndicators(Controllers::DropArea *dropArea); - ~ClassicIndicators() override; - DropLocation hover_impl(QPoint globalPos) override; - QPoint posForIndicator(DropLocation) const override; - - // Lots of getters needed because of QML: - bool innerLeftIndicatorVisible() const; - bool innerRightIndicatorVisible() const; - bool innerTopIndicatorVisible() const; - bool innerBottomIndicatorVisible() const; - bool outterLeftIndicatorVisible() const; - bool outterRightIndicatorVisible() const; - bool outterTopIndicatorVisible() const; - bool outterBottomIndicatorVisible() const; - bool tabIndicatorVisible() const; - - bool onResize(QSize newSize); - -protected: - void updateVisibility() override; -Q_SIGNALS: - void indicatorsVisibleChanged(); - -private: - friend class KDDockWidgets::Indicator; - friend class KDDockWidgets::IndicatorWindow; - bool rubberBandIsTopLevel() const; - void raiseIndicators(); - QRect geometryForRubberband(QRect localRect) const; - void setDropLocation(DropLocation); - void updateWindowPosition(); - - View *const m_rubberBand; - IndicatorWindow *const m_indicatorWindow; -}; - -} - -} - -#endif diff --git a/src/private/indicators/SegmentedIndicators_p.h b/src/private/indicators/SegmentedIndicators_p.h deleted file mode 100644 index ce7ec0bb..00000000 --- a/src/private/indicators/SegmentedIndicators_p.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - This file is part of KDDockWidgets. - - SPDX-FileCopyrightText: 2019-2022 Klarälvdalens Datakonsult AB, a KDAB Group company - Author: Sérgio Martins - - SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only - - Contact KDAB at for commercial licensing options. -*/ - -#ifndef KD_SEGMENTED_INDICATORS_P_H -#define KD_SEGMENTED_INDICATORS_P_H - -#include "../DropIndicatorOverlay.h" - -#include -#include - -namespace KDDockWidgets { - -namespace Controllers { - -class DOCKS_EXPORT SegmentedIndicators : public DropIndicatorOverlay -{ - Q_OBJECT -public: - explicit SegmentedIndicators(Controllers::DropArea *dropArea); - ~SegmentedIndicators() override; - DropLocation hover_impl(QPoint globalPos) override; - - DropLocation dropLocationForPos(QPoint pos) const; - QPoint hoveredPt() const; - QHash segments() const; - - static int s_segmentGirth; - static int s_segmentPenWidth; - static qreal s_draggedWindowOpacity; - static QColor s_segmentPenColor; - static QColor s_segmentBrushColor; - static QColor s_hoveredSegmentBrushColor; - -protected: - QPoint posForIndicator(DropLocation) const override; - -private: - QHash segmentsForRect(QRect, bool inner, bool useOffset = false) const; - void updateSegments(); - QPoint m_hoveredPt = {}; - QHash m_segments; -}; - -} - -} - -#endif