From 7a980874149d99539b65cc9df66c217e7be33adf Mon Sep 17 00:00:00 2001 From: "Tim E. Real" Date: Fri, 13 May 2011 20:06:48 +0000 Subject: Changed default imported midi song type to GM. --- muse2/ChangeLog | 1 + muse2/muse/midifile.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'muse2') diff --git a/muse2/ChangeLog b/muse2/ChangeLog index edf65b0b..2e3fa20f 100644 --- a/muse2/ChangeLog +++ b/muse2/ChangeLog @@ -1,5 +1,6 @@ 13.05.2011: - New spanish translation from Cristian Ramos (rj) + - Changed default imported midi song type to GM. (Tim) 12.05.2011: - Changed template song "default.med" song type from NO to GM, to help new users. (Tim) 10.05.2011: diff --git a/muse2/muse/midifile.cpp b/muse2/muse/midifile.cpp index 319152d7..89cf30f6 100644 --- a/muse2/muse/midifile.cpp +++ b/muse2/muse/midifile.cpp @@ -60,7 +60,7 @@ MidiFile::MidiFile(FILE* f) { fp = f; curPos = 0; - _mtype = MT_UNKNOWN; + _mtype = MT_GM; // MT_UNKNOWN; _error = MF_NO_ERROR; _tracks = new MidiFileTrackList; } -- cgit v1.2.3 From 99ccbebf8ce4e7070843fff94f2953c2818ca5c8 Mon Sep 17 00:00:00 2001 From: Robert Jonsson Date: Fri, 13 May 2011 20:18:01 +0000 Subject: find unused wave files --- muse2/ChangeLog | 1 + muse2/muse/app.cpp | 23 +++++- muse2/muse/app.h | 7 +- muse2/muse/widgets/CMakeLists.txt | 9 ++- muse2/muse/widgets/unusedwavefiles.cpp | 96 ++++++++++++++++++++++++ muse2/muse/widgets/unusedwavefiles.h | 25 +++++++ muse2/muse/widgets/unusedwavefiles.ui | 131 +++++++++++++++++++++++++++++++++ 7 files changed, 283 insertions(+), 9 deletions(-) create mode 100644 muse2/muse/widgets/unusedwavefiles.cpp create mode 100644 muse2/muse/widgets/unusedwavefiles.h create mode 100644 muse2/muse/widgets/unusedwavefiles.ui (limited to 'muse2') diff --git a/muse2/ChangeLog b/muse2/ChangeLog index 2e3fa20f..32382091 100644 --- a/muse2/ChangeLog +++ b/muse2/ChangeLog @@ -1,5 +1,6 @@ 13.05.2011: - New spanish translation from Cristian Ramos (rj) + - Added dialog to remove unused wave files (rj) - Changed default imported midi song type to GM. (Tim) 12.05.2011: - Changed template song "default.med" song type from NO to GM, to help new users. (Tim) diff --git a/muse2/muse/app.cpp b/muse2/muse/app.cpp index 59993911..c42a1a7c 100644 --- a/muse2/muse/app.cpp +++ b/muse2/muse/app.cpp @@ -55,6 +55,7 @@ #include "widgets/menutitleitem.h" #include "tools.h" #include "visibletracks.h" +#include "widgets/unusedwavefiles.h" #ifdef DSSI_SUPPORT #include "dssihost.h" @@ -966,6 +967,7 @@ MusE::MusE(int argc, char** argv) : QMainWindow() fileImportPartAction = new QAction(tr("Import Part"), this); fileImportWaveAction = new QAction(tr("Import Wave File"), this); + fileMoveWaveFiles = new QAction(tr("Find unused wave files"), this); quitAction = new QAction(tr("&Quit"), this); @@ -1000,10 +1002,9 @@ MusE::MusE(int argc, char** argv) : QMainWindow() scoreAllInOneSubsubmenu = new QMenu(tr("all parts in one staff"), this); scoreOneStaffPerTrackSubsubmenu = new QMenu(tr("one staff per part"), this); - scoreSubmenu->addMenu(scoreAllInOneSubsubmenu); - scoreSubmenu->addMenu(scoreOneStaffPerTrackSubsubmenu); - - updateScoreMenus(); + scoreSubmenu->addMenu(scoreAllInOneSubsubmenu); + scoreSubmenu->addMenu(scoreOneStaffPerTrackSubsubmenu); + updateScoreMenus(); startScoreEditAction = new QAction(*scoreIconSet, tr("New score window"), this); startPianoEditAction = new QAction(*pianoIconSet, tr("Pianoroll"), this); @@ -1075,6 +1076,7 @@ MusE::MusE(int argc, char** argv) : QMainWindow() autoClearAction = new QAction(QIcon(*automation_clear_dataIcon), tr("Clear Automation Data"), this); autoClearAction->setEnabled(false); + //-------- Settings Actions settingsGlobalAction = new QAction(QIcon(*settings_globalsettingsIcon), tr("Global Settings"), this); settingsShortcutsAction = new QAction(QIcon(*settings_configureshortcutsIcon), tr("Configure Shortcuts"), this); @@ -1116,6 +1118,7 @@ MusE::MusE(int argc, char** argv) : QMainWindow() connect(fileImportPartAction, SIGNAL(activated()), SLOT(importPart())); connect(fileImportWaveAction, SIGNAL(activated()), SLOT(importWave())); + connect(fileMoveWaveFiles, SIGNAL(activated()), SLOT(findUnusedWaveFiles())); connect(quitAction, SIGNAL(activated()), SLOT(quitDoc())); //-------- Edit connections @@ -1342,6 +1345,8 @@ MusE::MusE(int argc, char** argv) : QMainWindow() menu_file->addSeparator(); menu_file->addAction(fileImportWaveAction); menu_file->addSeparator(); + menu_file->addAction(fileMoveWaveFiles); + menu_file->addSeparator(); menu_file->addAction(quitAction); menu_file->addSeparator(); @@ -5098,6 +5103,7 @@ void MusE::execDeliveredScript(int id) //QString scriptfile = QString(INSTPREFIX) + SCRIPTSSUFFIX + deliveredScriptNames[id]; song->executeScript(song->getScriptPath(id, true).toLatin1().constData(), song->getSelectedMidiParts(), 0, false); // TODO: get quant from arranger } + //--------------------------------------------------------- // execUserScript //--------------------------------------------------------- @@ -5105,3 +5111,12 @@ void MusE::execUserScript(int id) { song->executeScript(song->getScriptPath(id, false).toLatin1().constData(), song->getSelectedMidiParts(), 0, false); // TODO: get quant from arranger } + +//--------------------------------------------------------- +// findUnusedWaveFiles +//--------------------------------------------------------- +void MusE::findUnusedWaveFiles() +{ + UnusedWaveFiles unused(muse); + unused.exec(); +} diff --git a/muse2/muse/app.h b/muse2/muse/app.h index 42aebf3b..e940c1ad 100644 --- a/muse2/muse/app.h +++ b/muse2/muse/app.h @@ -104,7 +104,8 @@ class MusE : public QMainWindow // File menu actions QAction *fileSaveAction, *fileOpenAction, *fileNewAction, *testAction; - QAction *fileSaveAsAction, *fileImportMidiAction, *fileExportMidiAction, *fileImportPartAction, *fileImportWaveAction, *quitAction; + QAction *fileSaveAsAction, *fileImportMidiAction, *fileExportMidiAction; + QAction *fileImportPartAction, *fileImportWaveAction, *fileMoveWaveFiles, *quitAction; // Edit Menu actions QAction *editCutAction, *editCopyAction, *editPasteAction, *editInsertAction, *editPasteCloneAction, *editPaste2TrackAction; @@ -160,7 +161,7 @@ class MusE : public QMainWindow QMenu *menu_file, *menuView, *menuSettings, *menu_help; QMenu *menuEdit, *menuStructure; - QMenu* menu_audio, *menuAutomation; + QMenu* menu_audio, *menuAutomation, *menuUtils; QMenu* menu_functions, *menuScriptPlugins; QMenu* select, *master, *midiEdit, *addTrack; @@ -247,6 +248,7 @@ class MusE : public QMainWindow void importWave(); void importPart(); void exportMidi(); + void findUnusedWaveFiles(); void toggleTransport(bool); void toggleMarker(bool); @@ -375,6 +377,7 @@ class MusE : public QMainWindow bool seqStart(); void setHeartBeat(); void importController(int, MidiPort*, int); + QString projectName() { return project.fileName(); } //QWidget* mixerWindow(); QWidget* mixer1Window(); QWidget* mixer2Window(); diff --git a/muse2/muse/widgets/CMakeLists.txt b/muse2/muse/widgets/CMakeLists.txt index 261c27a2..9a3f993a 100644 --- a/muse2/muse/widgets/CMakeLists.txt +++ b/muse2/muse/widgets/CMakeLists.txt @@ -75,7 +75,8 @@ QT4_WRAP_CPP (widget_mocs tools.h # ttoolbar.h ttoolbutton.h - velocity.h + unusedwavefiles.h + velocity.h verticalmeter.h view.h vscale.h @@ -109,7 +110,8 @@ file (GLOB widgets_ui_files songinfo.ui synthconfigbase.ui transformbase.ui - transposebase.ui + transposebase.ui + unusedwavefiles.ui velocitybase.ui ) QT4_WRAP_UI (widget_ui_headers ${widgets_ui_files}) @@ -175,7 +177,8 @@ file (GLOB widgets_source_files tools.cpp ttoolbar.cpp ttoolbutton.cpp - utils.cpp + unusedwavefiles.cpp + utils.cpp velocity.cpp verticalmeter.cpp view.cpp diff --git a/muse2/muse/widgets/unusedwavefiles.cpp b/muse2/muse/widgets/unusedwavefiles.cpp new file mode 100644 index 00000000..7cba1bd5 --- /dev/null +++ b/muse2/muse/widgets/unusedwavefiles.cpp @@ -0,0 +1,96 @@ +#include +#include +#include +#include +#include +#include +#include "unusedwavefiles.h" +#include "ui_unusedwavefiles.h" +#include "globals.h" +#include "app.h" + +UnusedWaveFiles::UnusedWaveFiles(QWidget *parent) : + QDialog(parent), + ui(new Ui::UnusedWaveFiles) +{ + + ui->setupUi(this); + ui->currentProjRadioButton->setChecked(true); + connect(ui->currentProjRadioButton, SIGNAL(clicked()), SLOT(findWaveFiles())); + connect(ui->allProjRadioButton, SIGNAL(clicked()), SLOT(findWaveFiles())); + findWaveFiles(); + +} + +void UnusedWaveFiles::findWaveFiles() +{ + ui->filelistWidget->clear(); + printf("museProject =%s\n", museProject.toLatin1().data()); +// QFileInfo proj(museProject); +// QString projPath = proj.absolutePath(); + QDir dir(museProject); + QStringList filter; + filter.append("*.wav"); + filter.append("*.ogg"); + allWaveFiles= dir.entryList(filter); + if (!allWaveFiles.count()) + return; + // get med files + QStringList medFiles; + if (ui->currentProjRadioButton->isChecked()) { + medFiles.append(muse->projectName()); + } else { + printf("get ALLL *.med files!\n"); + QStringList medFilter("*.med"); + medFiles = dir.entryList(medFilter); + } + foreach (QString medFile, medFiles) { + QString fname = museProject+"/"+ medFile; + //printf("fopen %s\n", fname.toLatin1().data()); + FILE *fp =fopen(fname.toLatin1().data(),"r"); + QTextStream fileContent(fp); + while (!fileContent.atEnd()) { + QString line = fileContent.readLine(); + if (line.contains(".wav") || line.contains(".ogg")) { // optimization + foreach (QString wav, allWaveFiles) { + //printf("checking wav [%s]\n", wav.toLatin1().data() ); + if (line.contains(wav)) { + //int beforeSize=allWaveFiles.size(); + allWaveFiles.removeOne(wav); + //printf("removed one from list, %d %d\n", beforeSize, allWaveFiles.size()); + break; + } + } + } + } + } + + ui->filelistWidget->addItems(allWaveFiles); + update(); +} + +UnusedWaveFiles::~UnusedWaveFiles() +{ + delete ui; +} + +void UnusedWaveFiles::accept() +{ + int ret = QMessageBox::question(this,"Move files", "Are you sure you want to move away the unused files?", + QMessageBox::Ok, QMessageBox::Cancel); + if (ret == QMessageBox::Ok) { + QDir currDir(museProject); + currDir.mkdir("unused"); + + foreach(QString file, allWaveFiles) { + QFile::rename(museProject+ "/"+file, museProject + "/unused/" +file); + // move the wca file if it exists + QFileInfo wf(museProject + "/" + file); + if (QFile::exists(museProject + "/" + wf.baseName()+".wca")) { + QFile::rename(museProject + "/" + wf.baseName()+".wca", museProject + "/unused/" +wf.baseName()+".wca"); + + } + } + } + QDialog::accept(); +} diff --git a/muse2/muse/widgets/unusedwavefiles.h b/muse2/muse/widgets/unusedwavefiles.h new file mode 100644 index 00000000..fd1f524c --- /dev/null +++ b/muse2/muse/widgets/unusedwavefiles.h @@ -0,0 +1,25 @@ +#ifndef UNUSEDWAVEFILES_H +#define UNUSEDWAVEFILES_H + +#include + +namespace Ui { + class UnusedWaveFiles; +} + +class UnusedWaveFiles : public QDialog +{ + Q_OBJECT + QStringList allWaveFiles; +public: + explicit UnusedWaveFiles(QWidget *parent = 0); + ~UnusedWaveFiles(); + +public slots: + void accept(); + void findWaveFiles(); +private: + Ui::UnusedWaveFiles *ui; +}; + +#endif // UNUSEDWAVEFILES_H diff --git a/muse2/muse/widgets/unusedwavefiles.ui b/muse2/muse/widgets/unusedwavefiles.ui new file mode 100644 index 00000000..65c8c804 --- /dev/null +++ b/muse2/muse/widgets/unusedwavefiles.ui @@ -0,0 +1,131 @@ + + + UnusedWaveFiles + + + + 0 + 0 + 508 + 241 + + + + Dialog + + + + + + List of unused audio files in current project directory: + + + + + + + + + Current project + + + + + + + All .med files +in current + directory + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + + Qt::Horizontal + + + + 98 + 17 + + + + + + + + Move files to 'unused' subdir + + + true + + + + + + + Cancel + + + + + + + + + + + cancelButton + clicked() + UnusedWaveFiles + reject() + + + 416 + 331 + + + 305 + 183 + + + + + moveButton + clicked() + UnusedWaveFiles + accept() + + + 266 + 321 + + + 305 + 183 + + + + + -- cgit v1.2.3 From d2f37049cf0b41daa25d1a698c3010a278554956 Mon Sep 17 00:00:00 2001 From: Robert Jonsson Date: Fri, 13 May 2011 22:06:25 +0000 Subject: fclose --- muse2/muse/widgets/unusedwavefiles.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'muse2') diff --git a/muse2/muse/widgets/unusedwavefiles.cpp b/muse2/muse/widgets/unusedwavefiles.cpp index 7cba1bd5..5a2e620b 100644 --- a/muse2/muse/widgets/unusedwavefiles.cpp +++ b/muse2/muse/widgets/unusedwavefiles.cpp @@ -25,7 +25,7 @@ UnusedWaveFiles::UnusedWaveFiles(QWidget *parent) : void UnusedWaveFiles::findWaveFiles() { ui->filelistWidget->clear(); - printf("museProject =%s\n", museProject.toLatin1().data()); + //printf("museProject =%s\n", museProject.toLatin1().data()); // QFileInfo proj(museProject); // QString projPath = proj.absolutePath(); QDir dir(museProject); @@ -40,7 +40,7 @@ void UnusedWaveFiles::findWaveFiles() if (ui->currentProjRadioButton->isChecked()) { medFiles.append(muse->projectName()); } else { - printf("get ALLL *.med files!\n"); + //printf("get ALLL *.med files!\n"); QStringList medFilter("*.med"); medFiles = dir.entryList(medFilter); } @@ -63,6 +63,7 @@ void UnusedWaveFiles::findWaveFiles() } } } + fclose(fp); } ui->filelistWidget->addItems(allWaveFiles); -- cgit v1.2.3 From cce71cb04c36b199b079faa8f6306e43e9605297 Mon Sep 17 00:00:00 2001 From: "Tim E. Real" Date: Sat, 14 May 2011 03:14:33 +0000 Subject: Added GM drums patch in MidiInstrument::populatePatchPopup() for GM songs on ch 10. --- muse2/ChangeLog | 1 + muse2/muse/instruments/minstrument.cpp | 6 ++++++ 2 files changed, 7 insertions(+) (limited to 'muse2') diff --git a/muse2/ChangeLog b/muse2/ChangeLog index 32382091..05f79fe0 100644 --- a/muse2/ChangeLog +++ b/muse2/ChangeLog @@ -2,6 +2,7 @@ - New spanish translation from Cristian Ramos (rj) - Added dialog to remove unused wave files (rj) - Changed default imported midi song type to GM. (Tim) + - Added GM drums patch in MidiInstrument::populatePatchPopup() for GM songs on ch 10. (Tim) 12.05.2011: - Changed template song "default.med" song type from NO to GM, to help new users. (Tim) 10.05.2011: diff --git a/muse2/muse/instruments/minstrument.cpp b/muse2/muse/instruments/minstrument.cpp index 9e52498f..4fde7bf3 100644 --- a/muse2/muse/instruments/minstrument.cpp +++ b/muse2/muse/instruments/minstrument.cpp @@ -891,7 +891,13 @@ void MidiInstrument::populatePatchPopup(QMenu* menu, int chan, MType songType, b case MT_GS: mask = 2; break; case MT_GM: if(drumchan) + { + int id = (0xff << 16) + (0xff << 8) + 0x00; // First patch + QAction* act = menu->addAction(gmdrumname); + //act->setCheckable(true); + act->setData(id); return; + } mask = 1; break; case MT_UNKNOWN: mask = 7; break; -- cgit v1.2.3 From 0021af8ef6f76dd4575bc74da2b20431d58a8f7e Mon Sep 17 00:00:00 2001 From: "Tim E. Real" Date: Sat, 14 May 2011 18:26:21 +0000 Subject: Fixed problem with project save dialog missing a forward slash '/'. --- muse2/ChangeLog | 3 +++ muse2/muse/widgets/projectcreateimpl.cpp | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'muse2') diff --git a/muse2/ChangeLog b/muse2/ChangeLog index 05f79fe0..9379bdf8 100644 --- a/muse2/ChangeLog +++ b/muse2/ChangeLog @@ -1,3 +1,6 @@ +14.05.2011: + - Fixed problem with project save dialog missing a forward slash '/'. (Tim) + ~/.config was being polluted with wrong folders. Fixed ProjectCreateImpl::updateDirectoryPath(). 13.05.2011: - New spanish translation from Cristian Ramos (rj) - Added dialog to remove unused wave files (rj) diff --git a/muse2/muse/widgets/projectcreateimpl.cpp b/muse2/muse/widgets/projectcreateimpl.cpp index d455c917..369e806a 100644 --- a/muse2/muse/widgets/projectcreateimpl.cpp +++ b/muse2/muse/widgets/projectcreateimpl.cpp @@ -45,12 +45,13 @@ void ProjectCreateImpl::updateDirectoryPath() if (createFolderCheckbox->isChecked()) { if (!projectNameEdit->text().isEmpty()) name = projectNameEdit->text() + "/" + projectNameEdit->text() + ".med"; - storageDirEdit->setText(directoryPath + name ); + //storageDirEdit->setText(directoryPath + name ); } else { if (!projectNameEdit->text().isEmpty()) name = projectNameEdit->text() + ".med"; - storageDirEdit->setText(directoryPath +"/" + name); + //storageDirEdit->setText(directoryPath +"/" + name); } + storageDirEdit->setText(directoryPath +"/" + name ); // Tim } QString ProjectCreateImpl::getProjectPath() -- cgit v1.2.3 From 38988a37365c8772da11f3f41d49e5c1fd083084 Mon Sep 17 00:00:00 2001 From: Robert Jonsson Date: Sun, 15 May 2011 18:56:00 +0000 Subject: mouse wheel rework --- muse2/ChangeLog | 8 +++++++ muse2/muse/arranger/arranger.cpp | 46 +++++++++++++++++++++++------------- muse2/muse/arranger/arranger.h | 2 ++ muse2/muse/midiedit/drumedit.cpp | 2 ++ muse2/muse/midiedit/pianoroll.cpp | 2 ++ muse2/muse/midieditor.cpp | 27 +++++++++++++++++++++ muse2/muse/midieditor.h | 4 +++- muse2/muse/waveedit/waveedit.cpp | 31 +++++++++++++++++++++++++ muse2/muse/waveedit/waveedit.h | 3 +++ muse2/muse/waveedit/waveview.cpp | 49 +++++++++++++++++++++++++++++++++++---- muse2/muse/waveedit/waveview.h | 3 +++ muse2/muse/widgets/canvas.cpp | 44 +++++++++++++++++++++++++++++++---- muse2/muse/widgets/canvas.h | 2 ++ 13 files changed, 197 insertions(+), 26 deletions(-) (limited to 'muse2') diff --git a/muse2/ChangeLog b/muse2/ChangeLog index 9379bdf8..fce03eb0 100644 --- a/muse2/ChangeLog +++ b/muse2/ChangeLog @@ -1,3 +1,11 @@ +15.05.2011: + - Changed mouse wheel behaviour in graphical editors except the score editor (rj) + * wheel scrolls left-right + * shift+wheel scrolls up-down + * control+wheel zooms horizontally + TODO: + - score editor + - zoom to where the mouse is located 14.05.2011: - Fixed problem with project save dialog missing a forward slash '/'. (Tim) ~/.config was being polluted with wrong folders. Fixed ProjectCreateImpl::updateDirectoryPath(). diff --git a/muse2/muse/arranger/arranger.cpp b/muse2/muse/arranger/arranger.cpp index 495c4cb8..d74bed78 100644 --- a/muse2/muse/arranger/arranger.cpp +++ b/muse2/muse/arranger/arranger.cpp @@ -384,6 +384,8 @@ Arranger::Arranger(QMainWindow* parent, const char* name) connect(list, SIGNAL(keyPressExt(QKeyEvent*)), canvas, SLOT(redirKeypress(QKeyEvent*))); connect(canvas, SIGNAL(selectTrackAbove()), list, SLOT(selectTrackAbove())); connect(canvas, SIGNAL(selectTrackBelow()), list, SLOT(selectTrackBelow())); + connect(canvas, SIGNAL(horizontalZoomIn()), SLOT(horizontalZoomIn())); + connect(canvas, SIGNAL(horizontalZoomOut()), SLOT(horizontalZoomOut())); connect(this, SIGNAL(redirectWheelEvent(QWheelEvent*)), canvas, SLOT(redirectedWheelEvent(QWheelEvent*))); connect(list, SIGNAL(redirectWheelEvent(QWheelEvent*)), canvas, SLOT(redirectedWheelEvent(QWheelEvent*))); @@ -1078,27 +1080,39 @@ void Arranger::keyPressEvent(QKeyEvent* event) key+= Qt::CTRL; if (key == shortcuts[SHRT_ZOOM_IN].key) { - int mag = hscroll->mag(); - int zoomlvl = ScrollScale::getQuickZoomLevel(mag); - if (zoomlvl < 23) - zoomlvl++; - - int newmag = ScrollScale::convertQuickZoomLevelToMag(zoomlvl); - - hscroll->setMag(newmag); + horizontalZoomIn(); return; } else if (key == shortcuts[SHRT_ZOOM_OUT].key) { - int mag = hscroll->mag(); - int zoomlvl = ScrollScale::getQuickZoomLevel(mag); - if (zoomlvl > 1) - zoomlvl--; - - int newmag = ScrollScale::convertQuickZoomLevelToMag(zoomlvl); - - hscroll->setMag(newmag); + horizontalZoomOut(); return; } QWidget::keyPressEvent(event); } + +void Arranger::horizontalZoomIn() +{ + int mag = hscroll->mag(); + int zoomlvl = ScrollScale::getQuickZoomLevel(mag); + if (zoomlvl < 23) + zoomlvl++; + + int newmag = ScrollScale::convertQuickZoomLevelToMag(zoomlvl); + + hscroll->setMag(newmag); + +} + +void Arranger::horizontalZoomOut() +{ + int mag = hscroll->mag(); + int zoomlvl = ScrollScale::getQuickZoomLevel(mag); + if (zoomlvl > 1) + zoomlvl--; + + int newmag = ScrollScale::convertQuickZoomLevelToMag(zoomlvl); + + hscroll->setMag(newmag); + +} diff --git a/muse2/muse/arranger/arranger.h b/muse2/muse/arranger/arranger.h index 0143afd5..262d7464 100644 --- a/muse2/muse/arranger/arranger.h +++ b/muse2/muse/arranger/arranger.h @@ -122,6 +122,8 @@ class Arranger : public QWidget { void setTempo200(); //void seek(); void verticalScrollSetYpos(unsigned); + void horizontalZoomIn(); + void horizontalZoomOut(); signals: void redirectWheelEvent(QWheelEvent*); diff --git a/muse2/muse/midiedit/drumedit.cpp b/muse2/muse/midiedit/drumedit.cpp index ed3cd0e8..5cd4c130 100644 --- a/muse2/muse/midiedit/drumedit.cpp +++ b/muse2/muse/midiedit/drumedit.cpp @@ -368,6 +368,8 @@ DrumEdit::DrumEdit(PartList* pl, QWidget* parent, const char* name, unsigned ini canvas->setCanvasTools(drumeditTools); canvas->setFocus(); connect(canvas, SIGNAL(toolChanged(int)), tools2, SLOT(set(int))); + connect(canvas, SIGNAL(horizontalZoomIn()), SLOT(horizontalZoomIn())); + connect(canvas, SIGNAL(horizontalZoomOut()), SLOT(horizontalZoomOut())); time->setOrigin(offset, 0); QList mops; diff --git a/muse2/muse/midiedit/pianoroll.cpp b/muse2/muse/midiedit/pianoroll.cpp index 2778d8b9..f02b10a6 100644 --- a/muse2/muse/midiedit/pianoroll.cpp +++ b/muse2/muse/midiedit/pianoroll.cpp @@ -423,6 +423,8 @@ PianoRoll::PianoRoll(PartList* pl, QWidget* parent, const char* name, unsigned i canvas->setCanvasTools(pianorollTools); canvas->setFocus(); connect(canvas, SIGNAL(toolChanged(int)), tools2, SLOT(set(int))); + connect(canvas, SIGNAL(horizontalZoomIn()), SLOT(horizontalZoomIn())); + connect(canvas, SIGNAL(horizontalZoomOut()), SLOT(horizontalZoomOut())); time->setOrigin(offset, 0); gridS1->setRowStretch(2, 100); diff --git a/muse2/muse/midieditor.cpp b/muse2/muse/midieditor.cpp index 9191233d..7e25972c 100644 --- a/muse2/muse/midieditor.cpp +++ b/muse2/muse/midieditor.cpp @@ -241,3 +241,30 @@ void MidiEditor::setCurCanvasPart(Part* part) canvas->setCurrentPart(part); } +void MidiEditor::horizontalZoomIn() +{ + printf("zoom in \n"); + int mag = hscroll->mag(); + int zoomlvl = ScrollScale::getQuickZoomLevel(mag); + if (zoomlvl < 23) + zoomlvl++; + + int newmag = ScrollScale::convertQuickZoomLevelToMag(zoomlvl); + + hscroll->setMag(newmag); + +} + +void MidiEditor::horizontalZoomOut() +{ + printf("zoom out \n"); + int mag = hscroll->mag(); + int zoomlvl = ScrollScale::getQuickZoomLevel(mag); + if (zoomlvl > 1) + zoomlvl--; + + int newmag = ScrollScale::convertQuickZoomLevelToMag(zoomlvl); + + hscroll->setMag(newmag); + +} diff --git a/muse2/muse/midieditor.h b/muse2/muse/midieditor.h index 1f465c2d..c5668abf 100644 --- a/muse2/muse/midieditor.h +++ b/muse2/muse/midieditor.h @@ -55,7 +55,9 @@ class MidiEditor : public TopWin { public slots: void songChanged(int type); void setCurDrumInstrument(int instr); - + void horizontalZoomIn(); + void horizontalZoomOut(); + virtual void updateHScrollRange() { }; signals: void curDrumInstrumentChanged(int); diff --git a/muse2/muse/waveedit/waveedit.cpp b/muse2/muse/waveedit/waveedit.cpp index 2350a2c5..ccfb2730 100644 --- a/muse2/muse/waveedit/waveedit.cpp +++ b/muse2/muse/waveedit/waveedit.cpp @@ -222,6 +222,9 @@ WaveEdit::WaveEdit(PartList* pl) ymag->setFixedWidth(16); connect(view, SIGNAL(mouseWheelMoved(int)), this, SLOT(moveVerticalSlider(int))); connect(ymag, SIGNAL(valueChanged(int)), view, SLOT(setYScale(int))); + connect(view, SIGNAL(horizontalZoomIn()), SLOT(horizontalZoomIn())); + connect(view, SIGNAL(horizontalZoomOut()), SLOT(horizontalZoomOut())); + time->setOrigin(0, 0); mainGrid->setRowStretch(0, 100); @@ -246,6 +249,8 @@ WaveEdit::WaveEdit(PartList* pl) // connect(time, SIGNAL(timeChanged(unsigned)), SLOT(setTime(unsigned))); connect(view, SIGNAL(timeChanged(unsigned)), SLOT(setTime(unsigned))); + connect(view, SIGNAL(horizontalScroll(unsigned)),hscroll, SLOT(setPos(unsigned))); + connect(hscroll, SIGNAL(scaleChanged(int)), SLOT(updateHScrollRange())); connect(song, SIGNAL(songChanged(int)), SLOT(songChanged1(int))); @@ -498,3 +503,29 @@ void WaveEdit::moveVerticalSlider(int val) ymag->setValue(ymag->value() + val); } + +void WaveEdit::horizontalZoomIn() +{ + int mag = hscroll->mag(); + int zoomlvl = ScrollScale::getQuickZoomLevel(mag); + if (zoomlvl < 23) + zoomlvl++; + + int newmag = ScrollScale::convertQuickZoomLevelToMag(zoomlvl); + + hscroll->setMag(newmag); + +} + +void WaveEdit::horizontalZoomOut() +{ + int mag = hscroll->mag(); + int zoomlvl = ScrollScale::getQuickZoomLevel(mag); + if (zoomlvl > 1) + zoomlvl--; + + int newmag = ScrollScale::convertQuickZoomLevelToMag(zoomlvl); + + hscroll->setMag(newmag); + +} diff --git a/muse2/muse/waveedit/waveedit.h b/muse2/muse/waveedit/waveedit.h index 67230897..b4000794 100644 --- a/muse2/muse/waveedit/waveedit.h +++ b/muse2/muse/waveedit/waveedit.h @@ -66,6 +66,9 @@ class WaveEdit : public MidiEditor { void configChanged(); virtual void updateHScrollRange(); + void horizontalZoomIn(); + void horizontalZoomOut(); + signals: void deleted(unsigned long); diff --git a/muse2/muse/waveedit/waveview.cpp b/muse2/muse/waveedit/waveview.cpp index f83ae1d5..0c387f72 100644 --- a/muse2/muse/waveedit/waveview.cpp +++ b/muse2/muse/waveedit/waveview.cpp @@ -25,6 +25,7 @@ #include "waveedit.h" #include "audio.h" #include "gconfig.h" +#include "fastlog.h" bool modifyWarnedYet = false; //--------------------------------------------------------- @@ -381,14 +382,52 @@ void WaveView::viewMousePressEvent(QMouseEvent* event) viewMouseMoveEvent(event); } - +#define WHEEL_STEPSIZE 40 +#define WHEEL_DELTA 120 //--------------------------------------------------------- // wheelEvent //--------------------------------------------------------- -void WaveView::wheelEvent(QWheelEvent* event) - { - emit mouseWheelMoved(event->delta() / 10); - } +void WaveView::wheelEvent(QWheelEvent* ev) +{ + int keyState = ev->modifiers(); + + bool shift = keyState & Qt::ShiftModifier; + bool alt = keyState & Qt::AltModifier; + bool ctrl = keyState & Qt::ControlModifier; + + if (shift) { // scroll vertically + emit mouseWheelMoved(ev->delta() / 10); + + } else if (ctrl) { // zoom horizontally + if (ev->delta()>0) + emit horizontalZoomIn(); + else + emit horizontalZoomOut(); + + } else { // scroll horizontally + int delta = ev->delta() / WHEEL_DELTA; + int xpixelscale = 5*fast_log10(rmapxDev(1)); + + + if (xpixelscale <= 0) + xpixelscale = 1; + + int scrollstep = WHEEL_STEPSIZE * (delta); + ///if (ev->state() == Qt::ShiftModifier) +// if (((QInputEvent*)ev)->modifiers() == Qt::ShiftModifier) + scrollstep = scrollstep / 10; + + int newXpos = xpos + xpixelscale * scrollstep; + + if (newXpos < 0) + newXpos = 0; + + //setYPos(newYpos); + emit horizontalScroll((unsigned)newXpos); + + } + +} //--------------------------------------------------------- // viewMouseReleaseEvent diff --git a/muse2/muse/waveedit/waveview.h b/muse2/muse/waveedit/waveview.h index 3ee0d5f8..c7992952 100644 --- a/muse2/muse/waveedit/waveview.h +++ b/muse2/muse/waveedit/waveview.h @@ -88,6 +88,9 @@ class WaveView : public View { void followEvent(int); void timeChanged(unsigned); void mouseWheelMoved(int); + void horizontalScroll(unsigned); + void horizontalZoomIn(); + void horizontalZoomOut(); public: WaveView(MidiEditor*, QWidget* parent, int xscale, int yscale); diff --git a/muse2/muse/widgets/canvas.cpp b/muse2/muse/widgets/canvas.cpp index 14f414b7..07ad1d1f 100644 --- a/muse2/muse/widgets/canvas.cpp +++ b/muse2/muse/widgets/canvas.cpp @@ -24,6 +24,7 @@ #include "icons.h" #include "../marker/marker.h" #include "part.h" +#include "fastlog.h" #define ABS(x) ((x) < 0) ? -(x) : (x) @@ -338,7 +339,13 @@ void Canvas::draw(QPainter& p, const QRect& rect) // wheelEvent //--------------------------------------------------------- void Canvas::wheelEvent(QWheelEvent* ev) - { +{ + int keyState = ev->modifiers(); + + bool shift = keyState & Qt::ShiftModifier; + bool ctrl = keyState & Qt::ControlModifier; + + if (shift) { // scroll vertically int delta = ev->delta() / WHEEL_DELTA; int ypixelscale = rmapyDev(1); @@ -347,8 +354,8 @@ void Canvas::wheelEvent(QWheelEvent* ev) int scrollstep = WHEEL_STEPSIZE * (-delta); ///if (ev->state() == Qt::ShiftModifier) - if (((QInputEvent*)ev)->modifiers() == Qt::ShiftModifier) - scrollstep = scrollstep / 10; +// if (((QInputEvent*)ev)->modifiers() == Qt::ShiftModifier) + scrollstep = scrollstep / 2; int newYpos = ypos + ypixelscale * scrollstep; @@ -358,7 +365,36 @@ void Canvas::wheelEvent(QWheelEvent* ev) //setYPos(newYpos); emit verticalScroll((unsigned)newYpos); - } + } else if (ctrl) { // zoom horizontally + if (ev->delta()>0) + emit horizontalZoomIn(); + else + emit horizontalZoomOut(); + + } else { // scroll horizontally + int delta = ev->delta() / WHEEL_DELTA; + int xpixelscale = 5*fast_log10(rmapxDev(1)); + + + if (xpixelscale <= 0) + xpixelscale = 1; + + int scrollstep = WHEEL_STEPSIZE * (delta); + ///if (ev->state() == Qt::ShiftModifier) +// if (((QInputEvent*)ev)->modifiers() == Qt::ShiftModifier) + scrollstep = scrollstep / 10; + + int newXpos = xpos + xpixelscale * scrollstep; + + if (newXpos < 0) + newXpos = 0; + + //setYPos(newYpos); + emit horizontalScroll((unsigned)newXpos); + + } + +} void Canvas::redirectedWheelEvent(QWheelEvent* ev) { diff --git a/muse2/muse/widgets/canvas.h b/muse2/muse/widgets/canvas.h index 97392f1e..6e8b9fa8 100644 --- a/muse2/muse/widgets/canvas.h +++ b/muse2/muse/widgets/canvas.h @@ -174,6 +174,8 @@ class Canvas : public View { void verticalScroll(unsigned); void horizontalScroll(unsigned); void horizontalScrollNoLimit(unsigned); + void horizontalZoomIn(); + void horizontalZoomOut(); public: Canvas(QWidget* parent, int sx, int sy, const char* name = 0); bool isSingleSelection(); -- cgit v1.2.3