Song editor: fix jittery tracks bug (issue #286)

This commit is contained in:
Vesa
2014-03-08 11:43:05 +02:00
parent 31fa7ca061
commit 0947bcf70f
3 changed files with 16 additions and 9 deletions

View File

@@ -2,7 +2,7 @@
* TrackContainerView.h - view-component for TrackContainer
*
* Copyright (c) 2004-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
* This program is free software; you can redistribute it and/or
@@ -23,8 +23,8 @@
*/
#ifndef _TRACK_CONTAINER_VIEW_H
#define _TRACK_CONTAINER_VIEW_H
#ifndef TRACK_CONTAINER_VIEW_H
#define TRACK_CONTAINER_VIEW_H
#include <QtCore/QVector>
#include <QtGui/QScrollArea>

View File

@@ -2403,10 +2403,12 @@ void trackView::mouseMoveEvent( QMouseEvent * _me )
else if( m_action == MoveTrack )
{
// look which track-widget the mouse-cursor is over
const trackView * track_at_y =
m_trackContainerView->trackViewAt(
mapTo( m_trackContainerView->contentWidget(),
_me->pos() ).y() );
const int y_pos = m_trackContainerView->contentWidget()->mapFromGlobal( _me->globalPos() ).y();
const trackView * track_at_y = m_trackContainerView->trackViewAt( y_pos );
// debug code
// qDebug( "y position %d", y_pos );
// a track-widget not equal to ourself?
if( track_at_y != NULL && track_at_y != this )
{

View File

@@ -2,7 +2,7 @@
* TrackContainerView.cpp - view-component for TrackContainer
*
* Copyright (c) 2004-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
* This program is free software; you can redistribute it and/or
@@ -252,11 +252,16 @@ void TrackContainerView::deleteTrackView( trackView * _tv )
const trackView * TrackContainerView::trackViewAt( const int _y ) const
{
const int abs_y = _y + m_scrollArea->viewport()->y();
const int abs_y = _y + m_scrollArea->verticalScrollBar()->value();
int y_cnt = 0;
// debug code
// qDebug( "abs_y %d", abs_y );
for( trackViewList::const_iterator it = m_trackViews.begin();
it != m_trackViews.end(); ++it )
{
i++;
const int y_cnt1 = y_cnt;
y_cnt += ( *it )->height();
if( abs_y >= y_cnt1 && abs_y < y_cnt )