Line data Source code
1 : /*
2 : * SPDX-License-Identifier: GPL-3.0-only
3 : * MuseScore-CLA-applies
4 : *
5 : * MuseScore Studio
6 : * Music Composition & Notation
7 : *
8 : * Copyright (C) 2021 MuseScore Limited and others
9 : *
10 : * This program is free software: you can redistribute it and/or modify
11 : * it under the terms of the GNU General Public License version 3 as
12 : * published by the Free Software Foundation.
13 : *
14 : * This program is distributed in the hope that it will be useful,
15 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 : * GNU General Public License for more details.
18 : *
19 : * You should have received a copy of the GNU General Public License
20 : * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 : */
22 :
23 : #ifndef MUSE_DOCK_DROPCONTROLLER_H
24 : #define MUSE_DOCK_DROPCONTROLLER_H
25 :
26 : #include "modularity/ioc.h"
27 : #include "../idockwindowprovider.h"
28 :
29 : #include "dockbase.h"
30 :
31 : #include "kddockwidgets/src/core/views/ClassicIndicatorWindowViewInterface.h"
32 : #include "kddockwidgets/src/core/indicators/ClassicDropIndicatorOverlay.h"
33 :
34 : namespace muse::dock {
35 : class DockPanelView;
36 : class DockingHolderView;
37 : class DockToolBarView;
38 : class DockPageView;
39 :
40 : class DropController : public KDDockWidgets::Core::ClassicIndicatorWindowViewInterface, public Contextable
41 : {
42 : ContextInject<IDockWindowProvider> dockWindowProvider = { this };
43 :
44 : public:
45 : explicit DropController(KDDockWidgets::Core::ClassicDropIndicatorOverlay* classicIndicators, KDDockWidgets::Core::View* parent,
46 : const modularity::ContextPtr& iocCtx);
47 :
48 : // ClassicIndicatorWindowViewInterface
49 0 : void setObjectName(const QString&) override {}
50 : KDDockWidgets::DropLocation hover(KDDockWidgets::Point globalPos) override;
51 : KDDockWidgets::Point posForIndicator(KDDockWidgets::DropLocation) const override;
52 0 : void updatePositions() override {}
53 0 : void raise() override {}
54 : void setVisible(bool visible) override;
55 0 : void resize(KDDockWidgets::Size) override {}
56 0 : void setGeometry(KDDockWidgets::Rect) override {}
57 0 : bool isWindow() const override { return false; }
58 0 : void updateIndicatorVisibility() override {}
59 :
60 : private:
61 : void endHover();
62 :
63 : bool isMouseOverDock(const QPoint& mouseLocalPos, const DockBase* dock) const;
64 : void updateToolBarOrientation(DockToolBarView* draggedToolBar, const DropDestination& dropDestination = DropDestination());
65 : void setCurrentDropDestination(const DockBase* draggedDock, const DropDestination& dropDestination);
66 :
67 : DropDestination resolveDropDestination(const DockBase* draggedDock, const QPoint& localPos) const;
68 : DockingHolderView* resolveDockingHolder(DockType draggedDockType, const QPoint& localPos) const;
69 : DockPanelView* resolvePanelForDrop(const DockPanelView* panel, const QPoint& localPos) const;
70 : Location resolveDropLocation(const DockBase* hoveredDock, const QPoint& localPos) const;
71 : QRect resolveHighlightingRect(const DockBase* draggedDock, const DropDestination& destination) const;
72 :
73 : IDockWindow* dockWindow() const;
74 : DockPageView* currentPage() const;
75 : DockBase* draggedDock() const;
76 :
77 : KDDockWidgets::Core::ClassicDropIndicatorOverlay* m_classicIndicators = nullptr;
78 : KDDockWidgets::Core::DropArea* m_dropArea = nullptr;
79 : DropDestination m_currentDropDestination;
80 : };
81 : }
82 :
83 : #endif // MUSE_DOCK_DROPCONTROLLER_H
|