Mercurial > hg > svcore
diff base/ViewManager.cpp @ 9:73d85d19919f
* Add play-selection and looping modes. Looping seems to work OK, but
the plain play-selection is miscalculating current frame number to
feed back to the GUI.
* Cache selection rectanges wherever possible in View::paintEvent.
author | Chris Cannam |
---|---|
date | Tue, 24 Jan 2006 16:20:58 +0000 |
parents | 214054a0d8b8 |
children | ec6886f0e673 |
line wrap: on
line diff
--- a/base/ViewManager.cpp Mon Jan 23 17:02:57 2006 +0000 +++ b/base/ViewManager.cpp Tue Jan 24 16:20:58 2006 +0000 @@ -23,7 +23,9 @@ m_lastLeft(0), m_lastRight(0), m_inProgressExclusive(true), - m_toolMode(NavigateMode) + m_toolMode(NavigateMode), + m_playLoopMode(false), + m_playSelectionMode(true) { connect(this, SIGNAL(centreFrameChanged(void *, unsigned long, bool)), @@ -71,14 +73,14 @@ m_inProgressExclusive = exclusive; m_inProgressSelection = selection; if (exclusive) clearSelections(); - emit selectionChanged(); + emit inProgressSelectionChanged(); } void ViewManager::clearInProgressSelection() { m_inProgressSelection = Selection(); - emit selectionChanged(); + emit inProgressSelectionChanged(); } const ViewManager::SelectionList & @@ -103,7 +105,11 @@ // more existing ones. This is a terribly inefficient way to do // this, but that probably isn't significant in real life. - for (SelectionList::iterator i = m_selections.begin(); + // It's essential for the correct operation of + // getContainingSelection that the selections do not overlap, so + // this is not just a frill. + + for (SelectionList::iterator i = m_selections.begin(); i != m_selections.end(); ) { SelectionList::iterator j = i; @@ -145,6 +151,27 @@ emit selectionChanged(); } +Selection +ViewManager::getContainingSelection(size_t frame, bool defaultToFollowing) +{ + // This scales very badly with the number of selections, but it's + // more efficient for very small numbers of selections than a more + // scalable method, and I think that may be what we need + + for (SelectionList::const_iterator i = m_selections.begin(); + i != m_selections.end(); ++i) { + + if (i->contains(frame)) return *i; + + if (i->getStartFrame() > frame) { + if (defaultToFollowing) return *i; + else return Selection(); + } + } + + return Selection(); +} + void ViewManager::setToolMode(ToolMode mode) { @@ -154,6 +181,22 @@ } void +ViewManager::setPlayLoopMode(bool mode) +{ + m_playLoopMode = mode; + + emit playLoopModeChanged(); +} + +void +ViewManager::setPlaySelectionMode(bool mode) +{ + m_playSelectionMode = mode; + + emit playSelectionModeChanged(); +} + +void ViewManager::setAudioPlaySource(AudioPlaySource *source) { if (!m_playSource) {