mirror of
https://github.com/LMMS/lmms.git
synced 2026-03-04 14:18:58 -05:00
Co-authored-by: tecknixia <50790262+tecknixia@users.noreply.github.com>
This commit is contained in:
@@ -98,6 +98,7 @@ protected:
|
||||
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 @@ protected:
|
||||
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();
|
||||
|
||||
@@ -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<float>(),
|
||||
m_pattern->firstObject()->maxValue<float>(),
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user