API Documentation
Loading...
Searching...
No Matches
DropOverlay.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: Widgets
28File: DropOverlay
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33class QGridLayout;
34
35#include <NDEVR/RibbonArea.h>
36#include <QFrame>
37namespace NDEVR
38{
39class DropOverlayCross;
40
41/*!
42 * DropOverlay paints a translucent rectangle over another widget. The geometry
43 * of the rectangle is based on the mouse location.
44 */
45class DropOverlay : public QFrame
46{
47 Q_OBJECT
48 friend class DropOverlayCross;
49
50public:
51 DropOverlay(QWidget* parent);
52 virtual ~DropOverlay();
53
54
55 void setAreaWidgets(const QHash<DropArea, QWidget*>& widgets);
56
58
59 DropArea showDropOverlay(QWidget* target, QWidget* payload);
60 void showDropOverlay(QWidget* target, const QRect& targetAreaRect);
62
63protected:
64 virtual void paintEvent(QPaintEvent *e) override;
65 virtual void showEvent(QShowEvent* e) override;
66 virtual void hideEvent(QHideEvent* e) override;
67 virtual void resizeEvent(QResizeEvent* e) override;
68 virtual void moveEvent(QMoveEvent* e) override;
69
70private:
71 DropOverlayCross* _cross;
72 QWidget* m_payload = nullptr;
73 bool _fullAreaDrop;
74 QWidget* _target;
75 QRect _targetRect;
76 DropArea _lastLocation;
77};
78
79/*!
80 * DropOverlayCross shows a cross with 5 different drop area possibilities.
81 * I could have handled everything inside DropOverlay, but because of some
82 * styling issues it's better to have a separate class for the cross.
83 */
84class DropOverlayCross : public QWidget
85{
86 Q_OBJECT
87 friend class DropOverlay;
88
89public:
92
93 void setAreaWidgets(const QHash<DropArea, QWidget*>& widgets);
95
96protected:
97 virtual void showEvent(QShowEvent* e);
98
99private:
100 void reset();
101
102private:
103 DropOverlay* _overlay;
104 QHash<DropArea, QWidget*> _widgets;
105 QGridLayout* _grid;
106};
107}
108
Definition DropOverlay.h:85
DropArea cursorLocation() const
DropOverlayCross(DropOverlay *overlay)
virtual void showEvent(QShowEvent *e)
void setAreaWidgets(const QHash< DropArea, QWidget * > &widgets)
Definition DropOverlay.h:46
virtual void resizeEvent(QResizeEvent *e) override
virtual void hideEvent(QHideEvent *e) override
virtual void moveEvent(QMoveEvent *e) override
void showDropOverlay(QWidget *target, const QRect &targetAreaRect)
DropArea cursorLocation() const
DropArea showDropOverlay(QWidget *target, QWidget *payload)
virtual void paintEvent(QPaintEvent *e) override
DropOverlay(QWidget *parent)
virtual ~DropOverlay()
virtual void showEvent(QShowEvent *e) override
void setAreaWidgets(const QHash< DropArea, QWidget * > &widgets)
Definition ACIColor.h:37
DropArea
relates where a widget should be dropped relative to another.
Definition RibbonArea.h:46