NDEVR
API Documentation
DropOverlay.h
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{
39 class DropOverlayCross;
45 class DropOverlay : public QFrame
46 {
47 Q_OBJECT
48 friend class DropOverlayCross;
49 public:
54 DropOverlay(QWidget* parent);
55 virtual ~DropOverlay();
60 void setAreaWidgets(const QHash<DropArea, QWidget*>& widgets);
72 DropArea showDropOverlay(QWidget* target, QWidget* payload);
78 void showDropOverlay(QWidget* target, const QRect& targetAreaRect);
83 protected:
88 virtual void paintEvent(QPaintEvent* e) override;
93 virtual void showEvent(QShowEvent* e) override;
98 virtual void hideEvent(QHideEvent* e) override;
103 virtual void resizeEvent(QResizeEvent* e) override;
108 virtual void moveEvent(QMoveEvent* e) override;
109 private:
110 DropOverlayCross* _cross;
111 QWidget* m_payload = nullptr;
112 bool _fullAreaDrop;
113 QWidget* _target;
114 QRect _targetRect;
115 DropArea _lastLocation;
116 };
117
120 class DropOverlayCross : public QWidget
121 {
122 Q_OBJECT
123 friend class DropOverlay;
124 public:
129 DropOverlayCross(DropOverlay* overlay);
130 virtual ~DropOverlayCross();
135 void setAreaWidgets(const QHash<DropArea, QWidget*>& widgets);
141 protected:
146 virtual void showEvent(QShowEvent* e);
147 private:
151 void reset();
152 private:
153 DropOverlay* _overlay;
154 QHash<DropArea, QWidget*> _widgets;
155 QGridLayout* _grid;
156 };
157}
158
Shows a cross with 5 different drop area possibilities.
DropOverlayCross(DropOverlay *overlay)
Constructs the cross overlay for the given DropOverlay parent.
void setAreaWidgets(const QHash< DropArea, QWidget * > &widgets)
Sets the mapping of drop areas to their corresponding indicator widgets.
virtual void showEvent(QShowEvent *e)
Handles the show event to position the cross indicator widgets.
DropArea cursorLocation() const
Returns the drop area currently under the mouse cursor.
virtual void paintEvent(QPaintEvent *e) override
Paints the translucent drop indicator rectangle.
void setAreaWidgets(const QHash< DropArea, QWidget * > &widgets)
Sets the mapping of drop areas to their corresponding indicator widgets.
void hideDropOverlay()
Hides the drop overlay.
DropArea showDropOverlay(QWidget *target, QWidget *payload)
Shows the drop overlay over the target widget for the given payload.
virtual void moveEvent(QMoveEvent *e) override
Handles move events to update overlay positioning.
virtual void showEvent(QShowEvent *e) override
Handles the show event to update overlay positioning.
DropArea cursorLocation() const
Returns the drop area currently under the mouse cursor.
virtual void resizeEvent(QResizeEvent *e) override
Handles resize events to update overlay geometry.
void showDropOverlay(QWidget *target, const QRect &targetAreaRect)
Shows the drop overlay over the target widget constrained to a specific rectangle.
virtual void hideEvent(QHideEvent *e) override
Handles the hide event to clean up overlay state.
DropOverlay(QWidget *parent)
Constructs a DropOverlay with the given parent widget.
The primary namespace for the NDEVR SDK.
DropArea
relates where a widget should be dropped relative to another.
Definition RibbonArea.h:46