Skip to content
Snippets Groups Projects
Commit f11da5db authored by Matthias Puchner's avatar Matthias Puchner
Browse files

improve moving of layers

parent 7978105e
No related branches found
No related tags found
1 merge request!434Improve moving of layers in layer editor
......@@ -48,6 +48,9 @@ void WidgetMoverButton::mousePressEvent(QMouseEvent* event)
void WidgetMoverButton::mouseReleaseEvent(QMouseEvent*)
{
qDeleteAll(m_animations.values());
m_animations.clear();
m_dragScrollTimer.stop();
m_started = false;
if (m_layoutToDeactivate != nullptr) {
......@@ -107,14 +110,22 @@ void WidgetMoverButton::mouseMoveEvent(QMouseEvent* event)
QWidget* w = layoutItem->widget();
if (w == nullptr) {
layoutItem->setGeometry(r);
} else {
QPropertyAnimation* animation = new QPropertyAnimation(w, "geometry");
} else if (!m_animations.contains(w)) {
auto animation = new QPropertyAnimation(w, "geometry");
animation->setDuration(100);
animation->setEasingCurve(QEasingCurve::OutQuad);
animation->setStartValue(w->geometry());
animation->setEndValue(r);
animation->start();
m_animations[w] = animation;
} else {
auto animation = m_animations[w];
if (animation->endValue() != r) {
animation->stop();
animation->setStartValue(w->geometry());
animation->setEndValue(r);
animation->start();
}
}
}
......
......@@ -15,10 +15,12 @@
#ifndef BORNAGAIN_GUI_VIEW_SAMPLEDESIGNER_WIDGETMOVERBUTTON_H
#define BORNAGAIN_GUI_VIEW_SAMPLEDESIGNER_WIDGETMOVERBUTTON_H
#include <QMap>
#include <QTimer>
#include <QToolButton>
class QScrollArea;
class QPropertyAnimation;
//! Button to move a widget vertically in a layout.
//!
......@@ -65,6 +67,7 @@ private:
QTimer m_dragScrollTimer;
QScrollArea* m_scrollArea;
QPoint m_hotSpot; //!< The mouse-down coordinates in the widget to move
QMap<QWidget*, QPropertyAnimation*> m_animations;
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment