BornAgain
1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
WidgetMoverButton.h
Go to the documentation of this file.
1
// ************************************************************************************************
2
//
3
// BornAgain: simulate and fit reflection and scattering
4
//
5
//! @file GUI/View/SampleDesigner/WidgetMoverButton.h
6
//! @brief Defines class WidgetMoverButton
7
//!
8
//! @homepage http://www.bornagainproject.org
9
//! @license GNU General Public License v3 or higher (see COPYING)
10
//! @copyright Forschungszentrum Jülich GmbH 2021
11
//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12
//
13
// ************************************************************************************************
14
15
#ifndef BORNAGAIN_GUI_VIEW_SAMPLEDESIGNER_WIDGETMOVERBUTTON_H
16
#define BORNAGAIN_GUI_VIEW_SAMPLEDESIGNER_WIDGETMOVERBUTTON_H
17
18
#include <QMap>
19
#include <QTimer>
20
#include <QToolButton>
21
22
class
QScrollArea;
23
class
QPropertyAnimation;
24
25
//! Button to move a widget vertically in a layout.
26
//!
27
//! With this button, the "move layer" feature in the layer oriented sample editor is realized
28
//! (it is the button on each LayerForm).
29
//!
30
//! When pressing the button, the parent layout of the widget is deactivated, and the widget is
31
//! moved to the position where the pressed mouse cursor is moved.
32
//! When the mouse is released, the layout is again activated and a signal finishedMoving() is
33
//! emitted. Any reordering of the widgets in the layout then has to be handled outside - no
34
//! reordering is done in here.
35
class
WidgetMoverButton
:
public
QToolButton {
36
Q_OBJECT
37
public
:
38
//! Create a widget mover button.
39
//!
40
//! If the widget shall not be able to be dragged on the top position, this can be defined by
41
//! ignoreOnTop (the number of widgets at the top of the layout which shall not be affected by
42
//! the reordering). In the case of the layer moving, the topmost Form (the sample
43
//! properties) shall not be part of reordering.
44
WidgetMoverButton
(QWidget* parent, QWidget* widgetToMove,
int
ignoreOnTop = 0);
45
46
protected
:
47
void
mousePressEvent
(QMouseEvent* event)
override
;
48
void
mouseReleaseEvent
(QMouseEvent* event)
override
;
49
void
mouseMoveEvent
(QMouseEvent* event)
override
;
50
51
signals:
52
void
startingToMove
();
53
void
finishedMoving
(QWidget* widgetToMove, QWidget* moveAboveThisWidget);
54
55
private
:
56
void
scrollParent
(
bool
up);
57
58
private
:
59
bool
m_started
=
false
;
60
int
m_globalMouseDownY
;
61
QLayout*
m_layoutToDeactivate
=
nullptr
;
62
QWidget*
m_widgetToMove
;
63
QWidget*
m_dropAboveThisWidget
;
64
int
m_originalWidgetY
;
65
int
m_yOfFirstRelevantWidget
;
66
int
m_ignoreOnTop
;
67
QTimer
m_dragScrollTimer
;
68
QScrollArea*
m_scrollArea
;
69
QPoint
m_hotSpot
;
//!< The mouse-down coordinates in the widget to move
70
QMap<QWidget*, QPropertyAnimation*>
m_animations
;
71
};
72
73
74
#endif
// BORNAGAIN_GUI_VIEW_SAMPLEDESIGNER_WIDGETMOVERBUTTON_H
WidgetMoverButton
Button to move a widget vertically in a layout.
Definition:
WidgetMoverButton.h:35
WidgetMoverButton::mouseMoveEvent
void mouseMoveEvent(QMouseEvent *event) override
Definition:
WidgetMoverButton.cpp:67
WidgetMoverButton::m_globalMouseDownY
int m_globalMouseDownY
Definition:
WidgetMoverButton.h:60
WidgetMoverButton::m_ignoreOnTop
int m_ignoreOnTop
Definition:
WidgetMoverButton.h:66
WidgetMoverButton::mousePressEvent
void mousePressEvent(QMouseEvent *event) override
Definition:
WidgetMoverButton.cpp:34
WidgetMoverButton::WidgetMoverButton
WidgetMoverButton(QWidget *parent, QWidget *widgetToMove, int ignoreOnTop=0)
Create a widget mover button.
Definition:
WidgetMoverButton.cpp:23
WidgetMoverButton::mouseReleaseEvent
void mouseReleaseEvent(QMouseEvent *event) override
Definition:
WidgetMoverButton.cpp:50
WidgetMoverButton::m_scrollArea
QScrollArea * m_scrollArea
Definition:
WidgetMoverButton.h:68
WidgetMoverButton::m_layoutToDeactivate
QLayout * m_layoutToDeactivate
Definition:
WidgetMoverButton.h:61
WidgetMoverButton::finishedMoving
void finishedMoving(QWidget *widgetToMove, QWidget *moveAboveThisWidget)
WidgetMoverButton::m_yOfFirstRelevantWidget
int m_yOfFirstRelevantWidget
Definition:
WidgetMoverButton.h:65
WidgetMoverButton::m_animations
QMap< QWidget *, QPropertyAnimation * > m_animations
Definition:
WidgetMoverButton.h:70
WidgetMoverButton::m_started
bool m_started
Definition:
WidgetMoverButton.h:59
WidgetMoverButton::startingToMove
void startingToMove()
WidgetMoverButton::m_dropAboveThisWidget
QWidget * m_dropAboveThisWidget
Definition:
WidgetMoverButton.h:63
WidgetMoverButton::m_widgetToMove
QWidget * m_widgetToMove
Definition:
WidgetMoverButton.h:62
WidgetMoverButton::scrollParent
void scrollParent(bool up)
Definition:
WidgetMoverButton.cpp:155
WidgetMoverButton::m_dragScrollTimer
QTimer m_dragScrollTimer
Definition:
WidgetMoverButton.h:67
WidgetMoverButton::m_originalWidgetY
int m_originalWidgetY
Definition:
WidgetMoverButton.h:64
WidgetMoverButton::m_hotSpot
QPoint m_hotSpot
The mouse-down coordinates in the widget to move.
Definition:
WidgetMoverButton.h:69
GUI
View
SampleDesigner
WidgetMoverButton.h
Generated by
1.9.1