diff options
author | Tim E. Real <termtech@rogers.com> | 2012-09-08 05:15:07 +0000 |
---|---|---|
committer | Tim E. Real <termtech@rogers.com> | 2012-09-08 05:15:07 +0000 |
commit | 7ad820d6fa0846f4f4016ada795fdef286649d59 (patch) | |
tree | 84d2e0ac08edfd0ef8a4f0faa3be31cd3383101f /muse2 | |
parent | 5ec465d05bca8998d9e772714edaa4511431f5dd (diff) |
Wave Editor: Added Edit -> Adjust Wave Offset. Helps compensate for latency.
FIXME: Respect clones! If operating on two selected clones of the same part,
an extra event is created. May or may not be this code's problem?...
Diffstat (limited to 'muse2')
-rw-r--r-- | muse2/ChangeLog | 4 | ||||
-rw-r--r-- | muse2/muse/waveedit/wavecanvas.cpp | 68 | ||||
-rw-r--r-- | muse2/muse/waveedit/wavecanvas.h | 8 | ||||
-rw-r--r-- | muse2/muse/waveedit/waveedit.cpp | 6 | ||||
-rw-r--r-- | muse2/muse/waveedit/waveedit.h | 1 |
5 files changed, 82 insertions, 5 deletions
diff --git a/muse2/ChangeLog b/muse2/ChangeLog index cf6de60c..c82420b5 100644 --- a/muse2/ChangeLog +++ b/muse2/ChangeLog @@ -1,3 +1,7 @@ +08.09.2012: + - Follow up to Improved Wave Editor: Added Edit -> Adjust Wave Offset. Helps compensate for latency. (Tim) + FIXME: Respect clones! If operating on two selected clones of the same part, an extra event is created. + May not be this code's problem but seems like it, other operations like moving an event seem OK. 07.09.2012: - Bug 3555569, 3555572: New informative ERROR, WARNING and HINT messages in cmake build script. (Tim) Also, detect and report missing Doxygen executable. diff --git a/muse2/muse/waveedit/wavecanvas.cpp b/muse2/muse/waveedit/wavecanvas.cpp index 220c2804..2139b647 100644 --- a/muse2/muse/waveedit/wavecanvas.cpp +++ b/muse2/muse/waveedit/wavecanvas.cpp @@ -33,6 +33,7 @@ #include <QDragEnterEvent> #include <QDragMoveEvent> #include <QDropEvent> +#include <QInputDialog> #include <QMouseEvent> #include <QList> #include <QPair> @@ -1505,6 +1506,68 @@ bool WaveCanvas::deleteItem(MusEGui::CItem* item) } //--------------------------------------------------------- +// adjustWaveOffset +//--------------------------------------------------------- + +void WaveCanvas::adjustWaveOffset() +{ + bool have_selected = false; + int init_offset = 0; + + for (MusEGui::iCItem k = items.begin(); k != items.end(); ++k) + { + if (k->second->isSelected()) + { + have_selected = true; + init_offset = k->second->event().spos(); + break; + } + } + + if(!have_selected) + { + QMessageBox::information(this, + QString("MusE"), + QWidget::tr("No wave events selected.")); + return; + } + + bool ok = false; + int offset = QInputDialog::getInt(this, + tr("Adjust Wave Offset"), + tr("Wave offset (frames)"), + init_offset, + 0, 2147483647, 1, + &ok); + if(!ok) + return; + + MusECore::Undo operations; + + // FIXME: Respect clones! If operating on two selected clones of the same part, an extra event is created! + // Check - Is it really this code's problem? Seems so, other operations like moving an event seem OK. + for(MusEGui::iCItem ici = items.begin(); ici != items.end(); ++ici) + { + if(ici->second->isSelected()) + { + MusECore::Event oldEvent = ici->second->event(); + if(oldEvent.spos() != offset) + { + MusECore::Part* part = ici->second->part(); + MusECore::Event newEvent = oldEvent.clone(); + newEvent.setSpos(offset); + // Do not do port controller values and clone parts. + operations.push_back(MusECore::UndoOp(MusECore::UndoOp::ModifyEvent, newEvent, oldEvent, part, false, false)); + } + } + } + + MusEGlobal::song->applyOperationGroup(operations); + + redraw(); +} + +//--------------------------------------------------------- // draw //--------------------------------------------------------- @@ -1722,7 +1785,10 @@ void WaveCanvas::cmd(int cmd) } break; - + case CMD_ADJUST_WAVE_OFFSET: + adjustWaveOffset(); + break; + case CMD_EDIT_EXTERNAL: modifyoperation = EDIT_EXTERNAL; break; diff --git a/muse2/muse/waveedit/wavecanvas.h b/muse2/muse/waveedit/wavecanvas.h index df285abc..4a6ae9f9 100644 --- a/muse2/muse/waveedit/wavecanvas.h +++ b/muse2/muse/waveedit/wavecanvas.h @@ -105,8 +105,6 @@ class WaveCanvas : public EventCanvas { void drawTickRaster(QPainter& p, int x, int y, int w, int h, int raster); void drawParts(QPainter&, const QRect&, bool do_cur_part); - // REMOVE Tim. - //virtual void pdraw(QPainter&, const QRect&); virtual void draw(QPainter&, const QRect&); virtual void viewMouseDoubleClickEvent(QMouseEvent*); virtual void wheelEvent(QWheelEvent*); @@ -136,7 +134,8 @@ class WaveCanvas : public EventCanvas { virtual void itemMoved(const CItem*, const QPoint&); virtual void curPartChanged(); virtual void resizeEvent(QResizeEvent*); - + void adjustWaveOffset(); + private slots: void setPos(int idx, unsigned val, bool adjustScrollbar); @@ -159,7 +158,8 @@ class WaveCanvas : public EventCanvas { CMD_QUANTIZE, CMD_SELECT_ALL, CMD_SELECT_NONE, CMD_SELECT_INVERT, CMD_SELECT_ILOOP, CMD_SELECT_OLOOP, CMD_SELECT_PREV_PART, CMD_SELECT_NEXT_PART, - CMD_ERASE_MEASURE, CMD_DELETE_MEASURE, CMD_CREATE_MEASURE + CMD_ERASE_MEASURE, CMD_DELETE_MEASURE, CMD_CREATE_MEASURE, + CMD_ADJUST_WAVE_OFFSET }; WaveCanvas(MidiEditor*, QWidget*, int, int); diff --git a/muse2/muse/waveedit/waveedit.cpp b/muse2/muse/waveedit/waveedit.cpp index 8290128f..56185a83 100644 --- a/muse2/muse/waveedit/waveedit.cpp +++ b/muse2/muse/waveedit/waveedit.cpp @@ -152,6 +152,12 @@ WaveEdit::WaveEdit(MusECore::PartList* pl) mapper->setMapping(act, WaveCanvas::CMD_EDIT_EXTERNAL); connect(act, SIGNAL(triggered()), mapper, SLOT(map())); + menuEdit->addSeparator(); + + adjustWaveOffsetAction = menuEdit->addAction(tr("Adjust wave offset...")); + mapper->setMapping(adjustWaveOffsetAction, WaveCanvas::CMD_ADJUST_WAVE_OFFSET); + connect(adjustWaveOffsetAction, SIGNAL(triggered()), mapper, SLOT(map())); + act = menuFunctions->addAction(tr("Mute Selection")); mapper->setMapping(act, WaveCanvas::CMD_MUTE); connect(act, SIGNAL(triggered()), mapper, SLOT(map())); diff --git a/muse2/muse/waveedit/waveedit.h b/muse2/muse/waveedit/waveedit.h index 2d74391a..7165a63a 100644 --- a/muse2/muse/waveedit/waveedit.h +++ b/muse2/muse/waveedit/waveedit.h @@ -71,6 +71,7 @@ class WaveEdit : public MidiEditor { QAction* pasteAction; QAction* selectPrevPartAction; QAction* selectNextPartAction; + QAction* adjustWaveOffsetAction; QAction* evColorNormalAction; QAction* evColorPartsAction; |