There you go!

git diff from the development snapshot of a few days ago

2011/4/6 Tobias Doerffel <[email protected]>

> Hi,
>
> Am Dienstag, 5. April 2011, 17:32:36 schrieb François-Marie de Jouvencel:
> > I was missing the ability to show the notes from other tracks when
> editing
> > melodies and/or beats/basslines, so, having little to do this afternoon I
> > put together a (dirty?) little hack to do so,
> >
> Thanks for the patch! However I'm not able to apply it as it has been
> created
> with some kind of strange diff format. Please send a new one in unified
> diff
> format (e.g. "git diff" or "git show").
>
> Toby
>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2dffb35..905cc41 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,6 +2,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0)
 
 PROJECT(lmms)
 
+
 SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH})
 
 IF(COMMAND CMAKE_POLICY)
@@ -14,6 +15,7 @@ INCLUDE(CheckIncludeFiles)
 INCLUDE(CheckLibraryExists)
 INCLUDE(FindPkgConfig)
 
+
 SET(VERSION_MAJOR "0")
 SET(VERSION_MINOR "4")
 SET(VERSION_PATCH "90")
diff --git a/include/piano_roll.h b/include/piano_roll.h
index 29c0a1d..fc4f635 100644
--- a/include/piano_roll.h
+++ b/include/piano_roll.h
@@ -96,6 +96,7 @@ public slots:
 	void record();
 	void recordAccompany();
 	void stop();
+	void show();
 
 
 protected:
@@ -113,13 +114,13 @@ protected:
 
 	int getKey( int _y ) const;
 	static inline void drawNoteRect( QPainter & _p, int _x, int _y,
-					int  _width, note * _n );
+					int  _width, note * _n,
+					bool isFromOtherTrack = false);
 	void removeSelection();
 	void selectAll();
 	void getSelectedNotes( NoteVector & _selected_notes );
-
-
-protected slots:
+	
+    protected slots:
 	void startRecordNote( const note & _n );
 	void finishRecordNote( const note & _n );
 
@@ -238,6 +239,8 @@ private:
 	toolButton * m_cutButton;
 	toolButton * m_copyButton;
 	toolButton * m_pasteButton;
+	
+	toolButton * m_showOtherTracksButton;
 
 	comboBox * m_zoomingComboBox;
 	comboBox * m_quantizeComboBox;
@@ -256,6 +259,8 @@ private:
 	midiTime m_currentPosition;
 	bool m_recording;
 	QList<note> m_recordingNotes;
+	
+	bool m_showOtherTracks;
 
 	note * m_currentNote;
 	Actions m_action;
diff --git a/plugins/sf2_player/sf2_player.cpp b/plugins/sf2_player/sf2_player.cpp
index 35e9961..e866533 100644
--- a/plugins/sf2_player/sf2_player.cpp
+++ b/plugins/sf2_player/sf2_player.cpp
@@ -132,8 +132,9 @@ sf2Instrument::sf2Instrument( InstrumentTrack * _instrument_track ) :
 
 	InstrumentPlayHandle * iph = new InstrumentPlayHandle( this );
 	engine::mixer()->addPlayHandle( iph );
-
-	loadFile( configManager::inst()->defaultSoundfont() );
+	
+	//TODO : create the function
+	//loadFile( configManager::inst()->defaultSoundfont() );
 
 	updateSampleRate();
 	updateReverbOn();
diff --git a/src/gui/piano_roll.cpp b/src/gui/piano_roll.cpp
index b6c3c36..0cd820d 100644
--- a/src/gui/piano_roll.cpp
+++ b/src/gui/piano_roll.cpp
@@ -68,6 +68,8 @@
 #include "tooltip.h"
 #include "fluiq/collapsible_widget.h"
 
+#include <iostream>
+#include <bb_track.h>
 
 typedef AutomationPattern::timeMap timeMap;
 
@@ -145,6 +147,7 @@ pianoRoll::pianoRoll() :
 	m_pattern( NULL ),
 	m_currentPosition(),
 	m_recording( false ),
+	m_showOtherTracks(false),
 	m_currentNote( NULL ),
 	m_action( ActionNone ),
 	m_noteEditMode( NoteEditVolume ),
@@ -372,7 +375,11 @@ pianoRoll::pianoRoll() :
 		    "automation detuning. You can utilize this to slide "
 		    "notes from one to another. You can also press "
 		    "'Shift+T' on your keyboard to activate this mode." ) );
-
+	
+	m_showOtherTracksButton = new toolButton( embed::getIconPixmap( "note" ),
+		    tr( "Show/Hide notes from other tacks" ),
+		    this, SLOT( show() ), m_toolBar );
+		    
 	m_cutButton = new toolButton( embed::getIconPixmap( "edit_cut" ),
 					tr( "Cut selected notes (Ctrl+X)" ),
 					this, SLOT( cutSelectedNotes() ),
@@ -481,6 +488,7 @@ pianoRoll::pianoRoll() :
 	tb_layout->addWidget( m_selectButton );
 	tb_layout->addWidget( m_detuneButton );
 	tb_layout->addSpacing( 10 );
+	tb_layout->addWidget( m_showOtherTracksButton );
 	tb_layout->addWidget( m_cutButton );
 	tb_layout->addWidget( m_copyButton );
 	tb_layout->addWidget( m_pasteButton );
@@ -631,11 +639,13 @@ void pianoRoll::loadSettings( const QDomElement & _this )
 
 
 inline void pianoRoll::drawNoteRect( QPainter & _p, int _x, int _y,
-					int _width, note * _n )
+					int _width, note * _n, bool isFromOtherTrack)
 {
 	++_x;
 	++_y;
 	_width -= 2;
+	
+	int otherTrackAlpha = 64;
 
 	if( _width <= 0 )
 	{
@@ -660,7 +670,13 @@ inline void pianoRoll::drawNoteRect( QPainter & _p, int _x, int _y,
 	if( _n->length() < 0 )
 	{
 		//step note
-		col = engine::getLmmsStyle()->color( LmmsStyle::PianoRollStepNote );
+		col = engine::getLmmsStyle()->color( LmmsStyle::PianoRollStepNote);
+		_p.fillRect( _x, _y, _width, KeyLineHeight - 2, col );
+	}
+	else if(isFromOtherTrack)
+	{
+		//col.setRgb(255, 255, 255);
+		col.setAlpha(otherTrackAlpha);
 		_p.fillRect( _x, _y, _width, KeyLineHeight - 2, col );
 	}
 	else if( _n->isSelected() )
@@ -688,6 +704,7 @@ inline void pianoRoll::drawNoteRect( QPainter & _p, int _x, int _y,
 	}
 	
 	// hilighting lines around the note
+	
 	_p.setPen( Qt::SolidLine );
 	_p.setBrush( Qt::NoBrush );
 	
@@ -705,16 +722,19 @@ inline void pianoRoll::drawNoteRect( QPainter & _p, int _x, int _y,
 	
 	// that little tab thing on the end hinting at the user
 	// to resize the note
-	_p.setPen( defaultNoteColor.lighter( 200 ) );
-	if( _width > 2 )
+	if(!isFromOtherTrack)
 	{
-		_p.drawLine( _x + _width - 3, _y + 2, _x + _width - 3,
-						_y + KeyLineHeight - 4 );
+	    _p.setPen( defaultNoteColor.lighter( 200 ) );
+	    if( _width > 2 )
+	    {
+		    _p.drawLine( _x + _width - 3, _y + 2, _x + _width - 3,
+						    _y + KeyLineHeight - 4 );
+	    }
+	    _p.drawLine( _x + _width - 1, _y + 2, _x + _width - 1,
+						    _y + KeyLineHeight - 4 );
+	    _p.drawLine( _x + _width - 2, _y + 2, _x + _width - 2,
+						    _y + KeyLineHeight - 4 );
 	}
-	_p.drawLine( _x + _width - 1, _y + 2, _x + _width - 1,
-						_y + KeyLineHeight - 4 );
-	_p.drawLine( _x + _width - 2, _y + 2, _x + _width - 2,
-						_y + KeyLineHeight - 4 );
 }
 
 
@@ -2685,6 +2705,58 @@ void pianoRoll::paintEvent( QPaintEvent * _pe )
 				height() - TopMargin );
 
 		const NoteVector & notes = m_pattern->notes();
+		
+		std::vector<NoteVector> noteVectors;
+		
+		
+		//get all the notes at the same position
+		if(m_showOtherTracks && m_pattern->getTrack()->type() == track::InstrumentTrack)
+		{
+		    trackContainer *tc;
+		    //if(and m_pattern->getTrack()->getTrackContainer()->nodeName()=="bbtrackcontainer")
+		    tc = m_pattern->getTrack()->getTrackContainer();
+		    
+		    track::tcoVector tcos;
+		    trackContainer::trackList trks;
+		    
+		    bool areBB = (tc->nodeName()=="bbtrackcontainer");
+		    if(areBB)
+		    {
+			//if I understand correctly, a bbTrackContainer contains 
+			//one instrument per track and the different beats are stored as
+			//TCOs inside each unique instrument track
+			//thus to display the notes I loop over all tracks inside the bbTrackContainer
+			//and get the TCOs having the index of the current BB
+			//is there a simpler way?
+			bbTrackContainer *bbtc = dynamic_cast<bbTrackContainer*>(tc);
+			int cbb = bbtc->currentBB();
+			trks = bbtc->tracks();
+			for(trackContainer::trackList::ConstIterator t = trks.begin(); t!=trks.end(); t++)
+			{
+			    if((*t)->type()==track::InstrumentTrack)
+			    {
+				pattern *p = dynamic_cast<pattern*>((*t)->getTCO(cbb));
+				noteVectors.push_back(p->notes());
+			    }
+			}
+		    }
+		    else
+		    {
+			trks = tc->tracks();
+			for(trackContainer::trackList::ConstIterator t = trks.begin(); t!= trks.end(); t++)
+			{
+			    if((*t)->type() == track::InstrumentTrack && (*t)->id() != m_pattern->getTrack()->id())
+			    {
+				(*t)->getTCOsInRange(tcos,m_pattern->startPosition(),m_pattern->endPosition());
+				for(track::tcoVector::ConstIterator tco = tcos.begin(); tco!=tcos.end(); tco++)
+				{
+				    pattern *p = dynamic_cast<pattern*>(*tco);
+				    noteVectors.push_back(p->notes());
+				}
+			    }
+			}
+		    }
+		}
 
 		const int visible_keys = ( keyAreaBottom()-keyAreaTop() ) /
 							KeyLineHeight + 2;
@@ -2697,10 +2769,16 @@ void pianoRoll::paintEvent( QPaintEvent * _pe )
 							QColor( 64, 64, 64 ) );
 	
 		QPolygon editHandles;
-
-		for( NoteVector::ConstIterator it = notes.begin();
-						it != notes.end(); ++it )
+		
+		noteVectors.push_back(notes);
+		
+		for(std::vector<NoteVector>::iterator niter = noteVectors.begin();
+		    niter!= noteVectors.end(); niter++)
+		    for( NoteVector::ConstIterator it = niter->begin();
+						    it != niter->end(); ++it )
 		{
+			bool isFromOtherTrack = (niter!=noteVectors.end()-1);
+			
 			Sint32 len_ticks = ( *it )->length();
 
 			if( len_ticks == 0 )
@@ -2735,12 +2813,16 @@ void pianoRoll::paintEvent( QPaintEvent * _pe )
 				// note
 				drawNoteRect( p, x + WhiteKeyWidth,
 						y_base - key * KeyLineHeight,
-								note_width, *it );
+								note_width, *it, isFromOtherTrack);
 			}
 			
 			// draw note editing stuff
 			int editHandleTop = 0;
-			if( m_noteEditMode == NoteEditVolume )
+			if(isFromOtherTrack)
+			{
+			    //do nothing
+			}
+			else if( m_noteEditMode == NoteEditVolume )
 			{
 				QColor color = engine::getLmmsStyle()->color(
 						( *it )->isSelected() ?
@@ -3074,7 +3156,20 @@ void pianoRoll::stop()
 	m_scrollBack = true;
 }
 
-
+void pianoRoll::show()
+{
+    if(m_showOtherTracks)
+    {
+	m_showOtherTracks = false;
+	m_showOtherTracksButton->setIcon(embed::getIconPixmap( "note_half" ));
+    }
+    else
+    {
+	m_showOtherTracks = true;
+	m_showOtherTracksButton->setIcon(embed::getIconPixmap( "note" ));
+    }
+    update();
+}
 
 
 void pianoRoll::startRecordNote( const note & _n )
------------------------------------------------------------------------------
Xperia(TM) PLAY
It's a major breakthrough. An authentic gaming
smartphone on the nation's most reliable network.
And it wants your games.
http://p.sf.net/sfu/verizon-sfdev
_______________________________________________
LMMS-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/lmms-devel

Reply via email to