mirror of
https://github.com/LMMS/lmms.git
synced 2026-05-18 19:55:00 -04:00
Draggable effects (#6648)
Reorder effects in Mixer with the mouse via click and drag
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
#include "PluginView.h"
|
||||
#include "Effect.h"
|
||||
|
||||
class QGraphicsOpacityEffect;
|
||||
class QGroupBox;
|
||||
class QLabel;
|
||||
class QPushButton;
|
||||
@@ -61,6 +62,11 @@ public:
|
||||
}
|
||||
|
||||
static constexpr int DEFAULT_WIDTH = 215;
|
||||
static constexpr int DEFAULT_HEIGHT = 60;
|
||||
|
||||
void mouseMoveEvent(QMouseEvent* event) override;
|
||||
void mousePressEvent(QMouseEvent* event) override;
|
||||
void mouseReleaseEvent(QMouseEvent* event) override;
|
||||
|
||||
public slots:
|
||||
void editControls();
|
||||
@@ -90,6 +96,9 @@ private:
|
||||
Knob * m_gate;
|
||||
QMdiSubWindow * m_subWindow;
|
||||
EffectControlDialog * m_controlView;
|
||||
|
||||
bool m_dragging;
|
||||
QGraphicsOpacityEffect* m_opacityEffect;
|
||||
|
||||
} ;
|
||||
|
||||
|
||||
@@ -23,9 +23,11 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <QGraphicsOpacityEffect>
|
||||
#include <QLayout>
|
||||
#include <QMouseEvent>
|
||||
#include <QPushButton>
|
||||
#include <QPainter>
|
||||
#include <QLayout>
|
||||
|
||||
#include "EffectView.h"
|
||||
#include "DummyEffect.h"
|
||||
@@ -47,9 +49,10 @@ EffectView::EffectView( Effect * _model, QWidget * _parent ) :
|
||||
PluginView( _model, _parent ),
|
||||
m_bg( embed::getIconPixmap( "effect_plugin" ) ),
|
||||
m_subWindow( nullptr ),
|
||||
m_controlView( nullptr )
|
||||
m_controlView(nullptr),
|
||||
m_dragging(false)
|
||||
{
|
||||
setFixedSize( EffectView::DEFAULT_WIDTH, 60 );
|
||||
setFixedSize(EffectView::DEFAULT_WIDTH, EffectView::DEFAULT_HEIGHT);
|
||||
|
||||
// Disable effects that are of type "DummyEffect"
|
||||
bool isEnabled = !dynamic_cast<DummyEffect *>( effect() );
|
||||
@@ -116,7 +119,10 @@ EffectView::EffectView( Effect * _model, QWidget * _parent ) :
|
||||
m_subWindow->hide();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
m_opacityEffect = new QGraphicsOpacityEffect(this);
|
||||
m_opacityEffect->setOpacity(1);
|
||||
setGraphicsEffect(m_opacityEffect);
|
||||
|
||||
//move above vst effect view creation
|
||||
//setModel( _model );
|
||||
@@ -208,6 +214,43 @@ void EffectView::contextMenuEvent( QContextMenuEvent * )
|
||||
|
||||
|
||||
|
||||
void EffectView::mousePressEvent(QMouseEvent* event)
|
||||
{
|
||||
if (event->button() == Qt::LeftButton)
|
||||
{
|
||||
m_dragging = true;
|
||||
m_opacityEffect->setOpacity(0.3);
|
||||
QCursor c(Qt::SizeVerCursor);
|
||||
QApplication::setOverrideCursor(c);
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
void EffectView::mouseReleaseEvent(QMouseEvent* event)
|
||||
{
|
||||
if (event->button() == Qt::LeftButton)
|
||||
{
|
||||
m_dragging = false;
|
||||
m_opacityEffect->setOpacity(1);
|
||||
QApplication::restoreOverrideCursor();
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
void EffectView::mouseMoveEvent(QMouseEvent* event)
|
||||
{
|
||||
if (!m_dragging) { return; }
|
||||
if (event->pos().y() < 0)
|
||||
{
|
||||
moveUp();
|
||||
}
|
||||
else if (event->pos().y() > EffectView::DEFAULT_HEIGHT)
|
||||
{
|
||||
moveDown();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void EffectView::paintEvent( QPaintEvent * )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user