Hi all,

This is a patch that makes live recording work again, it also includes a
new class (LCDCombo) that is still buggy as hell, it should by used in
the pattern editor panel to enable changing pattern size by clicking on
the LCD display widget but it still needs much more testing but I can't
find any solutions to make it stable. Hopefully you can help.
        Greetz
diff -Naurx '*kde*' -x '*oxy*' -x '*~*' -x '*svn*' aikie/gui/gui.pro trunk/gui/gui.pro
--- aikie/gui/gui.pro	2006-05-10 17:49:57.000000000 +0200
+++ trunk/gui/gui.pro	2006-05-10 22:41:46.000000000 +0200
@@ -116,6 +116,7 @@
 	src/widgets/PixmapWidget.cpp \
 	src/widgets/Rotary.cpp \
 	src/widgets/DownloadWidget.cpp \
+	src/widgets/LCDCombo.cpp \
 	\
 	src/SoundLibrary/SoundLibraryTree.cpp\
 	src/SoundLibrary/SoundLibraryPanel.cpp\
@@ -169,6 +170,7 @@
 	src/widgets/PixmapWidget.h \
 	src/widgets/Rotary.h \
 	src/widgets/DownloadWidget.h \
+	src/widgets/LCDCombo.h \
 	\
 	src/SoundLibrary/SoundLibraryTree.h \
 	src/SoundLibrary/SoundLibraryPanel.h \
diff -Naurx '*kde*' -x '*oxy*' -x '*~*' -x '*svn*' aikie/gui/src/AboutDialog.cpp trunk/gui/src/AboutDialog.cpp
--- aikie/gui/src/AboutDialog.cpp	2006-03-19 22:17:36.000000000 +0100
+++ trunk/gui/src/AboutDialog.cpp	2006-05-10 17:44:11.000000000 +0200
@@ -50,7 +50,7 @@
 	move( 240, 100 );
 
 	QString about;
-	about += "<center><b>Hydrogen Drum Machine " + QString(VERSION) + " [" + __DATE__ + "]  </b><br>";
+	about += "<center><b>Hydrogen Drum Machine </b><br>";
 	about += tr( "<b>Website</b><br>" );
 	about += "<a href=\"http://www.hydrogen-music.org\";>http://www.hydrogen-music.org</a><br><br>";
 	about += tr( "<b>Project page</b><br>");
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-10 17:49:55.000000000 +0200
+++ trunk/gui/src/PatternEditor/PatternEditorPanel.cpp	2006-05-11 22:41:22.000000000 +0200
@@ -37,6 +37,7 @@
 #include "../widgets/Button.h"
 #include "../widgets/Fader.h"
 #include "../widgets/PixmapWidget.h"
+
 #include "../Skin.h"
 #include "../SongEditor/SongEditorPanel.h"
 
@@ -80,6 +81,14 @@
 	pPatternPropertiesPanel->setPixmap( "/patternEditor/background_res.png" );
 	pPatternPropertiesPanel->setFixedSize( 156, 43 );
 
+	/*
+	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_pPatternSizeLCD->move( 14, 21 );
@@ -568,6 +577,11 @@
 {
 }
 
+/*
+void PatternEditorPanel::testfunction(QString* test){
+	_WARNINGLOG("test: ");
+}
+*/
 
 
 void PatternEditorPanel::syncToExternalHorizontalScrollbar(int)
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-04-11 00:05:29.000000000 +0200
+++ trunk/gui/src/PatternEditor/PatternEditorPanel.h	2006-05-11 22:41:31.000000000 +0200
@@ -40,6 +40,7 @@
 
 #include "../EventListener.h"
 #include "../widgets/LCD.h"
+#include "../widgets/LCDCombo.h"
 
 
 class Button;
@@ -82,6 +83,8 @@
 		//~ Implements EventListener interface
 
 	public slots:
+		//void testfunction( QString *string );
+
 		void sizeDropdownBtnClicked(Button *ref);
 		void resDropdownBtnClicked(Button *ref);
 
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	1970-01-01 01:00:00.000000000 +0100
+++ trunk/gui/src/widgets/LCDCombo.cpp	2006-05-11 22:46:47.000000000 +0200
@@ -0,0 +1,130 @@
+/*
+ * Hydrogen
+ * Copyright(c) 2002-2006 by Alex >Comix< Cominu [EMAIL PROTECTED]
+ *
+ * http://www.hydrogen-music.org
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY, without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
+
+#include "LCDCombo.h"
+
+#include <string>
+#include <vector>
+#include <iostream>
+
+#include "../Skin.h"
+#include "LCD.h"
+#include "Button.h"
+
+#include <QWidget>
+#include <QMenu>
+#include <QPixmap>
+#include <QMouseEvent>
+#include <QWheelEvent>
+#include <QPaintEvent>
+#include <QPainter>
+
+#include <hydrogen/Globals.h>
+
+using namespace std;
+
+LCDCombo::LCDCombo(QWidget *pParent, int digits)
+: QWidget(pParent), 
+Object( "LCDCombo")
+{
+	vector<string> items;
+	display = new LCDDisplay( this, LCDDigit::SMALL_BLUE, digits, false);
+	button = new Button( this,
+			"/patternEditor/btn_dropdown_on.png",
+			"/patternEditor/btn_dropdown_off.png",
+			"/patternEditor/btn_dropdown_over.png",
+			QSize(13, 13)
+	);
+	pop = new QMenu( this );
+	size=digits;
+	QPalette defaultPalette;
+	defaultPalette.setColor( QPalette::Background, QColor( 10, 10, 10 ) );
+	defaultPalette.setColor( QPalette::Foreground, QColor( 230, 230, 230 ) );
+	this->setPalette( defaultPalette );
+
+	button->move( (digits*8)+3 , 1);
+	setMaximumWidth((digits*8)+17);
+	connect( button, SIGNAL( clicked(Button*) ), this, SLOT( onClick(Button*) ) );
+	
+	items.push_back("test");
+	
+	connect( pop, SIGNAL( triggered(QAction*) ), this, SLOT( changeText(QAction*) ) );
+	//_WARNINGLOG("items:"+items[0]);
+}
+
+
+LCDCombo::~LCDCombo()
+{
+}
+
+void LCDCombo::changeText(QAction* pAction){
+	_WARNINGLOG("triggered");
+	display->setText(pAction->text());
+	emit valueChanged( pAction->text() );
+}
+
+
+
+void LCDCombo::onClick(Button*){
+	pop->popup( display->mapToGlobal( QPoint( 1, display->height() + 2 ) ) );
+}
+int LCDCombo::length(){
+	return size;
+}
+void LCDCombo::update(){
+	pop->clear();
+	for(int i=0; i<=items.size();i++){
+		pop->addAction(QString::fromStdString(items[i]));
+	}
+}
+int LCDCombo::count(){
+	return items.size(); 
+}
+
+bool LCDCombo::addItem(const QString &text, const QVariant &userData ){
+	if(text.size()<=length()){
+		items.push_back(  text.toStdString() );
+		update();
+		return true;
+	}else{
+		return false;
+	}
+}
+
+inline void LCDCombo::insertItem(int index, const QString &text, const QVariant &userData ){
+}
+
+
+void LCDCombo::insertItems(int index, const QStringList &texts){
+	
+}
+
+void LCDCombo::mousePressEvent(QMouseEvent *ev){
+	pop->popup( display->mapToGlobal( QPoint( 1, display->height() + 2 ) ) );
+}
+void LCDCombo::mouseMoveEvent(QMouseEvent *ev){
+}
+void LCDCombo::wheelEvent( QWheelEvent *ev ){
+}
+void LCDCombo::paintEvent(QPaintEvent *ev){
+}
+
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	1970-01-01 01:00:00.000000000 +0100
+++ trunk/gui/src/widgets/LCDCombo.h	2006-05-11 21:48:39.000000000 +0200
@@ -0,0 +1,82 @@
+/*
+ * Hydrogen
+ * Copyright(c) 2002-2006 by Alex >Comix< Cominu [EMAIL PROTECTED]
+ *
+ * http://www.hydrogen-music.org
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY, without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
+
+#ifndef LCDCOMBO_H
+#define LCDCOMBO_H
+
+#include <string>
+#include <vector>
+#include <iostream>
+
+#include "LCDCombo.h"
+
+#include "../Skin.h"
+#include "LCD.h"
+#include "Button.h"
+
+#include <QWidget>
+#include <QPixmap>
+#include <QMouseEvent>
+#include <QWheelEvent>
+#include <QPaintEvent>
+#include <QPainter>
+#include <QMenu>
+
+#include <hydrogen/Object.h>
+
+
+class LCDCombo : public QWidget, public Object
+{
+	Q_OBJECT
+public:
+    	LCDCombo(QWidget *pParrent, int digits = 5);
+
+    	~LCDCombo();
+
+	int count();
+	int length();
+	void update();
+	bool addItem(const QString &text, const QVariant &userData = QVariant());
+    	inline void addItems(const QStringList &texts)
+        	{ insertItems(count(), texts); }
+
+    	inline void insertItem(int index, const QString &text, const QVariant &userData = QVariant());
+    	void insertItems(int index, const QStringList &texts);
+
+	virtual void mousePressEvent(QMouseEvent *ev);
+	virtual void mouseMoveEvent(QMouseEvent *ev);
+	virtual void wheelEvent( QWheelEvent *ev );
+	virtual void paintEvent(QPaintEvent *ev);
+public slots:
+	void changeText(QAction*);
+	void onClick(Button*);
+signals:
+	void valueChanged( QString );
+private:
+	std::vector<std::string> items;
+	LCDDisplay *display;
+	Button *button;
+	QMenu *pop;
+	int size;
+};
+
+#endif
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-10 17:49:58.000000000 +0200
+++ trunk/libs/hydrogen/src/Hydrogen.cpp	2006-05-10 22:38:13.000000000 +0200
@@ -1686,7 +1686,7 @@
 	bool hearnote = forcePlay;
 
 
-
+	
 	AudioEngine::getInstance()->lock( "Hydrogen::addRealtimeNote" );	// lock the audio engine
 
 	Song *song = getSong();
@@ -1700,18 +1700,15 @@
 
 	realcolumn = getRealtimeTickPosition();
 
-	//printf ("orig tickpos=%u  real=%u\n", column, realcolumn);
-
 	// quantize it to scale
 	int qcolumn = (int)::round(column / (double)scalar) * scalar;
 	if (qcolumn == MAX_NOTES) qcolumn = 0;
 
-	//printf ("column=%d  qcol=%d\n", column, qcolumn);
-
 	if (pref->getQuantizeEvents()) {
 		column = qcolumn;
 	}
 
+
 	unsigned position = column;
 
 	Pattern* currentPattern = NULL;
@@ -1731,8 +1728,8 @@
 			std::multimap <int, Note*>::iterator pos;
 			for ( pos = currentPattern->m_noteMap.lower_bound( nNote ); pos != currentPattern->m_noteMap.upper_bound( nNote ); ++pos ) {
 				Note *pNote = pos->second;
-				if ( pNote ) {
-					if ( pNote->getInstrument() == instrRef ) {
+				if ( pNote!=NULL ) {
+					if ( pNote->getInstrument() == instrRef && nNote==column) {
 						bNoteAlreadyExist = true;
 						break;
 					}

Reply via email to