Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automation point mouse wheel and double click (old) #5232

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/AutomationEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ protected slots:
float m_scrollLevel;
float m_bottomLevel;
float m_topLevel;
float m_pointYLevel;

void updateTopBottomLevels();

Expand Down
66 changes: 65 additions & 1 deletion src/gui/editors/AutomationEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ),
Expand Down Expand Up @@ -728,6 +729,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 )
{
Expand Down Expand Up @@ -1105,7 +1110,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 );
tecknixia marked this conversation as resolved.
Show resolved Hide resolved
} else if (m_pointYLevel != 0) {
QToolTip::showText( tt_pos, QString::number( m_pointYLevel ), this );
}
tecknixia marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down Expand Up @@ -1709,6 +1718,61 @@ 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
tecknixia marked this conversation as resolved.
Show resolved Hide resolved

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;
}
tecknixia marked this conversation as resolved.
Show resolved Hide resolved

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<float>();
// mouse wheel down
} else if (we->delta() > 0) {
level = roundf(it.value() * 1000) / 1000 +
m_pattern->firstObject()->step<float>();
tecknixia marked this conversation as resolved.
Show resolved Hide resolved
}

m_pointYLevel = level;

// set new value
m_pattern->setDragValue(MidiTime(pos_ticks), level, true, false);

// apply new value
m_pattern->applyDragValue();

break;
}
++it;
}
}
}
}
}

Expand Down