# HG changeset patch # User Chris Cannam # Date 1147347346 0 # Node ID 453f7da3534e53b162962b98541fa60ae8e9fa4f # Parent 2be85befe873eefc085c605c876085b5c713fd4e * Fix serious failure to reload "imported" (i.e. all non-derived non-main) models from .sv file * Give a short playback duration to notes with formal duration of 0 or 1 * Show crosshairs on spectrogram even when there is another layer on top (if it isn't opaque) * Always paste to the same time in the layer as the cut/copy was from, rather than to the playback pointer -- less flexible, but more predictable and less annoying. We probably need a way to get the old behaviour if pasting from somewhere else in the future (e.g. from a text file), but we can't do that yet anyway * Use a compound operation for dragging and resizing selections, so as to ensure a single undo operation works * Use a note model as the target for feature extraction plugins that output variable samplerate data with more than one value per feature * Avoid possible crashes in cut/paste if a layer proves to have no model diff -r 2be85befe873 -r 453f7da3534e layer/NoteLayer.cpp --- a/layer/NoteLayer.cpp Wed May 10 16:34:03 2006 +0000 +++ b/layer/NoteLayer.cpp Thu May 11 11:35:46 2006 +0000 @@ -688,6 +688,8 @@ void NoteLayer::moveSelection(Selection s, size_t newStartFrame) { + if (!m_model) return; + NoteModel::EditCommand *command = new NoteModel::EditCommand(m_model, tr("Drag Selection")); @@ -711,6 +713,8 @@ void NoteLayer::resizeSelection(Selection s, Selection newSize) { + if (!m_model) return; + NoteModel::EditCommand *command = new NoteModel::EditCommand(m_model, tr("Resize Selection")); @@ -748,6 +752,8 @@ void NoteLayer::deleteSelection(Selection s) { + if (!m_model) return; + NoteModel::EditCommand *command = new NoteModel::EditCommand(m_model, tr("Delete Selected Points")); @@ -768,6 +774,8 @@ void NoteLayer::copy(Selection s, Clipboard &to) { + if (!m_model) return; + NoteModel::PointList points = m_model->getPoints(s.getStartFrame(), s.getEndFrame()); @@ -783,6 +791,8 @@ void NoteLayer::paste(const Clipboard &from, int frameOffset) { + if (!m_model) return; + const Clipboard::PointList &points = from.getPoints(); NoteModel::EditCommand *command = diff -r 2be85befe873 -r 453f7da3534e layer/TextLayer.cpp --- a/layer/TextLayer.cpp Wed May 10 16:34:03 2006 +0000 +++ b/layer/TextLayer.cpp Thu May 11 11:35:46 2006 +0000 @@ -605,13 +605,15 @@ if (ok && label != points.begin()->label) { TextModel::RelabelCommand *command = new TextModel::RelabelCommand(m_model, *points.begin(), label); - CommandHistory::getInstance()->addCommand(command, true); + CommandHistory::getInstance()->addCommand(command); } } void TextLayer::moveSelection(Selection s, size_t newStartFrame) { + if (!m_model) return; + TextModel::EditCommand *command = new TextModel::EditCommand(m_model, tr("Drag Selection")); @@ -635,6 +637,8 @@ void TextLayer::resizeSelection(Selection s, Selection newSize) { + if (!m_model) return; + TextModel::EditCommand *command = new TextModel::EditCommand(m_model, tr("Resize Selection")); @@ -667,6 +671,8 @@ void TextLayer::deleteSelection(Selection s) { + if (!m_model) return; + TextModel::EditCommand *command = new TextModel::EditCommand(m_model, tr("Delete Selection")); @@ -684,6 +690,8 @@ void TextLayer::copy(Selection s, Clipboard &to) { + if (!m_model) return; + TextModel::PointList points = m_model->getPoints(s.getStartFrame(), s.getEndFrame()); @@ -699,6 +707,8 @@ void TextLayer::paste(const Clipboard &from, int frameOffset) { + if (!m_model) return; + const Clipboard::PointList &points = from.getPoints(); TextModel::EditCommand *command = diff -r 2be85befe873 -r 453f7da3534e layer/TimeInstantLayer.cpp --- a/layer/TimeInstantLayer.cpp Wed May 10 16:34:03 2006 +0000 +++ b/layer/TimeInstantLayer.cpp Thu May 11 11:35:46 2006 +0000 @@ -626,6 +626,8 @@ void TimeInstantLayer::moveSelection(Selection s, size_t newStartFrame) { + if (!m_model) return; + SparseOneDimensionalModel::EditCommand *command = new SparseOneDimensionalModel::EditCommand(m_model, tr("Drag Selection")); @@ -650,6 +652,8 @@ void TimeInstantLayer::resizeSelection(Selection s, Selection newSize) { + if (!m_model) return; + SparseOneDimensionalModel::EditCommand *command = new SparseOneDimensionalModel::EditCommand(m_model, tr("Resize Selection")); @@ -683,6 +687,8 @@ void TimeInstantLayer::deleteSelection(Selection s) { + if (!m_model) return; + SparseOneDimensionalModel::EditCommand *command = new SparseOneDimensionalModel::EditCommand(m_model, tr("Delete Selection")); @@ -701,6 +707,8 @@ void TimeInstantLayer::copy(Selection s, Clipboard &to) { + if (!m_model) return; + SparseOneDimensionalModel::PointList points = m_model->getPoints(s.getStartFrame(), s.getEndFrame()); @@ -716,6 +724,8 @@ void TimeInstantLayer::paste(const Clipboard &from, int frameOffset) { + if (!m_model) return; + const Clipboard::PointList &points = from.getPoints(); SparseOneDimensionalModel::EditCommand *command = diff -r 2be85befe873 -r 453f7da3534e layer/TimeValueLayer.cpp --- a/layer/TimeValueLayer.cpp Wed May 10 16:34:03 2006 +0000 +++ b/layer/TimeValueLayer.cpp Thu May 11 11:35:46 2006 +0000 @@ -992,6 +992,8 @@ void TimeValueLayer::moveSelection(Selection s, size_t newStartFrame) { + if (!m_model) return; + SparseTimeValueModel::EditCommand *command = new SparseTimeValueModel::EditCommand(m_model, tr("Drag Selection")); @@ -1016,6 +1018,8 @@ void TimeValueLayer::resizeSelection(Selection s, Selection newSize) { + if (!m_model) return; + SparseTimeValueModel::EditCommand *command = new SparseTimeValueModel::EditCommand(m_model, tr("Resize Selection")); @@ -1049,6 +1053,8 @@ void TimeValueLayer::deleteSelection(Selection s) { + if (!m_model) return; + SparseTimeValueModel::EditCommand *command = new SparseTimeValueModel::EditCommand(m_model, tr("Delete Selected Points")); @@ -1070,6 +1076,8 @@ void TimeValueLayer::copy(Selection s, Clipboard &to) { + if (!m_model) return; + SparseTimeValueModel::PointList points = m_model->getPoints(s.getStartFrame(), s.getEndFrame()); @@ -1085,6 +1093,8 @@ void TimeValueLayer::paste(const Clipboard &from, int frameOffset) { + if (!m_model) return; + const Clipboard::PointList &points = from.getPoints(); SparseTimeValueModel::EditCommand *command = diff -r 2be85befe873 -r 453f7da3534e widgets/Pane.cpp --- a/widgets/Pane.cpp Wed May 10 16:34:03 2006 +0000 +++ b/widgets/Pane.cpp Thu May 11 11:35:46 2006 +0000 @@ -20,6 +20,7 @@ #include "base/RealTime.h" #include "base/Profiler.h" #include "base/ViewManager.h" +#include "base/CommandHistory.h" #include "layer/WaveformLayer.h" #include @@ -144,24 +145,31 @@ int fontHeight = paint.fontMetrics().height(); int fontAscent = paint.fontMetrics().ascent(); - for (LayerList::iterator vi = m_layers.end(); vi != m_layers.begin(); ) { - --vi; - - if (dynamic_cast(*vi)) { - waveformModel = (*vi)->getModel(); - } + if (m_manager && + !m_manager->isPlaying() && + m_manager->getToolMode() == ViewManager::SelectMode) { - if (m_manager && - !m_manager->isPlaying() && - m_manager->getToolMode() == ViewManager::SelectMode) { + for (LayerList::iterator vi = m_layers.end(); vi != m_layers.begin(); ) { + --vi; std::vector crosshairExtents; if ((*vi)->getCrosshairExtents(this, paint, m_identifyPoint, crosshairExtents)) { (*vi)->paintCrosshairs(this, paint, m_identifyPoint); + break; + } else if ((*vi)->isLayerOpaque()) { + break; } } + } + + for (LayerList::iterator vi = m_layers.end(); vi != m_layers.begin(); ) { + --vi; + + if (dynamic_cast(*vi)) { + waveformModel = (*vi)->getModel(); + } if (!m_manager || m_manager->getOverlayMode() == ViewManager::NoOverlays) { @@ -972,10 +980,16 @@ if (m_editingSelectionEdge == 0) { + CommandHistory::getInstance()->startCompoundOperation + (tr("Drag Selection"), true); + layer->moveSelection(m_editingSelection, f0); } else { + CommandHistory::getInstance()->startCompoundOperation + (tr("Resize Selection"), true); + if (m_editingSelectionEdge < 0) { f1 = m_editingSelection.getEndFrame(); } else { @@ -989,6 +1003,8 @@ m_manager->removeSelection(m_editingSelection); m_manager->addSelection(newSelection); + CommandHistory::getInstance()->endCompoundOperation(); + m_editingSelection = Selection(); return true; }