From 7cb7bc1dcf0243bbb738dd33b55ebb92d40ecb7f Mon Sep 17 00:00:00 2001 From: llama Date: Tue, 31 Mar 2009 19:56:12 -0500 Subject: [PATCH] GIT SUCKS BALLS. FINALLY A COMMIT FROM WEEKS AGO --- .../gui/tracks/track_content_object_item.h | 5 ++ src/gui/tracks/track_content_object_item.cpp | 51 ++++++++++++++++++- 2 files changed, 54 insertions(+), 2 deletions(-) diff --git a/include/gui/tracks/track_content_object_item.h b/include/gui/tracks/track_content_object_item.h index cb297b3cf..1715fe007 100644 --- a/include/gui/tracks/track_content_object_item.h +++ b/include/gui/tracks/track_content_object_item.h @@ -67,6 +67,11 @@ public: // For TrackItem to call void updateGeometry(); + virtual bool resizable() + { + return false; + } + protected: virtual QVariant itemChange( GraphicsItemChange _change, const QVariant & _value ); diff --git a/src/gui/tracks/track_content_object_item.cpp b/src/gui/tracks/track_content_object_item.cpp index 7bc3a976f..95c217ec6 100644 --- a/src/gui/tracks/track_content_object_item.cpp +++ b/src/gui/tracks/track_content_object_item.cpp @@ -149,10 +149,11 @@ QVariant TrackContentObjectItem::itemChange( GraphicsItemChange _change, { newPos.setX( 0 ); } + /* FUCK_GIT if( newPos.y() < 0 ) { newPos.setY( 0 ); - } + } */ /* Let's just short-circuit the Y for now if( fmod( newPos.y(), 32 ) != 16 ) @@ -220,8 +221,53 @@ void TrackContentObjectItem::mouseReleaseEvent( QGraphicsSceneMouseEvent * event setCursor( Qt::OpenHandCursor ); QTimeLine * timeLine = new QTimeLine(); - prepareSnapBackAnimation( timeLine ); + //prepareSnapBackAnimation( timeLine ); + const float ppt = 16.0f; + const bool doSnap = true; + + QList selItems = scene()->selectedItems(); + + if( selItems.count() <= 1 ) + { + midiTime t = qMax( 0, (int)( x() * midiTime::ticksPerTact() / ppt ) ); + m_tco->movePosition( doSnap ? t.toNearestTact() : t ); + } + else + { + // Find first item, TODO: Or maybe the item-under-mouse? + qreal earliestX = x(); + midiTime earliestTime = m_tco->startPosition(); + + for( QList::iterator it = selItems.begin(); + it != selItems.end(); ++it ) + { + + TrackContentObjectItem * tcoItem = + dynamic_cast( *it ); + if( tcoItem->x() < earliestX ) + { + earliestX = qMin( earliestX, tcoItem->x() ); + earliestTime = tcoItem->m_tco->startPosition(); + } + } + + midiTime t = qMax( 0, (int)( earliestX * midiTime::ticksPerTact() / ppt ) ); + midiTime dt = ( doSnap ? t.toNearestTact() : t ) - earliestTime; + + for( QList::iterator it = selItems.begin(); + it != selItems.end(); ++it ) { + + trackContentObject * tco = + dynamic_cast( *it )->m_tco; + + tco->movePosition( tco->startPosition() + dt ); + } + + } + + + /* FUCK_GIT if( isSelected() ) { QList selItems = scene()->selectedItems(); for( QList::iterator it = selItems.begin(); @@ -242,6 +288,7 @@ void TrackContentObjectItem::mouseReleaseEvent( QGraphicsSceneMouseEvent * event timeLine->setCurveShape( QTimeLine::EaseInOutCurve ); connect( timeLine, SIGNAL(finished()), timeLine, SLOT(deleteLater())); timeLine->start(); + */ }