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

Use mean based logic for controlling loop points. #4034

Merged
merged 6 commits into from
Jul 29, 2019
Merged
Changes from all 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
34 changes: 15 additions & 19 deletions src/gui/TimeLineWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,40 +314,36 @@ void TimeLineWidget::mousePressEvent( QMouseEvent* event )
m_action = SelectSongTCO;
m_initalXSelect = event->x();
}
else if( event->button() == Qt::RightButton || event->button() == Qt::MiddleButton )
else if( event->button() == Qt::RightButton )
{
m_moveXOff = s_posMarkerPixmap->width() / 2;
const MidiTime t = m_begin + static_cast<int>( event->x() * MidiTime::ticksPerTact() / m_ppt );
if( m_loopPos[0] > m_loopPos[1] )
{
qSwap( m_loopPos[0], m_loopPos[1] );
}
if( ( event->modifiers() & Qt::ShiftModifier ) || event->button() == Qt::MiddleButton )
m_moveXOff = s_posMarkerPixmap->width() / 2;
const MidiTime t = m_begin + static_cast<int>( qMax( event->x() - m_xOffset - m_moveXOff, 0 ) * MidiTime::ticksPerTact() / m_ppt );
const MidiTime loopMid = ( m_loopPos[0] + m_loopPos[1] ) / 2;

if( t < loopMid )
{
m_action = MoveLoopBegin;
}
else
else if( t > loopMid )
{
m_action = MoveLoopEnd;
}

if( m_loopPos[0] > m_loopPos[1] )
{
qSwap( m_loopPos[0], m_loopPos[1] );
}

m_loopPos[( m_action == MoveLoopBegin ) ? 0 : 1] = t;
}

if( m_action == MoveLoopBegin )
if( m_action == MoveLoopBegin || m_action == MoveLoopEnd )
{
delete m_hint;
m_hint = TextFloat::displayMessage( tr( "Hint" ),
tr( "Press <%1> to disable magnetic loop points." ).arg(UI_CTRL_KEY),
embed::getIconPixmap( "hint" ), 0 );
}
else if( m_action == MoveLoopEnd )
{
delete m_hint;
m_hint = TextFloat::displayMessage( tr( "Hint" ),
tr( "Hold <Shift> to move the begin loop point; Press <%1> to disable magnetic loop points." ).arg(UI_CTRL_KEY),
embed::getIconPixmap( "hint" ), 0 );
}

mouseMoveEvent( event );
}

Expand Down Expand Up @@ -376,7 +372,7 @@ void TimeLineWidget::mouseMoveEvent( QMouseEvent* event )
case MoveLoopBegin:
case MoveLoopEnd:
{
const int i = m_action - MoveLoopBegin;
const int i = m_action - MoveLoopBegin; // i == 0 || i == 1
if( event->modifiers() & Qt::ControlModifier )
{
// no ctrl-press-hint when having ctrl pressed
Expand Down