Mercurial > hg > svgui
changeset 333:e74b56f07c73
* Some work on correct alignment when moving panes during playback
* Overhaul alignment for playback frame values (view manager now always
refers to reference-timeline values, only the play source deals in
playback model timeline values)
* When making a selection, ensure the selection regions shown in other
panes (and used for playback constraints if appropriate) are aligned
correctly. This may be the coolest feature ever implemented in any
program ever.
author | Chris Cannam |
---|---|
date | Thu, 22 Nov 2007 14:17:19 +0000 |
parents | d2d2521a6c7e |
children | 0a74248af622 |
files | view/Pane.cpp view/View.cpp view/ViewManager.cpp view/ViewManager.h |
diffstat | 4 files changed, 53 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/view/Pane.cpp Mon Nov 19 15:50:14 2007 +0000 +++ b/view/Pane.cpp Thu Nov 22 14:17:19 2007 +0000 @@ -1276,9 +1276,10 @@ if (snapFrame < 0) snapFrame = 0; m_selectionStartFrame = snapFrame; if (m_manager) { - m_manager->setInProgressSelection(Selection(snapFrame, - snapFrame + resolution), - !m_ctrlPressed); + m_manager->setInProgressSelection + (Selection(alignToReference(snapFrame), + alignToReference(snapFrame + resolution)), + !m_ctrlPressed); } m_resizing = false; @@ -1727,7 +1728,8 @@ } if (m_manager) { - m_manager->setInProgressSelection(Selection(min, max), + m_manager->setInProgressSelection(Selection(alignToReference(min), + alignToReference(max)), !m_resizing && !m_ctrlPressed); }
--- a/view/View.cpp Mon Nov 19 15:50:14 2007 +0000 +++ b/view/View.cpp Thu Nov 22 14:17:19 2007 +0000 @@ -326,8 +326,13 @@ changeVisible = true; } - if (e) emit centreFrameChanged(alignFromReference(f), - m_followPan, m_followPlay); + if (e) { + size_t rf = alignToReference(f); + std::cerr << "View[" << this << "]::setCentreFrame(" << f + << "): emitting centreFrameChanged(" + << rf << ")" << std::endl; + emit centreFrameChanged(rf, m_followPan, m_followPlay); + } } return changeVisible; @@ -869,10 +874,13 @@ } void -View::globalCentreFrameChanged(unsigned long f) +View::globalCentreFrameChanged(unsigned long rf) { if (m_followPan) { - setCentreFrame(alignToReference(f), false); + size_t f = alignFromReference(rf); + std::cerr << "View[" << this << "]::globalCentreFrameChanged(" << rf + << "): setting centre frame to " << f << std::endl; + setCentreFrame(f, false); } } @@ -1150,17 +1158,17 @@ Model *aligningModel = getAligningModel(); if (!aligningModel) return pf; - +/* Model *pm = m_manager->getPlaybackModel(); // std::cerr << "View[" << this << "]::getAlignedPlaybackFrame: pf = " << pf; if (pm) { - pf = pm->alignFromReference(pf); + pf = pm->alignToReference(pf); // std::cerr << " -> " << pf; } - - int af = aligningModel->alignToReference(pf); +*/ + int af = aligningModel->alignFromReference(pf); // std::cerr << ", aligned = " << af << std::endl; return af; @@ -1714,8 +1722,8 @@ for (MultiSelection::SelectionList::iterator i = selections.begin(); i != selections.end(); ++i) { - int p0 = getXForFrame(i->getStartFrame()); - int p1 = getXForFrame(i->getEndFrame()); + int p0 = getXForFrame(alignFromReference(i->getStartFrame())); + int p1 = getXForFrame(alignFromReference(i->getEndFrame())); if (p1 < 0 || p0 > width()) continue;
--- a/view/ViewManager.cpp Mon Nov 19 15:50:14 2007 +0000 +++ b/view/ViewManager.cpp Thu Nov 22 14:17:19 2007 +0000 @@ -173,6 +173,20 @@ m_playbackModel = model; } +size_t +ViewManager::alignPlaybackFrameToReference(size_t frame) const +{ + if (!m_playbackModel) return frame; + else return m_playbackModel->alignToReference(frame); +} + +size_t +ViewManager::alignReferenceToPlaybackFrame(size_t frame) const +{ + if (!m_playbackModel) return frame; + else return m_playbackModel->alignFromReference(frame); +} + bool ViewManager::haveInProgressSelection() const {
--- a/view/ViewManager.h Mon Nov 19 15:50:14 2007 +0000 +++ b/view/ViewManager.h Thu Nov 22 14:17:19 2007 +0000 @@ -66,9 +66,24 @@ void setPlaybackFrame(unsigned long frame); // Only meaningful in solo mode, and used for optional alignment feature + + //!!! We probably don't want to do this. It's probably better to + // always have playback frame aligned against the reference model, + // and have the ViewManager know which is the reference model. + // That way the ViewManager can assume that all Views report in + // reference model timeline, and it can convert the playback frame + // received from the play source (which always operates in literal + // audio sample frames, i.e. playback model timeline) to the + // reference timeline itself so the view never has to worry about + // the difference between playback and reference model. Of course + // that does mean the ViewManager needs to know about both. + Model *getPlaybackModel() const; void setPlaybackModel(Model *); + size_t alignPlaybackFrameToReference(size_t) const; + size_t alignReferenceToPlaybackFrame(size_t) const; + bool haveInProgressSelection() const; const Selection &getInProgressSelection(bool &exclusive) const; void setInProgressSelection(const Selection &selection, bool exclusive);