From 0947bcf70f1e8d7defff6a0d3ef1259158cba0d0 Mon Sep 17 00:00:00 2001 From: Vesa Date: Sat, 8 Mar 2014 11:43:05 +0200 Subject: [PATCH] Song editor: fix jittery tracks bug (issue #286) --- include/TrackContainerView.h | 6 +++--- src/core/track.cpp | 10 ++++++---- src/gui/TrackContainerView.cpp | 9 +++++++-- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/include/TrackContainerView.h b/include/TrackContainerView.h index a18bf5a78..48d8c4957 100644 --- a/include/TrackContainerView.h +++ b/include/TrackContainerView.h @@ -2,7 +2,7 @@ * TrackContainerView.h - view-component for TrackContainer * * Copyright (c) 2004-2014 Tobias Doerffel - * + * * 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 #include diff --git a/src/core/track.cpp b/src/core/track.cpp index 3d0c563d5..66452bfa6 100644 --- a/src/core/track.cpp +++ b/src/core/track.cpp @@ -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 ) { diff --git a/src/gui/TrackContainerView.cpp b/src/gui/TrackContainerView.cpp index 29a2e3295..51e0b7788 100644 --- a/src/gui/TrackContainerView.cpp +++ b/src/gui/TrackContainerView.cpp @@ -2,7 +2,7 @@ * TrackContainerView.cpp - view-component for TrackContainer * * Copyright (c) 2004-2014 Tobias Doerffel - * + * * 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 )