Mercurial > hg > svgui
comparison view/ViewManager.cpp @ 944:78c152e4db95
Merge from branch tonioni
author | Chris Cannam |
---|---|
date | Mon, 20 Apr 2015 09:12:17 +0100 |
parents | b48db6f1a7d2 |
children | 36cddc3de023 4d54882bbf73 |
comparison
equal
deleted
inserted
replaced
896:78e041e45ff0 | 944:78c152e4db95 |
---|---|
124 | 124 |
125 ViewManager::~ViewManager() | 125 ViewManager::~ViewManager() |
126 { | 126 { |
127 } | 127 } |
128 | 128 |
129 int | 129 sv_frame_t |
130 ViewManager::getGlobalCentreFrame() const | 130 ViewManager::getGlobalCentreFrame() const |
131 { | 131 { |
132 #ifdef DEBUG_VIEW_MANAGER | 132 #ifdef DEBUG_VIEW_MANAGER |
133 cerr << "ViewManager::getGlobalCentreFrame: returning " << m_globalCentreFrame << endl; | 133 cerr << "ViewManager::getGlobalCentreFrame: returning " << m_globalCentreFrame << endl; |
134 #endif | 134 #endif |
135 return m_globalCentreFrame; | 135 return m_globalCentreFrame; |
136 } | 136 } |
137 | 137 |
138 void | 138 void |
139 ViewManager::setGlobalCentreFrame(int f) | 139 ViewManager::setGlobalCentreFrame(sv_frame_t f) |
140 { | 140 { |
141 #ifdef DEBUG_VIEW_MANAGER | 141 #ifdef DEBUG_VIEW_MANAGER |
142 cerr << "ViewManager::setGlobalCentreFrame to " << f << endl; | 142 cerr << "ViewManager::setGlobalCentreFrame to " << f << endl; |
143 #endif | 143 #endif |
144 m_globalCentreFrame = f; | 144 m_globalCentreFrame = f; |
152 cerr << "ViewManager::getGlobalZoom: returning " << m_globalZoom << endl; | 152 cerr << "ViewManager::getGlobalZoom: returning " << m_globalZoom << endl; |
153 #endif | 153 #endif |
154 return m_globalZoom; | 154 return m_globalZoom; |
155 } | 155 } |
156 | 156 |
157 int | 157 sv_frame_t |
158 ViewManager::getPlaybackFrame() const | 158 ViewManager::getPlaybackFrame() const |
159 { | 159 { |
160 if (m_playSource && m_playSource->isPlaying()) { | 160 if (m_playSource && m_playSource->isPlaying()) { |
161 m_playbackFrame = m_playSource->getCurrentPlayingFrame(); | 161 m_playbackFrame = m_playSource->getCurrentPlayingFrame(); |
162 } | 162 } |
163 return m_playbackFrame; | 163 return m_playbackFrame; |
164 } | 164 } |
165 | 165 |
166 void | 166 void |
167 ViewManager::setPlaybackFrame(int f) | 167 ViewManager::setPlaybackFrame(sv_frame_t f) |
168 { | 168 { |
169 if (m_playbackFrame != f) { | 169 if (m_playbackFrame != f) { |
170 m_playbackFrame = f; | 170 m_playbackFrame = f; |
171 emit playbackFrameChanged(f); | 171 emit playbackFrameChanged(f); |
172 if (m_playSource && m_playSource->isPlaying()) { | 172 if (m_playSource && m_playSource->isPlaying()) { |
185 ViewManager::setPlaybackModel(Model *model) | 185 ViewManager::setPlaybackModel(Model *model) |
186 { | 186 { |
187 m_playbackModel = model; | 187 m_playbackModel = model; |
188 } | 188 } |
189 | 189 |
190 int | 190 sv_frame_t |
191 ViewManager::alignPlaybackFrameToReference(int frame) const | 191 ViewManager::alignPlaybackFrameToReference(sv_frame_t frame) const |
192 { | 192 { |
193 #ifdef DEBUG_VIEW_MANAGER | 193 #ifdef DEBUG_VIEW_MANAGER |
194 cerr << "ViewManager::alignPlaybackFrameToReference(" << frame << "): playback model is " << m_playbackModel << endl; | 194 cerr << "ViewManager::alignPlaybackFrameToReference(" << frame << "): playback model is " << m_playbackModel << endl; |
195 #endif | 195 #endif |
196 if (!m_playbackModel) { | 196 if (!m_playbackModel) { |
197 return frame; | 197 return frame; |
198 } else { | 198 } else { |
199 int f = m_playbackModel->alignToReference(frame); | 199 sv_frame_t f = m_playbackModel->alignToReference(frame); |
200 #ifdef DEBUG_VIEW_MANAGER | 200 #ifdef DEBUG_VIEW_MANAGER |
201 cerr << "aligned frame = " << f << endl; | 201 cerr << "aligned frame = " << f << endl; |
202 #endif | 202 #endif |
203 return f; | 203 return f; |
204 } | 204 } |
205 } | 205 } |
206 | 206 |
207 int | 207 sv_frame_t |
208 ViewManager::alignReferenceToPlaybackFrame(int frame) const | 208 ViewManager::alignReferenceToPlaybackFrame(sv_frame_t frame) const |
209 { | 209 { |
210 #ifdef DEBUG_VIEW_MANAGER | 210 #ifdef DEBUG_VIEW_MANAGER |
211 cerr << "ViewManager::alignReferenceToPlaybackFrame(" << frame << "): playback model is " << m_playbackModel << endl; | 211 cerr << "ViewManager::alignReferenceToPlaybackFrame(" << frame << "): playback model is " << m_playbackModel << endl; |
212 #endif | 212 #endif |
213 if (!m_playbackModel) { | 213 if (!m_playbackModel) { |
214 return frame; | 214 return frame; |
215 } else { | 215 } else { |
216 int f = m_playbackModel->alignFromReference(frame); | 216 sv_frame_t f = m_playbackModel->alignFromReference(frame); |
217 #ifdef DEBUG_VIEW_MANAGER | 217 #ifdef DEBUG_VIEW_MANAGER |
218 cerr << "aligned frame = " << f << endl; | 218 cerr << "aligned frame = " << f << endl; |
219 #endif | 219 #endif |
220 return f; | 220 return f; |
221 } | 221 } |
311 if (!quietly) { | 311 if (!quietly) { |
312 emit selectionChangedByUser(); | 312 emit selectionChangedByUser(); |
313 } | 313 } |
314 } | 314 } |
315 | 315 |
316 int | 316 sv_frame_t |
317 ViewManager::constrainFrameToSelection(int frame) const | 317 ViewManager::constrainFrameToSelection(sv_frame_t frame) const |
318 { | 318 { |
319 MultiSelection::SelectionList sl = getSelections(); | 319 MultiSelection::SelectionList sl = getSelections(); |
320 if (sl.empty()) return frame; | 320 if (sl.empty()) return frame; |
321 | 321 |
322 for (MultiSelection::SelectionList::const_iterator i = sl.begin(); | 322 for (MultiSelection::SelectionList::const_iterator i = sl.begin(); |
371 if (m_newSelection.getSelections().size() > 1) return tr("Select Multiple Regions"); | 371 if (m_newSelection.getSelections().size() > 1) return tr("Select Multiple Regions"); |
372 else return tr("Select Region"); | 372 else return tr("Select Region"); |
373 } | 373 } |
374 | 374 |
375 Selection | 375 Selection |
376 ViewManager::getContainingSelection(int frame, bool defaultToFollowing) const | 376 ViewManager::getContainingSelection(sv_frame_t frame, bool defaultToFollowing) const |
377 { | 377 { |
378 return m_selections.getContainingSelection(frame, defaultToFollowing); | 378 return m_selections.getContainingSelection(frame, defaultToFollowing); |
379 } | 379 } |
380 | 380 |
381 void | 381 void |
476 if (mode) emit activity(tr("Switch on Alignment mode")); | 476 if (mode) emit activity(tr("Switch on Alignment mode")); |
477 else emit activity(tr("Switch off Alignment mode")); | 477 else emit activity(tr("Switch off Alignment mode")); |
478 } | 478 } |
479 } | 479 } |
480 | 480 |
481 int | 481 sv_samplerate_t |
482 ViewManager::getPlaybackSampleRate() const | 482 ViewManager::getPlaybackSampleRate() const |
483 { | 483 { |
484 if (m_playSource) { | 484 if (m_playSource) { |
485 return m_playSource->getSourceSampleRate(); | 485 return m_playSource->getSourceSampleRate(); |
486 } | 486 } |
487 return 0; | 487 return 0; |
488 } | 488 } |
489 | 489 |
490 int | 490 sv_samplerate_t |
491 ViewManager::getOutputSampleRate() const | 491 ViewManager::getOutputSampleRate() const |
492 { | 492 { |
493 if (m_playSource) { | 493 if (m_playSource) { |
494 return m_playSource->getTargetSampleRate(); | 494 return m_playSource->getTargetSampleRate(); |
495 } | 495 } |
557 { | 557 { |
558 return m_playSource && m_playSource->isPlaying(); | 558 return m_playSource && m_playSource->isPlaying(); |
559 } | 559 } |
560 | 560 |
561 void | 561 void |
562 ViewManager::viewCentreFrameChanged(int f, bool locked, | 562 ViewManager::viewCentreFrameChanged(sv_frame_t f, bool locked, |
563 PlaybackFollowMode mode) | 563 PlaybackFollowMode mode) |
564 { | 564 { |
565 View *v = dynamic_cast<View *>(sender()); | 565 View *v = dynamic_cast<View *>(sender()); |
566 | 566 |
567 #ifdef DEBUG_VIEW_MANAGER | 567 #ifdef DEBUG_VIEW_MANAGER |
588 seek(f); | 588 seek(f); |
589 } | 589 } |
590 } | 590 } |
591 | 591 |
592 void | 592 void |
593 ViewManager::seek(int f) | 593 ViewManager::seek(sv_frame_t f) |
594 { | 594 { |
595 #ifdef DEBUG_VIEW_MANAGER | 595 #ifdef DEBUG_VIEW_MANAGER |
596 cerr << "ViewManager::seek(" << f << ")" << endl; | 596 cerr << "ViewManager::seek(" << f << ")" << endl; |
597 #endif | 597 #endif |
598 | 598 |
599 if (m_playSource && m_playSource->isPlaying()) { | 599 if (m_playSource && m_playSource->isPlaying()) { |
600 int playFrame = m_playSource->getCurrentPlayingFrame(); | 600 sv_frame_t playFrame = m_playSource->getCurrentPlayingFrame(); |
601 int diff = std::max(f, playFrame) - std::min(f, playFrame); | 601 sv_frame_t diff = std::max(f, playFrame) - std::min(f, playFrame); |
602 if (diff > 20000) { | 602 if (diff > 20000) { |
603 m_playbackFrame = f; | 603 m_playbackFrame = f; |
604 m_playSource->play(f); | 604 m_playSource->play(f); |
605 #ifdef DEBUG_VIEW_MANAGER | 605 #ifdef DEBUG_VIEW_MANAGER |
606 cerr << "ViewManager::considerSeek: reseeking from " << playFrame << " to " << f << endl; | 606 cerr << "ViewManager::considerSeek: reseeking from " << playFrame << " to " << f << endl; |
721 } | 721 } |
722 | 722 |
723 int | 723 int |
724 ViewManager::scalePixelSize(int pixels) | 724 ViewManager::scalePixelSize(int pixels) |
725 { | 725 { |
726 static float ratio = 0.f; | 726 static double ratio = 0.0; |
727 if (ratio == 0.f) { | 727 if (ratio == 0.0) { |
728 float baseEm; | 728 double baseEm; |
729 #ifdef Q_OS_MAC | 729 #ifdef Q_OS_MAC |
730 baseEm = 17.f; | 730 baseEm = 17.0; |
731 #else | 731 #else |
732 baseEm = 15.f; | 732 baseEm = 15.0; |
733 #endif | 733 #endif |
734 float em = QFontMetrics(QFont()).height(); | 734 double em = QFontMetrics(QFont()).height(); |
735 ratio = em / baseEm; | 735 ratio = em / baseEm; |
736 } | 736 } |
737 | 737 |
738 int scaled = int(pixels * ratio + 0.5); | 738 int scaled = int(pixels * ratio + 0.5); |
739 cerr << "scaledSize: " << pixels << " -> " << scaled << " at ratio " << ratio << endl; | 739 // cerr << "scaledSize: " << pixels << " -> " << scaled << " at ratio " << ratio << endl; |
740 if (pixels != 0 && scaled == 0) scaled = 1; | 740 if (pixels != 0 && scaled == 0) scaled = 1; |
741 return scaled; | 741 return scaled; |
742 } | 742 } |