diff --git a/include/AutomationEditor.h b/include/AutomationEditor.h index e66ab665bdf..d52f3bc24e5 100644 --- a/include/AutomationEditor.h +++ b/include/AutomationEditor.h @@ -98,6 +98,7 @@ public slots: void keyPressEvent(QKeyEvent * ke) override; void leaveEvent(QEvent * e) override; void mousePressEvent(QMouseEvent * mouseEvent) override; + void mouseDoubleClickEvent(QMouseEvent * mouseEvent) override; void mouseReleaseEvent(QMouseEvent * mouseEvent) override; void mouseMoveEvent(QMouseEvent * mouseEvent) override; void paintEvent(QPaintEvent * pe) override; @@ -112,6 +113,7 @@ public slots: timeMap::iterator getNodeAt(int x, int y, bool outValue = false, int r = 5); void drawLine( int x0, float y0, int x1, float y1 ); + bool fineTuneValue(timeMap::iterator node, bool editingOutValue); protected slots: void play(); diff --git a/src/gui/editors/AutomationEditor.cpp b/src/gui/editors/AutomationEditor.cpp index c50c1ca05ab..ede66760c7d 100644 --- a/src/gui/editors/AutomationEditor.cpp +++ b/src/gui/editors/AutomationEditor.cpp @@ -398,6 +398,53 @@ void AutomationEditor::drawLine( int x0In, float y0, int x1In, float y1 ) +bool AutomationEditor::fineTuneValue(timeMap::iterator node, bool editingOutValue) +{ + if (node == m_pattern->getTimeMap().end()) { return false; } + + // Display dialog to edit the value + bool ok; + double value = QInputDialog::getDouble( + this, + tr("Edit Value"), + editingOutValue + ? tr("New outValue") + : tr("New inValue"), + editingOutValue + ? OUTVAL(node) + : INVAL(node), + m_pattern->firstObject()->minValue(), + m_pattern->firstObject()->maxValue(), + 3, + &ok + ); + + // If dialog failed return false + if (!ok) { return false; } + + // Set the new inValue/outValue + if (editingOutValue) + { + node.value().setOutValue(value); + } + else + { + // If the outValue is equal to the inValue we + // set both to the given value + if (OFFSET(node) == 0) + { + node.value().setOutValue(value); + } + node.value().setInValue(value); + } + + Engine::getSong()->setModified(); + return true; +} + + + + void AutomationEditor::mousePressEvent( QMouseEvent* mouseEvent ) { if( !validPattern() ) @@ -615,6 +662,31 @@ void AutomationEditor::mousePressEvent( QMouseEvent* mouseEvent ) +void AutomationEditor::mouseDoubleClickEvent(QMouseEvent * mouseEvent) +{ + if (!validPattern()) { return; } + + // If we double clicked outside the AutomationEditor viewport return + if (mouseEvent->y() <= TOP_MARGIN || mouseEvent->x() < VALUES_WIDTH) { return; } + + // Are we fine tuning the inValue or outValue? + const bool isOutVal = (m_editMode == DRAW_OUTVALUES); + timeMap::iterator clickedNode = getNodeAt(mouseEvent->x(), mouseEvent->y(), isOutVal); + + switch (m_editMode) + { + case DRAW: + case DRAW_OUTVALUES: + if (fineTuneValue(clickedNode, isOutVal)) { update(); } + break; + default: + break; + } +} + + + + void AutomationEditor::mouseReleaseEvent(QMouseEvent * mouseEvent ) { bool mustRepaint = false;