# HG changeset patch # User Chris Cannam # Date 1202302189 0 # Node ID dd74c5332b49317386e5150ffb162b53cc62e7a0 # Parent 40d0c964ad24faae34b1d4781821eb95c2a34ca7 * More work on aligning copy/paste between layers. It's a surprisingly complicated business. diff -r 40d0c964ad24 -r dd74c5332b49 framework/Document.cpp --- a/framework/Document.cpp Tue Feb 05 13:46:45 2008 +0000 +++ b/framework/Document.cpp Wed Feb 06 12:49:49 2008 +0000 @@ -370,8 +370,14 @@ } for (ModelMap::iterator i = m_models.begin(); i != m_models.end(); ++i) { - if (oldMainModel && - (i->first->getAlignmentReference() == oldMainModel)) { + + if (m_autoAlignment) { + + alignModel(i->first); + + } else if (oldMainModel && + (i->first->getAlignmentReference() == oldMainModel)) { + alignModel(i->first); } } @@ -381,6 +387,10 @@ emit modelAboutToBeDeleted(oldMainModel); } + if (m_autoAlignment) { + alignModel(m_mainModel); + } + emit mainModelChanged(m_mainModel); delete oldMainModel; @@ -760,14 +770,27 @@ void Document::alignModel(Model *model) { - if (!m_mainModel || model == m_mainModel) return; + if (!m_mainModel) return; RangeSummarisableTimeValueModel *rm = dynamic_cast(model); if (!rm) return; - if (rm->getAlignmentReference() == m_mainModel) return; + if (rm->getAlignmentReference() == m_mainModel) { + std::cerr << "Document::alignModel: model " << rm << " is already aligned to main model " << m_mainModel << std::endl; + return; + } + if (model == m_mainModel) { + // The reference has an empty alignment to itself. This makes + // it possible to distinguish between the reference and any + // unaligned model just by looking at the model itself, + // without also knowing what the main model is + std::cerr << "Document::alignModel(" << model << "): is main model, setting appropriately" << std::endl; + rm->setAlignment(new AlignmentModel(model, model, 0, 0)); + return; + } + // This involves creating three new models: // 1. an AggregateWaveModel to provide the mixdowns of the main @@ -845,6 +868,7 @@ for (ModelMap::iterator i = m_models.begin(); i != m_models.end(); ++i) { alignModel(i->first); } + alignModel(m_mainModel); } Document::AddLayerCommand::AddLayerCommand(Document *d, diff -r 40d0c964ad24 -r dd74c5332b49 framework/MainWindowBase.cpp --- a/framework/MainWindowBase.cpp Tue Feb 05 13:46:45 2008 +0000 +++ b/framework/MainWindowBase.cpp Wed Feb 06 12:49:49 2008 +0000 @@ -572,7 +572,7 @@ for (MultiSelection::SelectionList::iterator i = selections.begin(); i != selections.end(); ++i) { - layer->copy(*i, clipboard); + layer->copy(currentPane, *i, clipboard); layer->deleteSelection(*i); } @@ -595,7 +595,7 @@ for (MultiSelection::SelectionList::iterator i = selections.begin(); i != selections.end(); ++i) { - layer->copy(*i, clipboard); + layer->copy(currentPane, *i, clipboard); } } @@ -628,7 +628,7 @@ layer->paste(clipboard, frameOffset); */ - layer->paste(clipboard, 0, true); + layer->paste(currentPane, clipboard, 0, true); } void