Mercurial > hg > svapp
changeset 86:dd74c5332b49
* More work on aligning copy/paste between layers. It's a surprisingly
complicated business.
author | Chris Cannam |
---|---|
date | Wed, 06 Feb 2008 12:49:49 +0000 |
parents | 40d0c964ad24 |
children | 1b217963e53a |
files | framework/Document.cpp framework/MainWindowBase.cpp |
diffstat | 2 files changed, 31 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- 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<RangeSummarisableTimeValueModel *>(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,
--- 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