diff --git a/include/Track.h b/include/Track.h index 800524a9e..d09b955fc 100644 --- a/include/Track.h +++ b/include/Track.h @@ -121,6 +121,16 @@ public: return m_length; } + inline void setAutoResize( const bool _r ) + { + m_autoResize = _r; + } + + inline const bool getAutoResize() const + { + return m_autoResize; + } + virtual void movePosition( const MidiTime & _pos ); virtual void changeLength( const MidiTime & _length ); @@ -165,6 +175,7 @@ private: BoolModel m_mutedModel; BoolModel m_soloModel; + bool m_autoResize; bool m_selectViewOnCreate; @@ -216,7 +227,6 @@ protected: virtual void mouseMoveEvent( QMouseEvent * _me ); virtual void mouseReleaseEvent( QMouseEvent * _me ); - void setAutoResizeEnabled( bool _e = false ); float pixelsPerTact(); inline TrackView * getTrackView() @@ -248,7 +258,6 @@ private: TrackContentObject * m_tco; TrackView * m_trackView; Actions m_action; - bool m_autoResize; QPoint m_initialMousePos; QPoint m_initialMouseGlobalPos; diff --git a/include/TrackContainer.h b/include/TrackContainer.h index d932f32dd..2e31e0814 100644 --- a/include/TrackContainer.h +++ b/include/TrackContainer.h @@ -42,6 +42,11 @@ class EXPORT TrackContainer : public Model, public JournallingObject Q_OBJECT public: typedef QVector TrackList; + enum TrackContainerTypes + { + BBContainer, + SongContainer + } ; TrackContainer(); virtual ~TrackContainer(); @@ -78,6 +83,16 @@ public: return "trackcontainer"; } + inline void setType( TrackContainerTypes newType ) + { + m_TrackContainerType = newType; + } + + inline TrackContainerTypes type() const + { + return m_TrackContainerType; + } + signals: void trackAdded( Track * _track ); @@ -88,6 +103,8 @@ protected: private: TrackList m_tracks; + TrackContainerTypes m_TrackContainerType; + friend class TrackContainerView; friend class Track; diff --git a/src/core/AutomationPattern.cpp b/src/core/AutomationPattern.cpp index 9185839a4..20ab58de9 100644 --- a/src/core/AutomationPattern.cpp +++ b/src/core/AutomationPattern.cpp @@ -54,6 +54,21 @@ AutomationPattern::AutomationPattern( AutomationTrack * _auto_track ) : m_lastRecordedValue( 0 ) { changeLength( MidiTime( 1, 0 ) ); + if( getTrack() ) + { + switch( getTrack()->trackContainer()->type() ) + { + case TrackContainer::BBContainer: + setAutoResize( true ); + break; + + case TrackContainer::SongContainer: + // move down + default: + setAutoResize( false ); + break; + } + } } @@ -72,6 +87,18 @@ AutomationPattern::AutomationPattern( const AutomationPattern & _pat_to_copy ) : m_timeMap[it.key()] = it.value(); m_tangents[it.key()] = _pat_to_copy.m_tangents[it.key()]; } + switch( getTrack()->trackContainer()->type() ) + { + case TrackContainer::BBContainer: + setAutoResize( true ); + break; + + case TrackContainer::SongContainer: + // move down + default: + setAutoResize( false ); + break; + } } diff --git a/src/core/BBTrackContainer.cpp b/src/core/BBTrackContainer.cpp index 7bf59f1d7..839e40994 100644 --- a/src/core/BBTrackContainer.cpp +++ b/src/core/BBTrackContainer.cpp @@ -42,6 +42,7 @@ BBTrackContainer::BBTrackContainer() : // not change upon setCurrentBB()-call connect( &m_bbComboBoxModel, SIGNAL( dataUnchanged() ), this, SLOT( currentBBChanged() ) ); + setType( BBContainer ); } diff --git a/src/core/Song.cpp b/src/core/Song.cpp index e15533cdf..c4cc905d8 100644 --- a/src/core/Song.cpp +++ b/src/core/Song.cpp @@ -114,6 +114,7 @@ Song::Song() : this, SLOT( masterPitchChanged() ) );*/ qRegisterMetaType( "note" ); + setType( SongContainer ); } diff --git a/src/core/Track.cpp b/src/core/Track.cpp index 63fe1729c..1b5cf1d0e 100644 --- a/src/core/Track.cpp +++ b/src/core/Track.cpp @@ -248,7 +248,6 @@ TrackContentObjectView::TrackContentObjectView( TrackContentObject * _tco, m_tco( _tco ), m_trackView( _tv ), m_action( NoAction ), - m_autoResize( false ), m_initialMousePos( QPoint( 0, 0 ) ), m_initialMouseGlobalPos( QPoint( 0, 0 ) ), m_hint( NULL ), @@ -656,7 +655,7 @@ void TrackContentObjectView::mousePressEvent( QMouseEvent * _me ) "a copy." ), embed::getIconPixmap( "hint" ), 0 ); } - else if( m_autoResize == false ) + else if( !m_tco->getAutoResize() ) { m_action = Resize; m_oldTime = m_tco->length(); @@ -846,7 +845,7 @@ void TrackContentObjectView::mouseMoveEvent( QMouseEvent * _me ) } else { - if( _me->x() > width() - RESIZE_GRIP_WIDTH && !_me->buttons() ) + if( _me->x() > width() - RESIZE_GRIP_WIDTH && !_me->buttons() && !m_tco->getAutoResize() ) { if( QApplication::overrideCursor() != NULL && QApplication::overrideCursor()->shape() != @@ -957,19 +956,6 @@ float TrackContentObjectView::pixelsPerTact() -/*! \brief Set whether this trackContentObjectView can resize. - * - * \param _e The boolean state of whether this track content object view - * is allowed to resize. - */ -void TrackContentObjectView::setAutoResizeEnabled( bool _e ) -{ - m_autoResize = _e; -} - - - - /*! \brief Detect whether the mouse moved more than n pixels on screen. * * \param _me The QMouseEvent. diff --git a/src/gui/AutomationPatternView.cpp b/src/gui/AutomationPatternView.cpp index 1e96839f3..cbea1211e 100644 --- a/src/gui/AutomationPatternView.cpp +++ b/src/gui/AutomationPatternView.cpp @@ -54,7 +54,6 @@ AutomationPatternView::AutomationPatternView( AutomationPattern * _pattern, setAttribute( Qt::WA_OpaquePaintEvent, true ); setFixedHeight( parentWidget()->height() - 2 ); - setAutoResizeEnabled( false ); ToolTip::add( this, tr( "double-click to open this pattern in " "automation editor" ) ); diff --git a/src/tracks/BBTrack.cpp b/src/tracks/BBTrack.cpp index 435fdb5b7..78892e728 100644 --- a/src/tracks/BBTrack.cpp +++ b/src/tracks/BBTrack.cpp @@ -58,6 +58,7 @@ BBTCO::BBTCO( Track * _track ) : changeLength( MidiTime( t, 0 ) ); restoreJournallingState(); } + setAutoResize( false ); } diff --git a/src/tracks/Pattern.cpp b/src/tracks/Pattern.cpp index b934733c5..e527acd03 100644 --- a/src/tracks/Pattern.cpp +++ b/src/tracks/Pattern.cpp @@ -66,6 +66,7 @@ Pattern::Pattern( InstrumentTrack * _instrument_track ) : { setName( _instrument_track->name() ); init(); + setAutoResize( true ); } @@ -83,6 +84,18 @@ Pattern::Pattern( const Pattern& other ) : } init(); + switch( getTrack()->trackContainer()->type() ) + { + case TrackContainer::BBContainer: + setAutoResize( true ); + break; + + case TrackContainer::SongContainer: + // move down + default: + setAutoResize( false ); + break; + } } @@ -635,7 +648,6 @@ PatternView::PatternView( Pattern* pattern, TrackView* parent ) : } setFixedHeight( parentWidget()->height() - 2 ); - setAutoResizeEnabled( false ); ToolTip::add( this, tr( "double-click to open this pattern in piano-roll\n" diff --git a/src/tracks/SampleTrack.cpp b/src/tracks/SampleTrack.cpp index 9ef5f981c..1aa3044e6 100644 --- a/src/tracks/SampleTrack.cpp +++ b/src/tracks/SampleTrack.cpp @@ -62,6 +62,18 @@ SampleTCO::SampleTCO( Track * _track ) : // change length of this TCO connect( Engine::getSong(), SIGNAL( tempoChanged( bpm_t ) ), this, SLOT( updateLength( bpm_t ) ) ); + switch( getTrack()->trackContainer()->type() ) + { + case TrackContainer::BBContainer: + setAutoResize( true ); + break; + + case TrackContainer::SongContainer: + // move down + default: + setAutoResize( false ); + break; + } }