From 445a53892a7d00af90b95205c8439d570f4ac492 Mon Sep 17 00:00:00 2001 From: w1z7ard Date: Sun, 16 Aug 2009 22:47:22 +0000 Subject: [PATCH] context menu for preset switching. bug fix selecting presets from projectM. moved preset change related code from key handler to projectm. git-svn-id: https://projectm.svn.sourceforge.net/svnroot/projectm/trunk@1262 6778bc44-b910-0410-a7a0-be141de4315d --- src/libprojectM/KeyHandler.cpp | 77 ----- src/libprojectM/projectM.cpp | 97 +++++- src/libprojectM/projectM.hpp | 2 +- src/projectM-qt/qprojectm_mainwindow.cpp | 24 +- src/projectM-qt/qprojectm_mainwindow.hpp | 4 +- src/projectM-qt/qprojectm_mainwindow.ui | 409 ++++++++++++----------- 6 files changed, 333 insertions(+), 280 deletions(-) diff --git a/src/libprojectM/KeyHandler.cpp b/src/libprojectM/KeyHandler.cpp index 1e8d3aff9..7f664a944 100755 --- a/src/libprojectM/KeyHandler.cpp +++ b/src/libprojectM/KeyHandler.cpp @@ -216,82 +216,5 @@ void projectM::default_key_handler( projectMEvent event, projectMKeycode keycode break; } - - - - } -void projectM::selectRandom(const bool hardCut) { - - if (m_presetChooser->empty()) - return; - - if (!hardCut) { - timeKeeper->StartSmoothing(); - } - - *m_presetPos = m_presetChooser->weightedRandom(); - - if (!hardCut) { - switchPreset(m_activePreset2); - } else { - switchPreset(m_activePreset); - timeKeeper->StartPreset(); - } - - presetSwitchedEvent(hardCut, **m_presetPos); - -} - -void projectM::selectPrevious(const bool hardCut) { - - if (m_presetChooser->empty()) - return; - - if (!hardCut) { - timeKeeper->StartSmoothing(); - } - - m_presetChooser->previousPreset(*m_presetPos); - - if (!hardCut) { - switchPreset(m_activePreset2); - } else { - switchPreset(m_activePreset); - timeKeeper->StartPreset(); - } - - presetSwitchedEvent(hardCut, **m_presetPos); - -// m_activePreset = m_presetPos->allocate(); -// renderer->SetPipeline(m_activePreset->pipeline()); -// renderer->setPresetName(m_activePreset->name()); - - //timeKeeper->StartPreset(); - -} - -void projectM::selectNext(const bool hardCut) { - - if (m_presetChooser->empty()) - return; - - if (!hardCut) { - timeKeeper->StartSmoothing(); - std::cout << "start smoothing" << std::endl; - } - - std::cout << "getting next preset" << std::endl; - m_presetChooser->nextPreset(*m_presetPos); - - if (!hardCut) { - switchPreset(m_activePreset2); - } else { - switchPreset(m_activePreset); - timeKeeper->StartPreset(); - } - presetSwitchedEvent(hardCut, **m_presetPos); - - -} diff --git a/src/libprojectM/projectM.cpp b/src/libprojectM/projectM.cpp index 708158180..9ecea6f22 100755 --- a/src/libprojectM/projectM.cpp +++ b/src/libprojectM/projectM.cpp @@ -658,24 +658,103 @@ static void *thread_callback(void *prjm) { return index; } - void projectM::selectPreset ( unsigned int index ) + void projectM::selectPreset ( unsigned int index, bool hardCut) { - if ( m_presetChooser->empty() ) - return; + if (m_presetChooser->empty()) + return; - assert ( index < m_presetLoader->size()); - assert ( index >= 0 ); + if (!hardCut) { + timeKeeper->StartSmoothing(); + } - *m_presetPos = m_presetChooser->begin ( index ); + *m_presetPos = m_presetChooser->begin(index); - m_activePreset = m_presetPos->allocate (); + if (!hardCut) { + switchPreset(m_activePreset2); + } else { + switchPreset(m_activePreset); + timeKeeper->StartPreset(); + } - renderer->setPresetName ( m_activePreset->name() ); + presetSwitchedEvent(hardCut, **m_presetPos); - timeKeeper->StartPreset(); } + +void projectM::selectRandom(const bool hardCut) { + + if (m_presetChooser->empty()) + return; + + if (!hardCut) { + timeKeeper->StartSmoothing(); + } + + *m_presetPos = m_presetChooser->weightedRandom(); + + if (!hardCut) { + switchPreset(m_activePreset2); + } else { + switchPreset(m_activePreset); + timeKeeper->StartPreset(); + } + + presetSwitchedEvent(hardCut, **m_presetPos); + +} + +void projectM::selectPrevious(const bool hardCut) { + + if (m_presetChooser->empty()) + return; + + if (!hardCut) { + timeKeeper->StartSmoothing(); + } + + m_presetChooser->previousPreset(*m_presetPos); + + if (!hardCut) { + switchPreset(m_activePreset2); + } else { + switchPreset(m_activePreset); + timeKeeper->StartPreset(); + } + + presetSwitchedEvent(hardCut, **m_presetPos); + +// m_activePreset = m_presetPos->allocate(); +// renderer->SetPipeline(m_activePreset->pipeline()); +// renderer->setPresetName(m_activePreset->name()); + + //timeKeeper->StartPreset(); + +} + +void projectM::selectNext(const bool hardCut) { + + if (m_presetChooser->empty()) + return; + + if (!hardCut) { + timeKeeper->StartSmoothing(); + std::cout << "start smoothing" << std::endl; + } + + std::cout << "getting next preset" << std::endl; + m_presetChooser->nextPreset(*m_presetPos); + + if (!hardCut) { + switchPreset(m_activePreset2); + } else { + switchPreset(m_activePreset); + timeKeeper->StartPreset(); + } + presetSwitchedEvent(hardCut, **m_presetPos); + + +} void projectM::switchPreset(std::auto_ptr & targetPreset) { targetPreset = m_presetPos->allocate(); diff --git a/src/libprojectM/projectM.hpp b/src/libprojectM/projectM.hpp index 6151c72b9..d44748a40 100755 --- a/src/libprojectM/projectM.hpp +++ b/src/libprojectM/projectM.hpp @@ -169,7 +169,7 @@ public: void selectPresetPosition(unsigned int index); /// Plays a preset immediately - void selectPreset(unsigned int index); + void selectPreset(unsigned int index, bool hardCut = true); /// Removes a preset from the play list. If it is playing then it will continue as normal until next switch void removePreset(unsigned int index); diff --git a/src/projectM-qt/qprojectm_mainwindow.cpp b/src/projectM-qt/qprojectm_mainwindow.cpp index 4dfa481d2..37caa7af3 100644 --- a/src/projectM-qt/qprojectm_mainwindow.cpp +++ b/src/projectM-qt/qprojectm_mainwindow.cpp @@ -999,8 +999,27 @@ void QProjectM_MainWindow::createActions() connect (ui->actionRemove_selection, SIGNAL(triggered()), this, SLOT(removeSelectedPlaylistItems())); connect (ui->actionInsert_presets, SIGNAL(triggered()), this, SLOT(insertPresetsDialog())); connect (ui->actionEdit_this_preset, SIGNAL(triggered()), this, SLOT(openPresetEditorDialogForSelectedPreset())); + connect (ui->actionHard_cut_to_this_preset, SIGNAL(triggered()), this, SLOT(presetHardCut())); + connect (ui->actionSoft_cut_to_this_preset, SIGNAL(triggered()), this, SLOT(presetSoftCut())); } + +void QProjectM_MainWindow::presetHardCut() { + if (selectedPlaylistIndexes.empty()) + return; + + qprojectM()->selectPreset(selectedPlaylistIndexes[0].row(), true); +} + + +void QProjectM_MainWindow::presetSoftCut() { + if (selectedPlaylistIndexes.empty()) + return; + + qprojectM()->selectPreset(selectedPlaylistIndexes[0].row(), false); +} + + void QProjectM_MainWindow::openPresetEditorDialogForSelectedPreset() { if (selectedPlaylistIndexes.empty()) @@ -1025,7 +1044,10 @@ void QProjectM_MainWindow::createMenus() playlistContextMenu->addAction(ui->actionInsert_presets); playlistContextMenu->addAction(ui->actionRemove_selection); - + + playlistContextMenu->addAction(ui->actionHard_cut_to_this_preset); + playlistContextMenu->addAction(ui->actionSoft_cut_to_this_preset); + ui->menuBar->hide(); diff --git a/src/projectM-qt/qprojectm_mainwindow.hpp b/src/projectM-qt/qprojectm_mainwindow.hpp index b03cd6a15..960a41328 100644 --- a/src/projectM-qt/qprojectm_mainwindow.hpp +++ b/src/projectM-qt/qprojectm_mainwindow.hpp @@ -113,7 +113,8 @@ protected: void closeEvent(QCloseEvent *event); private slots: - +void presetHardCut(); +void presetSoftCut(); void insertPresetsDialog() ; void removeSelectedPlaylistItems(); @@ -144,6 +145,7 @@ private slots: private: + bool warnIfPlaylistModified(); void insertPlaylistItem(const PlaylistItemMetaData & data, int targetIndex); diff --git a/src/projectM-qt/qprojectm_mainwindow.ui b/src/projectM-qt/qprojectm_mainwindow.ui index 65499e511..58b6c4371 100644 --- a/src/projectM-qt/qprojectm_mainwindow.ui +++ b/src/projectM-qt/qprojectm_mainwindow.ui @@ -1,7 +1,8 @@ - + + QProjectM_MainWindow - - + + 0 0 @@ -9,22 +10,23 @@ 568 - + projectM - - :/images/icons/prjm16-transparent.svg + + + :/images/icons/prjm16-transparent.svg:/images/icons/prjm16-transparent.svg - + - - + + Qt::ClickFocus - - + + 0 0 @@ -32,264 +34,267 @@ 26 - - + + &Playlist - - - - - - - + + + + + + + - - + + &Help - - - + + + - - + + &Settings - + - - - + + + - - - - + + + + 0 1 - + 315 - 0 + 110 - + 300 0 - - <html><head><meta name="qrichtext" content="1" /><style type="text/css"> + + <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">This dock panel provides a convenient interface to manage a list of presets for projectM to render. The behavior is very similar to a music player playlist.</p></body></html> +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">This dock panel provides a convenient interface to manage a list of presets for projectM to render. The behavior is very similar to a music player playlist.</p></body></html> - - QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable|QDockWidget::NoDockWidgetFeatures + + QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable - - Preset Playlist + + Preset Playlist - + 1 - - - + + + 1 1 - - - - - + + + + + 0 0 - - <html><head><meta name="qrichtext" content="1" /><style type="text/css"> + + <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Click here to add presets to the current playlist.</p></body></html> +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Click here to add presets to the current playlist.</p></body></html> - + - - :/images/icons/hi16-action-projectm_add_playlist.png + + + :/images/icons/hi16-action-projectm_add_playlist.png:/images/icons/hi16-action-projectm_add_playlist.png - - - - + + + + 0 0 - - <html><head><meta name="qrichtext" content="1" /><style type="text/css"> + + <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Saves the currently loaded play list</p></body></html> +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Saves the currently loaded play list</p></body></html> - + - + - - :/images/icons/hi16-action-projectm_save.png + + + :/images/icons/hi16-action-projectm_save.png:/images/icons/hi16-action-projectm_save.png - - - - + + + + 0 0 - - <html><head><meta name="qrichtext" content="1" /><style type="text/css"> + + <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Clears<span style=" font-style:italic;"> all </span>presets<span style=" font-style:italic;"> </span>in the playlist.</p></body></html> +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Clears<span style=" font-style:italic;"> all </span>presets<span style=" font-style:italic;"> </span>in the playlist.</p></body></html> - + - - :/images/icons/hi16-action-projectm_playlist_clear.png + + + :/images/icons/hi16-action-projectm_playlist_clear.png:/images/icons/hi16-action-projectm_playlist_clear.png - - - - + + + + 20 0 - + Start typing in a filter to crop the play list. - - <html><head><meta name="qrichtext" content="1" /><style type="text/css"> + + <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Use this search bar to crop your preset play list. Only the presets that match your search criteria will be queued.</p></body></html> +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Use this search bar to crop your preset play list. Only the presets that match your search criteria will be queued.</p></body></html> - - - - + + + + 2 4 - + 5 5 - + 200 0 - + Qt::ActionsContextMenu - + true - + Double click on a preset to render it, or drag presets to change the preset order. - + false - + QFrame::StyledPanel - + QFrame::Sunken - + Qt::ScrollBarAlwaysOn - + Qt::ScrollBarAlwaysOff - + true - + false - + QAbstractItemView::DragDrop - + false - + QAbstractItemView::ExtendedSelection - + QAbstractItemView::SelectRows - + false - + Qt::DashDotDotLine - - - + + + true - - + + 0 0 - + PointingHandCursor - - <html><head><meta name="qrichtext" content="1" /><style type="text/css"> + + <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">When the dice is activated, projectM will randomly select presets weighted by your rating preferences.</p></body></html> +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">When the dice is activated, projectM will randomly select presets weighted by your rating preferences.</p></body></html> - + Enable / Disable Shuffle Mode - + - + QCheckBox::indicator:checked { image: url(:/images/icons/hi16-action-projectm_random.png); } @@ -298,44 +303,44 @@ QCheckBox::indicator:unchecked{ image: url(:/images/icons/hi16-action-projectm_random_no.png); } - + - + true - + true - - - + + + true - - + + 1 0 - + PointingHandCursor - - <html><head><meta name="qrichtext" content="1" /><style type="text/css"> + + <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">When the locked icon is shown, projectM will not automatically switch to another preset.</p></body></html> +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">When the locked icon is shown, projectM will not automatically switch to another preset.</p></body></html> - + Lock / Unlock the selected preset - + - + QCheckBox::indicator:checked {image: url(:/images/icons/hi16-action-projectm_lock.png); } @@ -343,13 +348,13 @@ QCheckBox::indicator:unchecked{ image: url(:/images/icons/hi16-action-projectm_unlock.png); } - + - + false - + true @@ -357,89 +362,111 @@ image: url(:/images/icons/hi16-action-projectm_unlock.png); - - - :/images/icons/hi16-action-projectm_add_playlist.png + + + + :/images/icons/hi16-action-projectm_add_playlist.png:/images/icons/hi16-action-projectm_add_playlist.png - + &Add Presets... - - + + About projectM - - + + About Qt - - + + &Quit - - - :/images/icons/hi16-action-projectm_save.png + + + + :/images/icons/hi16-action-projectm_save.png:/images/icons/hi16-action-projectm_save.png - + &Save Playlist - - + + Save Playlist &As... - - + + Configure projectM... - - + + &Open Playlist... - - - :/images/icons/hi16-action-projectm_lock.png + + + + :/images/icons/hi16-action-projectm_lock.png:/images/icons/hi16-action-projectm_lock.png - + Lock Active Preset - - + + Hotkey reference - - - :/images/icons/hi16-action-projectm_edit.png + + + + :/images/icons/hi16-action-projectm_edit.png:/images/icons/hi16-action-projectm_edit.png - + Edit preset - - - :/images/icons/hi16-action-projectm_remove.png + + + + :/images/icons/hi16-action-projectm_remove.png:/images/icons/hi16-action-projectm_remove.png - + Remove selection - - - :/images/icons/hi16-action-projectm_add_playlist.png + + + + :/images/icons/hi16-action-projectm_add_playlist.png:/images/icons/hi16-action-projectm_add_playlist.png - + Insert presets... + + + Hard cut to this preset + + + Switches to this preset immediately. + + + + + Soft cut to this preset + + + Executes a smooth transition to this preset from the current prese.t + + @@ -449,7 +476,7 @@ image: url(:/images/icons/hi16-action-projectm_unlock.png); - + @@ -458,11 +485,11 @@ image: url(:/images/icons/hi16-action-projectm_unlock.png); actionAddPresets trigger() - + 221 66 - + -1 -1 @@ -474,11 +501,11 @@ image: url(:/images/icons/hi16-action-projectm_unlock.png); actionSave_play_list trigger() - + 52 66 - + -1 -1