Skip to content

Commit

Permalink
Implements fine tuning with double click
Browse files Browse the repository at this point in the history
	Implements a way to fine tune a node's inValue/outValue by
double clicking the node on the AutomationEditor.
	This is an adaptation of PR LMMS#5292 for the new AutomationEditor
code which is being changed by PR LMMS#5712, keeping the original
authorship.
  • Loading branch information
tecknixia authored and IanCaio committed Dec 26, 2020
1 parent 2d1fbd0 commit 2226108
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/AutomationEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
68 changes: 68 additions & 0 deletions src/gui/editors/AutomationEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,74 @@ void AutomationEditor::mousePressEvent( QMouseEvent* mouseEvent )



void AutomationEditor::mouseDoubleClickEvent(QMouseEvent * mouseEvent)
{
if (!validPattern()) { return; }

// If we double clicked inside the AutomationEditor viewport
if (mouseEvent->y() > TOP_MARGIN && mouseEvent->x() >= VALUES_WIDTH)
{
timeMap & tm = m_pattern->getTimeMap();

timeMap::iterator clickedNode;

// Are we editing the inValue or outValue?
bool editingInValue;

switch (m_editMode)
{
case DRAW:
// We will edit the inValue
clickedNode = getNodeAt(mouseEvent->x(), mouseEvent->y());
editingInValue = true;
break;
case DRAW_OUTVALUES:
// We will edit the outValue
clickedNode = getNodeAt(mouseEvent->x(), mouseEvent->y(), true);
editingInValue = false;
break;
}

if (clickedNode == tm.end())
{
return;
}

// Display dialog to edit the value
bool ok;
double value = QInputDialog::getDouble(
this,
tr("Edit Value"),
editingInValue
? tr("New inValue")
: tr("New outValue"),
editingInValue
? INVAL(clickedNode)
: OUTVAL(clickedNode),
m_pattern->firstObject()->minValue<float>(),
m_pattern->firstObject()->maxValue<float>(),
3,
&ok
);

if (ok)
{
// Set the new inValue/outValue
if (editingInValue)
{
clickedNode.value().setInValue(value);
}
else
{
clickedNode.value().setOutValue(value);
}
}
}
}




void AutomationEditor::mouseReleaseEvent(QMouseEvent * mouseEvent )
{
bool mustRepaint = false;
Expand Down

0 comments on commit 2226108

Please sign in to comment.