From 8730b21776ec64269849751780356f24f77e9b23 Mon Sep 17 00:00:00 2001 From: tecknixia <50790262+tecknixia@users.noreply.github.com> Date: Mon, 7 Oct 2019 20:34:37 -0500 Subject: [PATCH 01/14] Update AutomationEditor.h --- include/AutomationEditor.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/AutomationEditor.h b/include/AutomationEditor.h index 9705c5efa6a..8806ebf9758 100644 --- a/include/AutomationEditor.h +++ b/include/AutomationEditor.h @@ -208,6 +208,7 @@ protected slots: float m_scrollLevel; float m_bottomLevel; float m_topLevel; + float m_point_y_level; void updateTopBottomLevels(); From 21336ea96b8b806605a35fbc340c526a4e7c933a Mon Sep 17 00:00:00 2001 From: tecknixia <50790262+tecknixia@users.noreply.github.com> Date: Mon, 7 Oct 2019 22:53:17 -0500 Subject: [PATCH 02/14] Update AutomationEditor.cpp --- src/gui/editors/AutomationEditor.cpp | 64 +++++++++++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-) diff --git a/src/gui/editors/AutomationEditor.cpp b/src/gui/editors/AutomationEditor.cpp index 94e9d5cc86a..881b8611dd0 100644 --- a/src/gui/editors/AutomationEditor.cpp +++ b/src/gui/editors/AutomationEditor.cpp @@ -86,6 +86,7 @@ AutomationEditor::AutomationEditor() : m_scrollLevel( 0 ), m_bottomLevel( 0 ), m_topLevel( 0 ), + m_pointYLevel(0), m_currentPosition(), m_action( NONE ), m_moveStartLevel( 0 ), @@ -726,6 +727,10 @@ void AutomationEditor::mouseMoveEvent(QMouseEvent * mouseEvent ) update(); return; } + + // sets drawCross tooltip back to mouse y position + // TODO: set to point's y value when mouse over point + m_pointYLevel = 0; if( mouseEvent->y() > TOP_MARGIN ) { @@ -1103,7 +1108,11 @@ inline void AutomationEditor::drawCross( QPainter & p ) mouse_pos.y() >= 0 && mouse_pos.y() <= height() - SCROLLBAR_SIZE ) { - QToolTip::showText( tt_pos, QString::number( scaledLevel ), this ); + if (m_pointYLevel == 0) { + QToolTip::showText( tt_pos, QString::number( scaledLevel ), this ); + } else if (m_pointYLevel != 0) { + QToolTip::showText( tt_pos, QString::number( m_pointYLevel ), this ); + } } } @@ -1707,6 +1716,59 @@ void AutomationEditor::wheelEvent(QWheelEvent * we ) { m_topBottomScroll->setValue( m_topBottomScroll->value() - we->delta() / 30 ); + + if (we->y() > TOP_MARGIN) { + float level = getLevel( we->y() ); + int x = we->x(); + + if (x >= VALUES_WIDTH) { + // set or move value + + x -= VALUES_WIDTH; + // get tick in which the cursor is posated + int pos_ticks = x * MidiTime::ticksPerTact() / m_ppt + + m_currentPosition; + + // get time map of current pattern + timeMap & time_map = m_pattern->getTimeMap(); + + // will be our iterator in the following loop + timeMap::iterator it = time_map.begin(); + + // and check whether the user scrolls over an + // existing value + while (it != time_map.end()) { + + if (pos_ticks < 0) { + pos_ticks = 0; + } + + if (pos_ticks >= it.key() - MidiTime::ticksPerTact() *4 / m_ppt + && (it+1==time_map.end() || pos_ticks <= (it+1).key()) + && (pos_ticks<= it.key() + MidiTime::ticksPerTact() *4 / m_ppt)) + { + // mouse wheel up + if (we->delta() < 0) { + level = roundf(it.value() * 1000) / 1000 - 0.001; + // mouse wheel down + } else if (we->delta() > 0) { + level = roundf(it.value() * 1000) / 1000 + 0.001; + } + + m_pointYLevel = level; + + // set new value + m_pattern->setDragValue(MidiTime(pos_ticks), level, true, false); + + // apply new value + m_pattern->applyDragValue(); + + break; + } + ++it; + } + } + } } } From d81e77d0570c5ec116998c09c741f07f3576835c Mon Sep 17 00:00:00 2001 From: tecknixia <50790262+tecknixia@users.noreply.github.com> Date: Mon, 7 Oct 2019 22:55:03 -0500 Subject: [PATCH 03/14] Update AutomationEditor.h --- include/AutomationEditor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/AutomationEditor.h b/include/AutomationEditor.h index 8806ebf9758..507eb062bea 100644 --- a/include/AutomationEditor.h +++ b/include/AutomationEditor.h @@ -208,7 +208,7 @@ protected slots: float m_scrollLevel; float m_bottomLevel; float m_topLevel; - float m_point_y_level; + float m_pointYLevel; void updateTopBottomLevels(); From df886b0d84f2af235af85c87c1ebef06bcafc4c4 Mon Sep 17 00:00:00 2001 From: tecknixia <50790262+tecknixia@users.noreply.github.com> Date: Thu, 10 Oct 2019 09:42:07 -0500 Subject: [PATCH 04/14] Update AutomationEditor.cpp --- src/gui/editors/AutomationEditor.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gui/editors/AutomationEditor.cpp b/src/gui/editors/AutomationEditor.cpp index 881b8611dd0..53b92ac58b4 100644 --- a/src/gui/editors/AutomationEditor.cpp +++ b/src/gui/editors/AutomationEditor.cpp @@ -1749,10 +1749,12 @@ void AutomationEditor::wheelEvent(QWheelEvent * we ) { // mouse wheel up if (we->delta() < 0) { - level = roundf(it.value() * 1000) / 1000 - 0.001; + level = roundf(it.value() * 1000) / 1000 - + m_pattern->firstObject()->step(); // mouse wheel down } else if (we->delta() > 0) { - level = roundf(it.value() * 1000) / 1000 + 0.001; + level = roundf(it.value() * 1000) / 1000 + + m_pattern->firstObject()->step(); } m_pointYLevel = level; From 2bb7a3ea4ae993a660a69fd2e1f9cd10ab6889be Mon Sep 17 00:00:00 2001 From: tecknixia Date: Mon, 14 Oct 2019 21:21:32 -0500 Subject: [PATCH 05/14] Style review fixes --- src/gui/editors/AutomationEditor.cpp | 58 +++++++++++++++------------- 1 file changed, 32 insertions(+), 26 deletions(-) diff --git a/src/gui/editors/AutomationEditor.cpp b/src/gui/editors/AutomationEditor.cpp index cae5639f2c2..13ce367476a 100644 --- a/src/gui/editors/AutomationEditor.cpp +++ b/src/gui/editors/AutomationEditor.cpp @@ -729,7 +729,7 @@ void AutomationEditor::mouseMoveEvent(QMouseEvent * mouseEvent ) update(); return; } - + // sets drawCross tooltip back to mouse y position // TODO: set to point's y value when mouse over point m_pointYLevel = 0; @@ -1110,10 +1110,13 @@ inline void AutomationEditor::drawCross( QPainter & p ) mouse_pos.y() >= 0 && mouse_pos.y() <= height() - SCROLLBAR_SIZE ) { - if (m_pointYLevel == 0) { - QToolTip::showText( tt_pos, QString::number( scaledLevel ), this ); - } else if (m_pointYLevel != 0) { - QToolTip::showText( tt_pos, QString::number( m_pointYLevel ), this ); + if (m_pointYLevel == 0) + { + QToolTip::showText(tt_pos, QString::number(scaledLevel), this); + } + else if (m_pointYLevel != 0) + { + QToolTip::showText(tt_pos, QString::number(m_pointYLevel), this); } } } @@ -1716,18 +1719,20 @@ void AutomationEditor::wheelEvent(QWheelEvent * we ) } else { - m_topBottomScroll->setValue( m_topBottomScroll->value() - - we->delta() / 30 ); - - if (we->y() > TOP_MARGIN) { + m_topBottomScroll->setValue(m_topBottomScroll->value() - + we->delta() / 30); + + if (we->y() > TOP_MARGIN) + { float level = getLevel( we->y() ); int x = we->x(); - if (x >= VALUES_WIDTH) { - // set or move value - + if (x >= VALUES_WIDTH) + { + // set or move value x -= VALUES_WIDTH; - // get tick in which the cursor is posated + + // get tick in which the cursor is posated int pos_ticks = x * MidiTime::ticksPerTact() / m_ppt + m_currentPosition; @@ -1739,26 +1744,27 @@ void AutomationEditor::wheelEvent(QWheelEvent * we ) // and check whether the user scrolls over an // existing value - while (it != time_map.end()) { - - if (pos_ticks < 0) { - pos_ticks = 0; - } - + while (it != time_map.end()) + { + pos_ticks = (pos_ticks < 0) ? 0 : pos_ticks; + if (pos_ticks >= it.key() - MidiTime::ticksPerTact() *4 / m_ppt && (it+1==time_map.end() || pos_ticks <= (it+1).key()) - && (pos_ticks<= it.key() + MidiTime::ticksPerTact() *4 / m_ppt)) + && (pos_ticks<= it.key() + MidiTime::ticksPerTact() *4 / m_ppt)) { // mouse wheel up - if (we->delta() < 0) { + if (we->delta() < 0) + { level = roundf(it.value() * 1000) / 1000 - - m_pattern->firstObject()->step(); + m_pattern->firstObject()->step(); // mouse wheel down - } else if (we->delta() > 0) { + } + else if (we->delta() > 0) + { level = roundf(it.value() * 1000) / 1000 + - m_pattern->firstObject()->step(); + m_pattern->firstObject()->step(); } - + m_pointYLevel = level; // set new value @@ -1766,7 +1772,7 @@ void AutomationEditor::wheelEvent(QWheelEvent * we ) // apply new value m_pattern->applyDragValue(); - + break; } ++it; From 453cad5dfaeddc601b51e76d9d9aadb29be44d3b Mon Sep 17 00:00:00 2001 From: tecknixia Date: Mon, 14 Oct 2019 21:32:03 -0500 Subject: [PATCH 06/14] Style Review Addition --- src/gui/editors/AutomationEditor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/editors/AutomationEditor.cpp b/src/gui/editors/AutomationEditor.cpp index 13ce367476a..7458e016c34 100644 --- a/src/gui/editors/AutomationEditor.cpp +++ b/src/gui/editors/AutomationEditor.cpp @@ -1734,7 +1734,7 @@ void AutomationEditor::wheelEvent(QWheelEvent * we ) // get tick in which the cursor is posated int pos_ticks = x * MidiTime::ticksPerTact() / m_ppt + - m_currentPosition; + m_currentPosition; // get time map of current pattern timeMap & time_map = m_pattern->getTimeMap(); From 9c5aaca0cca8ee4126da9a843b9a4f33f068c2e2 Mon Sep 17 00:00:00 2001 From: tecknixia Date: Tue, 15 Oct 2019 08:40:03 -0500 Subject: [PATCH 07/14] Fixed Indentation Inconsistencies --- src/gui/editors/AutomationEditor.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/gui/editors/AutomationEditor.cpp b/src/gui/editors/AutomationEditor.cpp index 7458e016c34..59e4b2ee98d 100644 --- a/src/gui/editors/AutomationEditor.cpp +++ b/src/gui/editors/AutomationEditor.cpp @@ -1711,16 +1711,16 @@ void AutomationEditor::wheelEvent(QWheelEvent * we ) m_zoomingXModel.setValue( x ); } - else if( we->modifiers() & Qt::ShiftModifier - || we->orientation() == Qt::Horizontal ) + else if (we->modifiers() & Qt::ShiftModifier + || we->orientation() == Qt::Horizontal) { m_leftRightScroll->setValue( m_leftRightScroll->value() - - we->delta() * 2 / 15 ); + we->delta() * 2 / 15 ); } else { m_topBottomScroll->setValue(m_topBottomScroll->value() - - we->delta() / 30); + we->delta() / 30); if (we->y() > TOP_MARGIN) { @@ -1734,7 +1734,7 @@ void AutomationEditor::wheelEvent(QWheelEvent * we ) // get tick in which the cursor is posated int pos_ticks = x * MidiTime::ticksPerTact() / m_ppt + - m_currentPosition; + m_currentPosition; // get time map of current pattern timeMap & time_map = m_pattern->getTimeMap(); @@ -1756,13 +1756,13 @@ void AutomationEditor::wheelEvent(QWheelEvent * we ) if (we->delta() < 0) { level = roundf(it.value() * 1000) / 1000 - - m_pattern->firstObject()->step(); - // mouse wheel down + m_pattern->firstObject()->step(); } + // mouse wheel down else if (we->delta() > 0) { level = roundf(it.value() * 1000) / 1000 + - m_pattern->firstObject()->step(); + m_pattern->firstObject()->step(); } m_pointYLevel = level; From fd2fab0c2e3fdf7f23de071e1dba5120c8ecf684 Mon Sep 17 00:00:00 2001 From: tecknixia Date: Tue, 15 Oct 2019 10:50:12 -0500 Subject: [PATCH 08/14] Removed Spaces Within Parameters --- src/gui/editors/AutomationEditor.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/gui/editors/AutomationEditor.cpp b/src/gui/editors/AutomationEditor.cpp index 59e4b2ee98d..6813b776874 100644 --- a/src/gui/editors/AutomationEditor.cpp +++ b/src/gui/editors/AutomationEditor.cpp @@ -1105,10 +1105,10 @@ inline void AutomationEditor::drawCross( QPainter & p ) float scaledLevel = m_pattern->firstObject()->scaledValue( level ); // Limit the scaled-level tooltip to the grid - if( mouse_pos.x() >= 0 && + if(mouse_pos.x() >= 0 && mouse_pos.x() <= width() - SCROLLBAR_SIZE && mouse_pos.y() >= 0 && - mouse_pos.y() <= height() - SCROLLBAR_SIZE ) + mouse_pos.y() <= height() - SCROLLBAR_SIZE) { if (m_pointYLevel == 0) { @@ -1714,8 +1714,8 @@ void AutomationEditor::wheelEvent(QWheelEvent * we ) else if (we->modifiers() & Qt::ShiftModifier || we->orientation() == Qt::Horizontal) { - m_leftRightScroll->setValue( m_leftRightScroll->value() - - we->delta() * 2 / 15 ); + m_leftRightScroll->setValue(m_leftRightScroll->value() - + we->delta() * 2 / 15); } else { @@ -1724,7 +1724,7 @@ void AutomationEditor::wheelEvent(QWheelEvent * we ) if (we->y() > TOP_MARGIN) { - float level = getLevel( we->y() ); + float level = getLevel(we->y()); int x = we->x(); if (x >= VALUES_WIDTH) From b6b6aac53e5a0776b2990de2c3110a7287e478ec Mon Sep 17 00:00:00 2001 From: tecknixia Date: Tue, 15 Oct 2019 13:23:15 -0500 Subject: [PATCH 09/14] Tooltip Display Fix --- include/AutomationEditor.h | 1 + src/gui/editors/AutomationEditor.cpp | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/AutomationEditor.h b/include/AutomationEditor.h index f76f37f7ffc..8427355e2db 100644 --- a/include/AutomationEditor.h +++ b/include/AutomationEditor.h @@ -209,6 +209,7 @@ protected slots: float m_bottomLevel; float m_topLevel; float m_pointYLevel; + ulong m_pointYLevelTimestamp; void updateTopBottomLevels(); diff --git a/src/gui/editors/AutomationEditor.cpp b/src/gui/editors/AutomationEditor.cpp index 6813b776874..ac0145d2572 100644 --- a/src/gui/editors/AutomationEditor.cpp +++ b/src/gui/editors/AutomationEditor.cpp @@ -732,7 +732,10 @@ void AutomationEditor::mouseMoveEvent(QMouseEvent * mouseEvent ) // sets drawCross tooltip back to mouse y position // TODO: set to point's y value when mouse over point - m_pointYLevel = 0; + if (mouseEvent->timestamp() > m_pointYLevelTimestamp) + { + m_pointYLevel = 0; + } if( mouseEvent->y() > TOP_MARGIN ) { @@ -1766,6 +1769,7 @@ void AutomationEditor::wheelEvent(QWheelEvent * we ) } m_pointYLevel = level; + m_pointYLevelTimestamp = we->timestamp(); // set new value m_pattern->setDragValue(MidiTime(pos_ticks), level, true, false); From 12dc2d3432c207f44eb1e4008e4d32d5b40462d8 Mon Sep 17 00:00:00 2001 From: tecknixia Date: Tue, 15 Oct 2019 18:26:31 -0500 Subject: [PATCH 10/14] Rewrite of Pull Request --- include/AutomatableModel.h | 1 - include/AutomationEditor.h | 1 + src/gui/editors/AutomationEditor.cpp | 171 ++++++++++++++------------- 3 files changed, 87 insertions(+), 86 deletions(-) diff --git a/include/AutomatableModel.h b/include/AutomatableModel.h index 3e0b6143da3..0dbe96abd47 100644 --- a/include/AutomatableModel.h +++ b/include/AutomatableModel.h @@ -483,4 +483,3 @@ class LMMS_EXPORT BoolModel : public TypedAutomatableModel typedef QMap AutomatedValueMap; #endif - diff --git a/include/AutomationEditor.h b/include/AutomationEditor.h index 8427355e2db..2c3125728d7 100644 --- a/include/AutomationEditor.h +++ b/include/AutomationEditor.h @@ -119,6 +119,7 @@ public slots: virtual void mousePressEvent(QMouseEvent * mouseEvent); virtual void mouseReleaseEvent(QMouseEvent * mouseEvent); virtual void mouseMoveEvent(QMouseEvent * mouseEvent); + virtual void mouseDoubleClickEvent( QMouseEvent * mouseEvent); virtual void paintEvent(QPaintEvent * pe); virtual void resizeEvent(QResizeEvent * re); virtual void wheelEvent(QWheelEvent * we); diff --git a/src/gui/editors/AutomationEditor.cpp b/src/gui/editors/AutomationEditor.cpp index ac0145d2572..81b63d5c2e8 100644 --- a/src/gui/editors/AutomationEditor.cpp +++ b/src/gui/editors/AutomationEditor.cpp @@ -30,6 +30,7 @@ #include #include +#include #include #include #include @@ -730,13 +731,6 @@ void AutomationEditor::mouseMoveEvent(QMouseEvent * mouseEvent ) return; } - // sets drawCross tooltip back to mouse y position - // TODO: set to point's y value when mouse over point - if (mouseEvent->timestamp() > m_pointYLevelTimestamp) - { - m_pointYLevel = 0; - } - if( mouseEvent->y() > TOP_MARGIN ) { float level = getLevel( mouseEvent->y() ); @@ -750,6 +744,7 @@ void AutomationEditor::mouseMoveEvent(QMouseEvent * mouseEvent ) int pos_ticks = x * MidiTime::ticksPerTact() / m_ppt + m_currentPosition; + if( mouseEvent->buttons() & Qt::LeftButton && m_editMode == DRAW ) { if( m_action == MOVE_VALUE ) @@ -791,63 +786,6 @@ void AutomationEditor::mouseMoveEvent(QMouseEvent * mouseEvent ) removePoints( m_drawLastTick, pos_ticks ); Engine::getSong()->setModified(); } - else if( mouseEvent->buttons() & Qt::NoButton && m_editMode == DRAW ) - { - // set move- or resize-cursor - - // get time map of current pattern - timeMap & time_map = m_pattern->getTimeMap(); - - // will be our iterator in the following loop - timeMap::iterator it = time_map.begin(); - // loop through whole time map... - for( ; it != time_map.end(); ++it ) - { - // and check whether the cursor is over an - // existing value - if( pos_ticks >= it.key() && - ( it+1==time_map.end() || - pos_ticks <= (it+1).key() ) && - level <= it.value() ) - { - break; - } - } - - // did it reach end of map because there's - // no value?? - if( it != time_map.end() ) - { - if( QApplication::overrideCursor() ) - { - if( QApplication::overrideCursor()->shape() != Qt::SizeAllCursor ) - { - while( QApplication::overrideCursor() != NULL ) - { - QApplication::restoreOverrideCursor(); - } - - QCursor c( Qt::SizeAllCursor ); - QApplication::setOverrideCursor( - c ); - } - } - else - { - QCursor c( Qt::SizeAllCursor ); - QApplication::setOverrideCursor( c ); - } - } - else - { - // the cursor is over no value, so restore - // cursor - while( QApplication::overrideCursor() != NULL ) - { - QApplication::restoreOverrideCursor(); - } - } - } else if( mouseEvent->buttons() & Qt::LeftButton && m_editMode == SELECT && m_action == SELECT_VALUES ) @@ -929,7 +867,6 @@ void AutomationEditor::mouseMoveEvent(QMouseEvent * mouseEvent ) int tact_diff = ticks_diff / MidiTime::ticksPerTact(); ticks_diff = ticks_diff % MidiTime::ticksPerTact(); - // do vertical move-stuff float level_diff = level - m_moveStartLevel; @@ -1006,6 +943,68 @@ void AutomationEditor::mouseMoveEvent(QMouseEvent * mouseEvent ) m_moveStartTick = pos_ticks; m_moveStartLevel = level; } + else if (m_editMode == DRAW) + { + // get time map of current pattern + timeMap & time_map = m_pattern->getTimeMap(); + // will be our iterator in the following loop + timeMap::iterator it = time_map.begin(); + // loop through whole time map... + + while (it != time_map.end()) + { + // and check whether the cursor is over an + // existing value + if (pos_ticks >= it.key() - MidiTime::ticksPerTact() *4 / m_ppt + && (it+1==time_map.end() || pos_ticks <= (it+1).key()) + && (pos_ticks<= it.key() + MidiTime::ticksPerTact() *4 / m_ppt)) + { + break; + } + it++; + } + + m_pointYLevel = roundf(it.value() * 1000) / 1000; + // did it reach end of map because there's + // no value?? + if( it != time_map.end() ) + { + if( QApplication::overrideCursor() ) + { + if( QApplication::overrideCursor()->shape() != Qt::SizeAllCursor ) + { + while( QApplication::overrideCursor() != NULL ) + { + QApplication::restoreOverrideCursor(); + } + + QCursor c( Qt::SizeAllCursor ); + QApplication::setOverrideCursor( + c ); + } + } + else + { + QCursor c( Qt::SizeAllCursor ); + QApplication::setOverrideCursor( c ); + } + } + else + { + // the cursor is over no value, so restore + // cursor + while( QApplication::overrideCursor() != NULL ) + { + QApplication::restoreOverrideCursor(); + } + + // sets drawCross tooltip back to mouse y position + if (mouseEvent->timestamp() > m_pointYLevelTimestamp) + { + m_pointYLevel = 0; + } + } + } } else { @@ -1013,7 +1012,6 @@ void AutomationEditor::mouseMoveEvent(QMouseEvent * mouseEvent ) m_editMode == SELECT && m_action == SELECT_VALUES ) { - int x = mouseEvent->x() - VALUES_WIDTH; if( x < 0 && m_currentPosition > 0 ) { @@ -1038,22 +1036,20 @@ void AutomationEditor::mouseMoveEvent(QMouseEvent * mouseEvent ) m_leftRightScroll->setValue( m_currentPosition + 4 ); } - // get tick in which the cursor is posated int pos_ticks = x * MidiTime::ticksPerTact() / m_ppt + m_currentPosition; m_selectedTick = pos_ticks - m_selectStartTick; - if( (int) m_selectStartTick + m_selectedTick < - 0 ) + if ((int) m_selectStartTick + m_selectedTick < 0) { m_selectedTick = -m_selectStartTick; } - float level = getLevel( mouseEvent->y() ); + float level = getLevel(mouseEvent->y()); - if( level <= m_bottomLevel ) + if (level <= m_bottomLevel) { QCursor::setPos( mapToGlobal( QPoint( mouseEvent->x(), height() - @@ -1062,7 +1058,7 @@ void AutomationEditor::mouseMoveEvent(QMouseEvent * mouseEvent ) m_topBottomScroll->value() + 1 ); level = m_bottomLevel; } - else if( level >= m_topLevel ) + else if (level >= m_topLevel) { QCursor::setPos( mapToGlobal( QPoint( mouseEvent->x(), TOP_MARGIN ) ) ); @@ -1071,7 +1067,7 @@ void AutomationEditor::mouseMoveEvent(QMouseEvent * mouseEvent ) level = m_topLevel; } m_selectedLevels = level - m_selectStartLevel; - if( level <= m_selectStartLevel ) + if (level <= m_selectStartLevel) { --m_selectedLevels; } @@ -1085,6 +1081,15 @@ void AutomationEditor::mouseMoveEvent(QMouseEvent * mouseEvent ) +void AutomationEditor::mouseDoubleClickEvent( QMouseEvent * mouseEvent) +{ + // TODO: Double click on automation point opens Dialog Box + // to enter automation point y level values +} + + + + inline void AutomationEditor::drawCross( QPainter & p ) { QPoint mouse_pos = mapFromGlobal( QCursor::pos() ); @@ -1711,7 +1716,6 @@ void AutomationEditor::wheelEvent(QWheelEvent * we ) // scroll so the tick "selected" by the mouse x doesn't move on the screen m_leftRightScroll->setValue(m_leftRightScroll->value() + ticks - newTicks); - m_zoomingXModel.setValue( x ); } else if (we->modifiers() & Qt::ShiftModifier @@ -1722,9 +1726,6 @@ void AutomationEditor::wheelEvent(QWheelEvent * we ) } else { - m_topBottomScroll->setValue(m_topBottomScroll->value() - - we->delta() / 30); - if (we->y() > TOP_MARGIN) { float level = getLevel(we->y()); @@ -1734,17 +1735,15 @@ void AutomationEditor::wheelEvent(QWheelEvent * we ) { // set or move value x -= VALUES_WIDTH; - // get tick in which the cursor is posated int pos_ticks = x * MidiTime::ticksPerTact() / m_ppt + m_currentPosition; - + //disable scrolling while adjusting automation point + bool enableYScrolling = true; // get time map of current pattern timeMap & time_map = m_pattern->getTimeMap(); - // will be our iterator in the following loop timeMap::iterator it = time_map.begin(); - // and check whether the user scrolls over an // existing value while (it != time_map.end()) @@ -1767,20 +1766,22 @@ void AutomationEditor::wheelEvent(QWheelEvent * we ) level = roundf(it.value() * 1000) / 1000 + m_pattern->firstObject()->step(); } - m_pointYLevel = level; m_pointYLevelTimestamp = we->timestamp(); - + enableYScrolling = false; // set new value m_pattern->setDragValue(MidiTime(pos_ticks), level, true, false); - // apply new value m_pattern->applyDragValue(); - break; } ++it; } + if (enableYScrolling) + { + m_topBottomScroll->setValue(m_topBottomScroll->value() - + we->delta() / 30); + } } } } From 41085b823c6a5b4d5f051887a0a52320dba8fbc0 Mon Sep 17 00:00:00 2001 From: tecknixia Date: Wed, 16 Oct 2019 13:00:48 -0500 Subject: [PATCH 11/14] Whitespace fixes --- src/gui/editors/AutomationEditor.cpp | 93 +++++++++++++--------------- 1 file changed, 44 insertions(+), 49 deletions(-) diff --git a/src/gui/editors/AutomationEditor.cpp b/src/gui/editors/AutomationEditor.cpp index 81b63d5c2e8..21508f80a2e 100644 --- a/src/gui/editors/AutomationEditor.cpp +++ b/src/gui/editors/AutomationEditor.cpp @@ -722,7 +722,7 @@ void AutomationEditor::removePoints( int x0, int x1 ) -void AutomationEditor::mouseMoveEvent(QMouseEvent * mouseEvent ) +void AutomationEditor::mouseMoveEvent(QMouseEvent * mouseEvent) { QMutexLocker m( &m_patternMutex ); if( !validPattern() ) @@ -967,41 +967,38 @@ void AutomationEditor::mouseMoveEvent(QMouseEvent * mouseEvent ) m_pointYLevel = roundf(it.value() * 1000) / 1000; // did it reach end of map because there's // no value?? - if( it != time_map.end() ) + if(it != time_map.end()) { - if( QApplication::overrideCursor() ) + if(QApplication::overrideCursor()) { - if( QApplication::overrideCursor()->shape() != Qt::SizeAllCursor ) + if(QApplication::overrideCursor()->shape() != Qt::SizeAllCursor) { - while( QApplication::overrideCursor() != NULL ) + while(QApplication::overrideCursor() != NULL) { QApplication::restoreOverrideCursor(); } - - QCursor c( Qt::SizeAllCursor ); - QApplication::setOverrideCursor( - c ); + QCursor c(Qt::SizeAllCursor); + QApplication::setOverrideCursor(c); } } else { - QCursor c( Qt::SizeAllCursor ); - QApplication::setOverrideCursor( c ); + QCursor c(Qt::SizeAllCursor); + QApplication::setOverrideCursor(c); } } else { // the cursor is over no value, so restore // cursor - while( QApplication::overrideCursor() != NULL ) + while(QApplication::overrideCursor() != NULL) { QApplication::restoreOverrideCursor(); } - // sets drawCross tooltip back to mouse y position if (mouseEvent->timestamp() > m_pointYLevelTimestamp) { - m_pointYLevel = 0; + m_pointYLevel = 0; } } } @@ -1081,7 +1078,7 @@ void AutomationEditor::mouseMoveEvent(QMouseEvent * mouseEvent ) -void AutomationEditor::mouseDoubleClickEvent( QMouseEvent * mouseEvent) +void AutomationEditor::mouseDoubleClickEvent(QMouseEvent * mouseEvent) { // TODO: Double click on automation point opens Dialog Box // to enter automation point y level values @@ -1090,33 +1087,31 @@ void AutomationEditor::mouseDoubleClickEvent( QMouseEvent * mouseEvent) -inline void AutomationEditor::drawCross( QPainter & p ) +inline void AutomationEditor::drawCross(QPainter & p) { - QPoint mouse_pos = mapFromGlobal( QCursor::pos() ); + QPoint mouse_pos = mapFromGlobal(QCursor::pos()); int grid_bottom = height() - SCROLLBAR_SIZE - 1; - float level = getLevel( mouse_pos.y() ); - float cross_y = m_y_auto ? - grid_bottom - ( ( grid_bottom - TOP_MARGIN ) - * ( level - m_minLevel ) - / (float)( m_maxLevel - m_minLevel ) ) : - grid_bottom - ( level - m_bottomLevel ) * m_y_delta; - - p.setPen( crossColor() ); - p.drawLine( VALUES_WIDTH, (int) cross_y, width(), (int) cross_y ); - p.drawLine( mouse_pos.x(), TOP_MARGIN, mouse_pos.x(), height() - SCROLLBAR_SIZE ); + float level = getLevel(mouse_pos.y()); + float cross_y = m_y_auto ? grid_bottom - ((grid_bottom - TOP_MARGIN) + * (level - m_minLevel) / (float)( m_maxLevel - m_minLevel)) + : grid_bottom - (level - m_bottomLevel) * m_y_delta; + p.setPen(crossColor()); + p.drawLine(VALUES_WIDTH, (int) cross_y, width(), (int) cross_y); + p.drawLine(mouse_pos.x(), TOP_MARGIN, mouse_pos.x(), height() + - SCROLLBAR_SIZE); QPoint tt_pos = QCursor::pos(); tt_pos.ry() -= 51; tt_pos.rx() += 26; - float scaledLevel = m_pattern->firstObject()->scaledValue( level ); + float scaledLevel = m_pattern->firstObject()->scaledValue(level); // Limit the scaled-level tooltip to the grid - if(mouse_pos.x() >= 0 && - mouse_pos.x() <= width() - SCROLLBAR_SIZE && - mouse_pos.y() >= 0 && - mouse_pos.y() <= height() - SCROLLBAR_SIZE) + if(mouse_pos.x() >= 0 + && mouse_pos.x() <= width() - SCROLLBAR_SIZE + && mouse_pos.y() >= 0 + && mouse_pos.y() <= height() - SCROLLBAR_SIZE) { if (m_pointYLevel == 0) { @@ -1662,52 +1657,52 @@ void AutomationEditor::resizeEvent(QResizeEvent * re) -void AutomationEditor::wheelEvent(QWheelEvent * we ) +void AutomationEditor::wheelEvent(QWheelEvent * we) { we->accept(); - if( we->modifiers() & Qt::ControlModifier && we->modifiers() & Qt::ShiftModifier ) + if(we->modifiers() & Qt::ControlModifier && we->modifiers() & Qt::ShiftModifier) { int y = m_zoomingYModel.value(); - if( we->delta() > 0 ) + if(we->delta() > 0) { y++; } - else if( we->delta() < 0 ) + else if(we->delta() < 0) { y--; } - y = qBound( 0, y, m_zoomingYModel.size() - 1 ); - m_zoomingYModel.setValue( y ); + y = qBound(0, y, m_zoomingYModel.size() - 1); + m_zoomingYModel.setValue(y); } - else if( we->modifiers() & Qt::ControlModifier && we->modifiers() & Qt::AltModifier ) + else if(we->modifiers() & Qt::ControlModifier && we->modifiers() & Qt::AltModifier) { int q = m_quantizeModel.value(); - if( we->delta() > 0 ) + if(we->delta() > 0) { q--; } - else if( we->delta() < 0 ) + else if(we->delta() < 0) { q++; } - q = qBound( 0, q, m_quantizeModel.size() - 1 ); - m_quantizeModel.setValue( q ); + q = qBound(0, q, m_quantizeModel.size() - 1); + m_quantizeModel.setValue(q); update(); } - else if( we->modifiers() & Qt::ControlModifier ) + else if(we->modifiers() & Qt::ControlModifier) { int x = m_zoomingXModel.value(); - if( we->delta() > 0 ) + if(we->delta() > 0) { x++; } - else if( we->delta() < 0 ) + else if(we->delta() < 0) { x--; } - x = qBound( 0, x, m_zoomingXModel.size() - 1 ); + x = qBound(0, x, m_zoomingXModel.size() - 1); - int mouseX = (we->x() - VALUES_WIDTH)* MidiTime::ticksPerTact(); + int mouseX = (we->x() - VALUES_WIDTH) * MidiTime::ticksPerTact(); // ticks based on the mouse x-position where the scroll wheel was used int ticks = mouseX / m_ppt; // what would be the ticks in the new zoom level on the very same mouse x @@ -1716,7 +1711,7 @@ void AutomationEditor::wheelEvent(QWheelEvent * we ) // scroll so the tick "selected" by the mouse x doesn't move on the screen m_leftRightScroll->setValue(m_leftRightScroll->value() + ticks - newTicks); - m_zoomingXModel.setValue( x ); + m_zoomingXModel.setValue(x); } else if (we->modifiers() & Qt::ShiftModifier || we->orientation() == Qt::Horizontal) From 5e93d7497147a9a3d99c996f306a237ceed459b9 Mon Sep 17 00:00:00 2001 From: tecknixia Date: Wed, 16 Oct 2019 18:47:48 -0500 Subject: [PATCH 12/14] Added Double Click Input Dialog Functionality --- include/AutomationEditor.h | 2 +- src/gui/editors/AutomationEditor.cpp | 298 +++++++++++++++------------ 2 files changed, 169 insertions(+), 131 deletions(-) diff --git a/include/AutomationEditor.h b/include/AutomationEditor.h index 2c3125728d7..761d8a9bfa9 100644 --- a/include/AutomationEditor.h +++ b/include/AutomationEditor.h @@ -120,9 +120,9 @@ public slots: virtual void mouseReleaseEvent(QMouseEvent * mouseEvent); virtual void mouseMoveEvent(QMouseEvent * mouseEvent); virtual void mouseDoubleClickEvent( QMouseEvent * mouseEvent); + virtual void wheelEvent(QWheelEvent * we); virtual void paintEvent(QPaintEvent * pe); virtual void resizeEvent(QResizeEvent * re); - virtual void wheelEvent(QWheelEvent * we); float getLevel( int y ); int xCoordOfTick( int tick ); diff --git a/src/gui/editors/AutomationEditor.cpp b/src/gui/editors/AutomationEditor.cpp index 21508f80a2e..23fe8aa82dd 100644 --- a/src/gui/editors/AutomationEditor.cpp +++ b/src/gui/editors/AutomationEditor.cpp @@ -1080,8 +1080,174 @@ void AutomationEditor::mouseMoveEvent(QMouseEvent * mouseEvent) void AutomationEditor::mouseDoubleClickEvent(QMouseEvent * mouseEvent) { - // TODO: Double click on automation point opens Dialog Box - // to enter automation point y level values + int x = mouseEvent->x(); + + if (x >= VALUES_WIDTH) + { + // set or move value + x -= VALUES_WIDTH; + // get tick in which the cursor is posated + int pos_ticks = x * MidiTime::ticksPerTact() / m_ppt + + m_currentPosition; + // get time map of current pattern + timeMap & time_map = m_pattern->getTimeMap(); + // will be our iterator in the following loop + timeMap::iterator it = time_map.begin(); + // loop through whole time map... + + while (it != time_map.end()) + { + // and check whether the cursor is over an + // existing value + if (pos_ticks >= it.key() - MidiTime::ticksPerTact() *4 / m_ppt + && (it+1==time_map.end() || pos_ticks <= (it+1).key()) + && (pos_ticks<= it.key() + MidiTime::ticksPerTact() *4 / m_ppt)) + { + break; + } + it++; + } + + bool ok; + double d = QInputDialog::getDouble(this, tr("Edit Point"), + tr("Enter Y Coordinate:"), m_pointYLevel, 0, m_pattern->firstObject()->maxValue(), 3, &ok); + + if (ok) + { + // set new value - need to pass in pos_ticks + m_pattern->setDragValue(MidiTime(pos_ticks), d, true, false); + // apply new value + m_pattern->applyDragValue(); + } + } +} + + + + +void AutomationEditor::wheelEvent(QWheelEvent * we) +{ + we->accept(); + if(we->modifiers() & Qt::ControlModifier && we->modifiers() & Qt::ShiftModifier) + { + int y = m_zoomingYModel.value(); + if(we->delta() > 0) + { + y++; + } + else if(we->delta() < 0) + { + y--; + } + y = qBound(0, y, m_zoomingYModel.size() - 1); + m_zoomingYModel.setValue(y); + } + else if(we->modifiers() & Qt::ControlModifier && we->modifiers() & Qt::AltModifier) + { + int q = m_quantizeModel.value(); + if(we->delta() > 0) + { + q--; + } + else if(we->delta() < 0) + { + q++; + } + q = qBound(0, q, m_quantizeModel.size() - 1); + m_quantizeModel.setValue(q); + update(); + } + else if(we->modifiers() & Qt::ControlModifier) + { + int x = m_zoomingXModel.value(); + if(we->delta() > 0) + { + x++; + } + else if(we->delta() < 0) + { + x--; + } + x = qBound(0, x, m_zoomingXModel.size() - 1); + + int mouseX = (we->x() - VALUES_WIDTH) * MidiTime::ticksPerTact(); + // ticks based on the mouse x-position where the scroll wheel was used + int ticks = mouseX / m_ppt; + // what would be the ticks in the new zoom level on the very same mouse x + int newTicks = mouseX / (DEFAULT_PPT * m_zoomXLevels[x]); + + // scroll so the tick "selected" by the mouse x doesn't move on the screen + m_leftRightScroll->setValue(m_leftRightScroll->value() + ticks - newTicks); + + m_zoomingXModel.setValue(x); + } + else if (we->modifiers() & Qt::ShiftModifier + || we->orientation() == Qt::Horizontal) + { + m_leftRightScroll->setValue(m_leftRightScroll->value() - + we->delta() * 2 / 15); + } + else + { + if (we->y() > TOP_MARGIN) + { + float level = getLevel(we->y()); + int x = we->x(); + + if (x >= VALUES_WIDTH) + { + // set or move value + x -= VALUES_WIDTH; + // get tick in which the cursor is posated + int pos_ticks = x * MidiTime::ticksPerTact() / m_ppt + + m_currentPosition; + //disable scrolling while adjusting automation point + bool enableYScrolling = true; + // get time map of current pattern + timeMap & time_map = m_pattern->getTimeMap(); + // will be our iterator in the following loop + timeMap::iterator it = time_map.begin(); + // and check whether the user scrolls over an + // existing value + while (it != time_map.end()) + { + pos_ticks = (pos_ticks < 0) ? 0 : pos_ticks; + + if (pos_ticks >= it.key() - MidiTime::ticksPerTact() *4 / m_ppt + && (it+1==time_map.end() || pos_ticks <= (it+1).key()) + && (pos_ticks<= it.key() + MidiTime::ticksPerTact() *4 / m_ppt)) + { + // mouse wheel up + if (we->delta() < 0) + { + level = roundf(it.value() * 1000) / 1000 - + m_pattern->firstObject()->step(); + } + // mouse wheel down + else if (we->delta() > 0) + { + level = roundf(it.value() * 1000) / 1000 + + m_pattern->firstObject()->step(); + } + m_pointYLevel = level; + m_pointYLevelTimestamp = we->timestamp(); + enableYScrolling = false; + // set new value + m_pattern->setDragValue(MidiTime(pos_ticks), level, true, false); + // apply new value + m_pattern->applyDragValue(); + break; + } + ++it; + } + if (enableYScrolling) + { + m_topBottomScroll->setValue(m_topBottomScroll->value() - + we->delta() / 30); + } + } + } + } } @@ -1657,134 +1823,6 @@ void AutomationEditor::resizeEvent(QResizeEvent * re) -void AutomationEditor::wheelEvent(QWheelEvent * we) -{ - we->accept(); - if(we->modifiers() & Qt::ControlModifier && we->modifiers() & Qt::ShiftModifier) - { - int y = m_zoomingYModel.value(); - if(we->delta() > 0) - { - y++; - } - else if(we->delta() < 0) - { - y--; - } - y = qBound(0, y, m_zoomingYModel.size() - 1); - m_zoomingYModel.setValue(y); - } - else if(we->modifiers() & Qt::ControlModifier && we->modifiers() & Qt::AltModifier) - { - int q = m_quantizeModel.value(); - if(we->delta() > 0) - { - q--; - } - else if(we->delta() < 0) - { - q++; - } - q = qBound(0, q, m_quantizeModel.size() - 1); - m_quantizeModel.setValue(q); - update(); - } - else if(we->modifiers() & Qt::ControlModifier) - { - int x = m_zoomingXModel.value(); - if(we->delta() > 0) - { - x++; - } - else if(we->delta() < 0) - { - x--; - } - x = qBound(0, x, m_zoomingXModel.size() - 1); - - int mouseX = (we->x() - VALUES_WIDTH) * MidiTime::ticksPerTact(); - // ticks based on the mouse x-position where the scroll wheel was used - int ticks = mouseX / m_ppt; - // what would be the ticks in the new zoom level on the very same mouse x - int newTicks = mouseX / (DEFAULT_PPT * m_zoomXLevels[x]); - - // scroll so the tick "selected" by the mouse x doesn't move on the screen - m_leftRightScroll->setValue(m_leftRightScroll->value() + ticks - newTicks); - - m_zoomingXModel.setValue(x); - } - else if (we->modifiers() & Qt::ShiftModifier - || we->orientation() == Qt::Horizontal) - { - m_leftRightScroll->setValue(m_leftRightScroll->value() - - we->delta() * 2 / 15); - } - else - { - if (we->y() > TOP_MARGIN) - { - float level = getLevel(we->y()); - int x = we->x(); - - if (x >= VALUES_WIDTH) - { - // set or move value - x -= VALUES_WIDTH; - // get tick in which the cursor is posated - int pos_ticks = x * MidiTime::ticksPerTact() / m_ppt + - m_currentPosition; - //disable scrolling while adjusting automation point - bool enableYScrolling = true; - // get time map of current pattern - timeMap & time_map = m_pattern->getTimeMap(); - // will be our iterator in the following loop - timeMap::iterator it = time_map.begin(); - // and check whether the user scrolls over an - // existing value - while (it != time_map.end()) - { - pos_ticks = (pos_ticks < 0) ? 0 : pos_ticks; - - if (pos_ticks >= it.key() - MidiTime::ticksPerTact() *4 / m_ppt - && (it+1==time_map.end() || pos_ticks <= (it+1).key()) - && (pos_ticks<= it.key() + MidiTime::ticksPerTact() *4 / m_ppt)) - { - // mouse wheel up - if (we->delta() < 0) - { - level = roundf(it.value() * 1000) / 1000 - - m_pattern->firstObject()->step(); - } - // mouse wheel down - else if (we->delta() > 0) - { - level = roundf(it.value() * 1000) / 1000 + - m_pattern->firstObject()->step(); - } - m_pointYLevel = level; - m_pointYLevelTimestamp = we->timestamp(); - enableYScrolling = false; - // set new value - m_pattern->setDragValue(MidiTime(pos_ticks), level, true, false); - // apply new value - m_pattern->applyDragValue(); - break; - } - ++it; - } - if (enableYScrolling) - { - m_topBottomScroll->setValue(m_topBottomScroll->value() - - we->delta() / 30); - } - } - } - } -} - - - - float AutomationEditor::getLevel(int y ) { int level_line_y = height() - SCROLLBAR_SIZE - 1; From b6da78da3dae438b6de8e317a07211c54f7fdec3 Mon Sep 17 00:00:00 2001 From: tecknixia Date: Wed, 16 Oct 2019 19:40:21 -0500 Subject: [PATCH 13/14] Engagement Area Enhancement --- src/gui/editors/AutomationEditor.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/gui/editors/AutomationEditor.cpp b/src/gui/editors/AutomationEditor.cpp index 23fe8aa82dd..8ad65aaea56 100644 --- a/src/gui/editors/AutomationEditor.cpp +++ b/src/gui/editors/AutomationEditor.cpp @@ -945,6 +945,8 @@ void AutomationEditor::mouseMoveEvent(QMouseEvent * mouseEvent) } else if (m_editMode == DRAW) { + float mouseLevel = getLevel(mouseEvent->y()); + float maxLvlFraction = m_pattern->firstObject()->maxValue() * 0.05; // get time map of current pattern timeMap & time_map = m_pattern->getTimeMap(); // will be our iterator in the following loop @@ -957,7 +959,9 @@ void AutomationEditor::mouseMoveEvent(QMouseEvent * mouseEvent) // existing value if (pos_ticks >= it.key() - MidiTime::ticksPerTact() *4 / m_ppt && (it+1==time_map.end() || pos_ticks <= (it+1).key()) - && (pos_ticks<= it.key() + MidiTime::ticksPerTact() *4 / m_ppt)) + && (pos_ticks<= it.key() + MidiTime::ticksPerTact() *4 / m_ppt) + && (mouseLevel > it.value() - maxLvlFraction) + && (mouseLevel < it.value() + maxLvlFraction)) { break; } @@ -1086,6 +1090,8 @@ void AutomationEditor::mouseDoubleClickEvent(QMouseEvent * mouseEvent) { // set or move value x -= VALUES_WIDTH; + float mouseLevel = getLevel(mouseEvent->y()); + float maxLvlFraction = m_pattern->firstObject()->maxValue() * 0.05; // get tick in which the cursor is posated int pos_ticks = x * MidiTime::ticksPerTact() / m_ppt + m_currentPosition; @@ -1101,7 +1107,9 @@ void AutomationEditor::mouseDoubleClickEvent(QMouseEvent * mouseEvent) // existing value if (pos_ticks >= it.key() - MidiTime::ticksPerTact() *4 / m_ppt && (it+1==time_map.end() || pos_ticks <= (it+1).key()) - && (pos_ticks<= it.key() + MidiTime::ticksPerTact() *4 / m_ppt)) + && (pos_ticks<= it.key() + MidiTime::ticksPerTact() *4 / m_ppt) + && (mouseLevel > it.value() - maxLvlFraction) + && (mouseLevel < it.value() + maxLvlFraction)) { break; } @@ -1198,6 +1206,7 @@ void AutomationEditor::wheelEvent(QWheelEvent * we) { // set or move value x -= VALUES_WIDTH; + float maxLvlFraction = m_pattern->firstObject()->maxValue() * 0.05; // get tick in which the cursor is posated int pos_ticks = x * MidiTime::ticksPerTact() / m_ppt + m_currentPosition; @@ -1215,7 +1224,9 @@ void AutomationEditor::wheelEvent(QWheelEvent * we) if (pos_ticks >= it.key() - MidiTime::ticksPerTact() *4 / m_ppt && (it+1==time_map.end() || pos_ticks <= (it+1).key()) - && (pos_ticks<= it.key() + MidiTime::ticksPerTact() *4 / m_ppt)) + && (pos_ticks<= it.key() + MidiTime::ticksPerTact() *4 / m_ppt) + && (level > it.value() - maxLvlFraction) + && (level < it.value() + maxLvlFraction)) { // mouse wheel up if (we->delta() < 0) From 05dbcb7ba24e5b7a2dd64009ff6db333d6226adc Mon Sep 17 00:00:00 2001 From: tecknixia Date: Wed, 16 Oct 2019 21:15:05 -0500 Subject: [PATCH 14/14] Mouse Control Enhancements --- src/gui/editors/AutomationEditor.cpp | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/gui/editors/AutomationEditor.cpp b/src/gui/editors/AutomationEditor.cpp index 8ad65aaea56..a667f726bbf 100644 --- a/src/gui/editors/AutomationEditor.cpp +++ b/src/gui/editors/AutomationEditor.cpp @@ -530,11 +530,10 @@ void AutomationEditor::mousePressEvent( QMouseEvent* mouseEvent ) { // and check whether the user clicked on an // existing value - if( pos_ticks >= it.key() && - ( it+1==time_map.end() || - pos_ticks <= (it+1).key() ) && - ( pos_ticks<= it.key() + MidiTime::ticksPerTact() *4 / m_ppt ) && - ( level == it.value() || mouseEvent->button() == Qt::RightButton ) ) + if(pos_ticks >= it.key() + && (it+1==time_map.end() || pos_ticks <= (it+1).key()) + && (pos_ticks<= it.key() + MidiTime::ticksPerTact() * 12 / m_ppt) + && (level == it.value() || mouseEvent->button() == Qt::RightButton)) { break; } @@ -957,9 +956,9 @@ void AutomationEditor::mouseMoveEvent(QMouseEvent * mouseEvent) { // and check whether the cursor is over an // existing value - if (pos_ticks >= it.key() - MidiTime::ticksPerTact() *4 / m_ppt + if (pos_ticks >= it.key() - MidiTime::ticksPerTact() * 12 / m_ppt && (it+1==time_map.end() || pos_ticks <= (it+1).key()) - && (pos_ticks<= it.key() + MidiTime::ticksPerTact() *4 / m_ppt) + && (pos_ticks<= it.key() + MidiTime::ticksPerTact() * 12 / m_ppt) && (mouseLevel > it.value() - maxLvlFraction) && (mouseLevel < it.value() + maxLvlFraction)) { @@ -1105,9 +1104,9 @@ void AutomationEditor::mouseDoubleClickEvent(QMouseEvent * mouseEvent) { // and check whether the cursor is over an // existing value - if (pos_ticks >= it.key() - MidiTime::ticksPerTact() *4 / m_ppt + if (pos_ticks >= it.key() - MidiTime::ticksPerTact() * 12 / m_ppt && (it+1==time_map.end() || pos_ticks <= (it+1).key()) - && (pos_ticks<= it.key() + MidiTime::ticksPerTact() *4 / m_ppt) + && (pos_ticks<= it.key() + MidiTime::ticksPerTact() * 12 / m_ppt) && (mouseLevel > it.value() - maxLvlFraction) && (mouseLevel < it.value() + maxLvlFraction)) { @@ -1118,7 +1117,7 @@ void AutomationEditor::mouseDoubleClickEvent(QMouseEvent * mouseEvent) bool ok; double d = QInputDialog::getDouble(this, tr("Edit Point"), - tr("Enter Y Coordinate:"), m_pointYLevel, 0, m_pattern->firstObject()->maxValue(), 3, &ok); + tr("New Y Value:"), m_pointYLevel, 0, m_pattern->firstObject()->maxValue(), 3, &ok); if (ok) { @@ -1222,9 +1221,9 @@ void AutomationEditor::wheelEvent(QWheelEvent * we) { pos_ticks = (pos_ticks < 0) ? 0 : pos_ticks; - if (pos_ticks >= it.key() - MidiTime::ticksPerTact() *4 / m_ppt + if (pos_ticks >= it.key() - MidiTime::ticksPerTact() * 12 / m_ppt && (it+1==time_map.end() || pos_ticks <= (it+1).key()) - && (pos_ticks<= it.key() + MidiTime::ticksPerTact() *4 / m_ppt) + && (pos_ticks<= it.key() + MidiTime::ticksPerTact() * 12 / m_ppt) && (level > it.value() - maxLvlFraction) && (level < it.value() + maxLvlFraction)) {