Hello

Now both the pattern size and the grid resolution selectors use the
LCDCombo class, also when changing the name of a pattern, it is also
updated in the pattern editor area.
You won't see mee for a while now, I have to concentrate on my books and
exams.
        Pieter
diff -Naurx '*kde*' -x '*oxy*' -x '*~*' -x '*svn*' aikie/gui/src/PatternEditor/PatternEditorPanel.cpp trunk/gui/src/PatternEditor/PatternEditorPanel.cpp
--- aikie/gui/src/PatternEditor/PatternEditorPanel.cpp	2006-05-17 01:25:26.000000000 +0200
+++ trunk/gui/src/PatternEditor/PatternEditorPanel.cpp	2006-05-17 01:16:21.000000000 +0200
@@ -81,16 +81,18 @@
 	pPatternPropertiesPanel->setPixmap( "/patternEditor/background_res.png" );
 	pPatternPropertiesPanel->setFixedSize( 156, 43 );
 
-/*
-	**** TEST LCD COMBO ****
-	LCDCombo *test = new LCDCombo(pPatternPropertiesPanel);
-	test->addItem("test2");
-	test->addItem("test1");
-//	connect( test, SIGNAL( valueChanged( QString*)), this, SLOT( testfunction(QString*)));
-*/
-
 	// PATTERN size
-	m_pPatternSizeLCD = new LCDDisplay( pPatternPropertiesPanel, LCDDigit::SMALL_BLUE, 4 );
+	m_pPatternSizeLCDCombo = new LCDCombo( pPatternPropertiesPanel, 4 );
+	m_pPatternSizeLCDCombo->move( 14, 21 );
+	m_pPatternSizeLCDCombo->setPalette( defaultPalette );
+	m_pPatternSizeLCDCombo->setToolTip( trUtf8("Select pattern size") );
+	for ( int i = 1; i <= 32; i++) {
+		m_pPatternSizeLCDCombo->addItem( QString( "%1" ).arg( i ) );
+	}
+	m_pPatternSizeLCDCombo->update();
+	connect( m_pPatternSizeLCDCombo, SIGNAL( valueChanged( QString* ) ), this, SLOT( patternSizeChanged(QString*) ) );
+
+/*	m_pPatternSizeLCD = new LCDDisplay( pPatternPropertiesPanel, LCDDigit::SMALL_BLUE, 4 );
 	m_pPatternSizeLCD->move( 14, 21 );
 	m_pPatternSizeLCD->setPalette( defaultPalette );
 
@@ -110,9 +112,29 @@
 		m_pPatternSizePopup->addAction( QString( "%1" ).arg( i ) );
 	}
 	connect( m_pPatternSizePopup, SIGNAL( triggered(QAction*) ), this, SLOT( patternSizeChanged(QAction*) ) );
-
+*/
+	
 	// GRID resolution
-	m_pResolutionLCD = new LCDDisplay( pPatternPropertiesPanel, LCDDigit::SMALL_BLUE, 7 );
+	m_pResolutionLCDCombo = new LCDCombo( pPatternPropertiesPanel, 7);
+	m_pResolutionLCDCombo->move( 68, 21 );
+	m_pResolutionLCDCombo->setPalette( defaultPalette );
+	m_pResolutionLCDCombo->setToolTip(trUtf8("Select grid resolution"));
+	m_pResolutionLCDCombo->addItem( "4" );
+	m_pResolutionLCDCombo->addItem( "8" );
+	m_pResolutionLCDCombo->addItem( "16" );
+	m_pResolutionLCDCombo->addItem( "32" );
+	m_pResolutionLCDCombo->addItem( "64" );
+	m_pResolutionLCDCombo->addSeparator();
+	m_pResolutionLCDCombo->addItem( "4T" );
+	m_pResolutionLCDCombo->addItem( "8T" );
+	m_pResolutionLCDCombo->addItem( "16T" );
+	m_pResolutionLCDCombo->addItem( "32T" );
+	m_pResolutionLCDCombo->addSeparator();
+	m_pResolutionLCDCombo->addItem( "off" );
+	m_pResolutionLCDCombo->update();
+	connect( m_pResolutionLCDCombo, SIGNAL(valueChanged(QString* )), this, SLOT(gridResolutionChanged(QString* )));
+
+/*	m_pResolutionLCD = new LCDDisplay( pPatternPropertiesPanel, LCDDigit::SMALL_BLUE, 7 );
 	m_pResolutionLCD->move( 68, 21 );
 	m_pResolutionLCD->setPalette( defaultPalette );
 
@@ -141,7 +163,7 @@
 	m_pResolutionPopup->addSeparator();
 	m_pResolutionPopup->addAction( "off" );
 	connect( m_pResolutionPopup, SIGNAL( triggered(QAction*) ), this, SLOT( gridResolutionChanged(QAction*) ) );
-
+*/
 
 
 	PixmapWidget *pRecordingPanel = new PixmapWidget( NULL );
@@ -494,61 +516,61 @@
 	if ( pPref->isPatternEditorUsingTriplets() == false ) {
 		switch ( pPref->getPatternEditorGridResolution() ) {
 			case 4:
-				m_pResolutionLCD->setText( "4" );
+				m_pResolutionLCDCombo->setText( "4" );
 				nIndex = 0;
 				break;
 
 			case 8:
-				m_pResolutionLCD->setText( "8" );
+				m_pResolutionLCDCombo->setText( "8" );
 				nIndex = 1;
 				break;
 
 			case 16:
-				m_pResolutionLCD->setText( "16" );
+				m_pResolutionLCDCombo->setText( "16" );
 				nIndex = 2;
 				break;
 
 			case 32:
-				m_pResolutionLCD->setText( "32" );
+				m_pResolutionLCDCombo->setText( "32" );
 				nIndex = 3;
 				break;
 
 			case 64:
-				m_pResolutionLCD->setText( "64" );
+				m_pResolutionLCDCombo->setText( "64" );
 				nIndex = 4;
 				break;
 
 			default:
 				WARNINGLOG( "Wrong grid resolution: " + toString( pPref->getPatternEditorGridResolution() ) );
-				m_pResolutionLCD->setText( "4" );
+				m_pResolutionLCDCombo->setText( "4" );
 				nIndex = 0;
 		}
 	}
 	else {
 		switch ( pPref->getPatternEditorGridResolution() ) {
 			case 8:
-				m_pResolutionLCD->setText( "4T" );
+				m_pResolutionLCDCombo->setText( "4T" );
 				nIndex = 5;
 				break;
 
 			case 16:
-				m_pResolutionLCD->setText( "8T" );
+				m_pResolutionLCDCombo->setText( "8T" );
 				nIndex = 6;
 				break;
 
 			case 32:
-				m_pResolutionLCD->setText( "16T" );
+				m_pResolutionLCDCombo->setText( "16T" );
 				nIndex = 7;
 				break;
 
 			case 64:
-				m_pResolutionLCD->setText( "32T" );
+				m_pResolutionLCDCombo->setText( "32T" );
 				nIndex = 8;
 				break;
 
 			default:
 				WARNINGLOG( "Wrong grid resolution: " + toString( pPref->getPatternEditorGridResolution() ) );
-				m_pResolutionLCD->setText( "4T" );
+				m_pResolutionLCDCombo->setText( "4T" );
 				nIndex = 5;
 		}
 	}
@@ -579,11 +601,6 @@
 {
 }
 
-/*
-void PatternEditorPanel::testfunction(QString* test){
-	_WARNINGLOG("test: ");
-}
-*/
 
 
 void PatternEditorPanel::syncToExternalHorizontalScrollbar(int)
@@ -622,62 +639,23 @@
 
 
 
-void PatternEditorPanel::gridResolutionChanged( QAction* pAction )
+void PatternEditorPanel::gridResolutionChanged( QString* pString )
 {
-	QString sText = pAction->text();
-
+	QString *sText = pString;
 	int nResolution;
 	bool bUseTriplets = false;
 
-	if ( sText == "4" ) {
-		nResolution = 4;
-		m_pResolutionLCD->setText( sText );
-	}
-	else if ( sText == "8" ) {
-		nResolution = 8;
-		m_pResolutionLCD->setText( sText );
-	}
-	else if ( sText == "16" ) {
-		nResolution = 16;
-		m_pResolutionLCD->setText( sText );
-	}
-	else if ( sText == "32" ) {
-		nResolution = 32;
-		m_pResolutionLCD->setText( sText );
-	}
-	else if ( sText == "64" ) {
-		nResolution = 64;
-		m_pResolutionLCD->setText( sText );
-	}
-	else if ( sText == "4T" ) {
-		nResolution = 8;
-		bUseTriplets = true;
-		m_pResolutionLCD->setText( sText );
-	}
-	else if ( sText == "8T" ) {
-		nResolution = 16;
-		bUseTriplets = true;
-		m_pResolutionLCD->setText( sText );
-	}
-	else if ( sText == "16T" ) {
-		nResolution = 32;
-		bUseTriplets = true;
-		m_pResolutionLCD->setText( sText );
-	}
-	else if ( sText == "32T" ) {
-		nResolution = 64;
-		bUseTriplets = true;
-		m_pResolutionLCD->setText( sText );
-	}
-	else if ( sText == "off" ) {
-		nResolution = MAX_NOTES;
-		m_pResolutionLCD->setText( sText );
-	}
-	else {
-		ERRORLOG( "[gridResolutionChanged] wrong value: " + sText.toStdString() );
-		nResolution = 4;
-		m_pResolutionLCD->setText( "4" );
+	if(sText->contains("off")){
+		nResolution=MAX_NOTES;
+	} else if(sText->contains("T")){
+		bUseTriplets=true;
+		QString *temp=sText;
+		temp->chop(1);
+		nResolution=temp->toInt()*2;
+	}else{
+		nResolution=sText->toInt();
 	}
+	
 	m_pDrumPatternEditor->setResolution( nResolution, bUseTriplets );
 
 	Preferences::getInstance()->setPatternEditorGridResolution( nResolution );
@@ -716,7 +694,7 @@
 		int nEighth = MAX_NOTES / 8;
 		for ( int i = 1; i <= 32; i++ ) {
 			if ( nPatternSize == nEighth * i ) {
-				m_pPatternSizeLCD->setText( QString( "%1" ).arg( i ) );
+				m_pPatternSizeLCDCombo->setText( QString( "%1" ).arg( i ) );
 				break;
 			}
 		}
@@ -732,25 +710,6 @@
 	resizeEvent( NULL ); // force an update of the scrollbars
 }
 
-
-
-
-
-void PatternEditorPanel::sizeDropdownBtnClicked( Button* pRef )
-{
-	UNUSED( pRef );
-	m_pPatternSizePopup->popup( m_pPatternSizeLCD->mapToGlobal( QPoint( 1, m_pPatternSizeLCD->height() + 2 ) ) );
-}
-
-
-void PatternEditorPanel::resDropdownBtnClicked( Button* pRef)
-{
-	UNUSED( pRef );
-	m_pResolutionPopup->popup( m_pResolutionLCD->mapToGlobal( QPoint( 1, m_pResolutionLCD->height() + 2 ) ) );
-}
-
-
-
 void PatternEditorPanel::hearNotesBtnClick(Button *ref)
 {
 	Preferences *pref = ( Preferences::getInstance() );
@@ -965,7 +924,7 @@
 
 
 
-void PatternEditorPanel::patternSizeChanged( QAction *pAction )
+void PatternEditorPanel::patternSizeChanged( QString *pString )
 {
 	INFOLOG( "pattern size changed" );
 
@@ -980,10 +939,10 @@
 
 	uint nEighth = MAX_NOTES / 8;
 
-	int nSelected = pAction->text().toInt();
+	int nSelected = pString->toInt();
 	if ( nSelected > 0 && nSelected <= 32 ) {
 		m_pPattern->m_nSize = nEighth * nSelected;
-		m_pPatternSizeLCD->setText( QString( "%1" ).arg( nSelected ) );
+		//m_pPatternSizeLCD->setText( QString( "%1" ).arg( nSelected ) );
 	}
 	else {
 		ERRORLOG( "[patternSizeChanged] Unhandled case " + toString( nSelected ) );
diff -Naurx '*kde*' -x '*oxy*' -x '*~*' -x '*svn*' aikie/gui/src/PatternEditor/PatternEditorPanel.h trunk/gui/src/PatternEditor/PatternEditorPanel.h
--- aikie/gui/src/PatternEditor/PatternEditorPanel.h	2006-05-17 01:25:26.000000000 +0200
+++ trunk/gui/src/PatternEditor/PatternEditorPanel.h	2006-05-17 01:11:09.000000000 +0200
@@ -83,13 +83,9 @@
 		//~ Implements EventListener interface
 
 	public slots:
-		//void testfunction( QString *string );
 
-		void sizeDropdownBtnClicked(Button *ref);
-		void resDropdownBtnClicked(Button *ref);
-
-		void gridResolutionChanged( QAction* ev );
-		void patternSizeChanged( QAction *ev );
+		void gridResolutionChanged( QString *text );
+		void patternSizeChanged( QString *text );
 
 		void hearNotesBtnClick(Button *ref);
 		void recordEventsBtnClick(Button *ref);
@@ -147,11 +143,8 @@
 		// TOOLBAR
 		QLabel *m_pPatternNameLbl;
 
-		LCDDisplay *m_pResolutionLCD;
-		QMenu *m_pResolutionPopup;
-
-		LCDDisplay *m_pPatternSizeLCD;
-		QMenu *m_pPatternSizePopup;
+		LCDCombo *m_pResolutionLCDCombo;
+		LCDCombo *m_pPatternSizeLCDCombo;
 
 		Button *m_pMoveUpBtn;
 		Button *m_pMoveDownBtn;
diff -Naurx '*kde*' -x '*oxy*' -x '*~*' -x '*svn*' aikie/gui/src/SongEditor/SongEditor.cpp trunk/gui/src/SongEditor/SongEditor.cpp
--- aikie/gui/src/SongEditor/SongEditor.cpp	2006-05-17 01:25:27.000000000 +0200
+++ trunk/gui/src/SongEditor/SongEditor.cpp	2006-05-17 10:37:56.000000000 +0200
@@ -888,6 +888,7 @@
 		Hydrogen *engine = Hydrogen::getInstance();
 		Song *song = engine->getSong();
 		song->m_bIsModified = true;
+		engine->setSelectedPatternNumber(nSelectedPattern);
 		createBackground();
 		update();
 	}
diff -Naurx '*kde*' -x '*oxy*' -x '*~*' -x '*svn*' aikie/gui/src/widgets/LCDCombo.cpp trunk/gui/src/widgets/LCDCombo.cpp
--- aikie/gui/src/widgets/LCDCombo.cpp	2006-05-17 01:25:27.000000000 +0200
+++ trunk/gui/src/widgets/LCDCombo.cpp	2006-05-17 00:46:10.000000000 +0200
@@ -23,7 +23,6 @@
 #include "LCDCombo.h"
 
 #include <string>
-#include <vector>
 #include <iostream>
 
 #include "../Skin.h"
@@ -40,7 +39,6 @@
 
 #include <hydrogen/Globals.h>
 
-using namespace std;
 
 LCDCombo::LCDCombo(QWidget *pParent, int digits)
  : QWidget(pParent)
@@ -48,7 +46,7 @@
 {
 	INFOLOG( "INIT" );
 	
-	vector<QString> items;
+	QStringList items;
 	display = new LCDDisplay( this, LCDDigit::SMALL_BLUE, digits, false);
 	button = new Button( this,
 			"/patternEditor/btn_dropdown_on.png",
@@ -63,7 +61,7 @@
 	defaultPalette.setColor( QPalette::Foreground, QColor( 230, 230, 230 ) );
 	this->setPalette( defaultPalette );
 
-	button->move( ( digits * 8 ) + 3 , 1 );
+	button->move( ( digits * 8 ) + 5 , 1 );
 	setMaximumWidth( ( digits * 8 ) + 17 );
 	connect( button, SIGNAL( clicked( Button* ) ), this, SLOT( onClick( Button* ) ) );
 
@@ -85,7 +83,7 @@
 {
 	_WARNINGLOG("triggered");
 	display->setText(pAction->text());
-	emit valueChanged( pAction->text() );
+	emit valueChanged( &pAction->text() );
 }
 
 
@@ -106,13 +104,16 @@
 
 void LCDCombo::update()
 {
-	INFOLOG( "update" );
-
+	INFOLOG ( "update: "+toString(items.size()) );
 	pop->clear();
 
 //BUG	for( int i = 0; i <= items.size(); i++ ) {
 	for( int i = 0; i < items.size(); i++ ) {
-		pop->addAction( items[ i ] );
+		if(items.at(i)!=QString("--sep--")){
+			pop->addAction( items.at(i) );
+		}else{
+			pop->addSeparator();
+		}
 	}
 
 }
@@ -128,19 +129,26 @@
 {
 	INFOLOG( "add item" );
 	
-	if(text.size()<=length()){
-		items.push_back(  text );
-		update();
+	if(text.size()<=size){
+		items.append( text );
 		return true;
 	}else{
 		return false;
 	}
 }
 
+void LCDCombo::addSeparator(){
+	items.append( QString("--sep--") );
+}
+
 
 
 inline void LCDCombo::insertItem(int index, const QString &text, const QVariant &userData )
 {
+	if(text.size()<=length()){
+		items.insert(index,text);
+		update();
+	}
 }
 
 
@@ -157,8 +165,8 @@
 	pop->popup( display->mapToGlobal( QPoint( 1, display->height() + 2 ) ) );
 }
 
-
-
-
+void LCDCombo::setText( const QString &text){
+	display->setText( text );
+}
 
 
diff -Naurx '*kde*' -x '*oxy*' -x '*~*' -x '*svn*' aikie/gui/src/widgets/LCDCombo.h trunk/gui/src/widgets/LCDCombo.h
--- aikie/gui/src/widgets/LCDCombo.h	2006-05-17 01:25:27.000000000 +0200
+++ trunk/gui/src/widgets/LCDCombo.h	2006-05-17 00:46:02.000000000 +0200
@@ -24,7 +24,6 @@
 #define LCDCOMBO_H
 
 #include <string>
-#include <vector>
 #include <iostream>
 
 #include "LCDCombo.h"
@@ -56,7 +55,9 @@
 		int count();
 		int length();
 		void update();
+		void setText( const QString &text );
 		bool addItem(const QString &text, const QVariant &userData = QVariant());
+		void addSeparator();
 		inline void addItems(const QStringList &texts) {	insertItems(count(), texts);	}
 
 		inline void insertItem(int index, const QString &text, const QVariant &userData = QVariant());
@@ -69,10 +70,10 @@
 		void onClick(Button*);
 
 	signals:
-		void valueChanged( QString );
+		void valueChanged( QString* );
 	
 	private:
-		std::vector<QString> items;
+		QStringList items;
 		LCDDisplay *display;
 		Button *button;
 		QMenu *pop;
diff -Naurx '*kde*' -x '*oxy*' -x '*~*' -x '*svn*' aikie/libs/hydrogen/src/Hydrogen.cpp trunk/libs/hydrogen/src/Hydrogen.cpp
--- aikie/libs/hydrogen/src/Hydrogen.cpp	2006-05-17 01:25:27.000000000 +0200
+++ trunk/libs/hydrogen/src/Hydrogen.cpp	2006-05-17 10:26:11.000000000 +0200
@@ -2326,7 +2326,7 @@
 void Hydrogen::setSelectedPatternNumber(int nPat)
 {
 	// FIXME: controllare se e' valido..
-	if (nPat == m_nSelectedPatternNumber)	return;
+	//if (nPat == m_nSelectedPatternNumber)	return;
 
 	m_nSelectedPatternNumber = nPat;
 

Reply via email to