comparison view/ViewManager.cpp @ 211:e2baee498ec8

* Rejig handling of scrolling views. Ensures, among other things, that playing when there is a scroll mode view present (e.g. a spectrum) does not drag any page mode views into scroll mode with it.
author Chris Cannam
date Thu, 01 Mar 2007 11:55:46 +0000
parents 5b7472db612b
children cd81066ac7ad
comparison
equal deleted inserted replaced
210:748985c7e2c1 211:e2baee498ec8
15 15
16 #include "ViewManager.h" 16 #include "ViewManager.h"
17 #include "base/AudioPlaySource.h" 17 #include "base/AudioPlaySource.h"
18 #include "data/model/Model.h" 18 #include "data/model/Model.h"
19 #include "base/CommandHistory.h" 19 #include "base/CommandHistory.h"
20 #include "View.h"
20 21
21 #include <QSettings> 22 #include <QSettings>
22 23
23 #include <iostream> 24 #include <iostream>
24 25
46 m_zoomWheelsEnabled = 47 m_zoomWheelsEnabled =
47 settings.value("zoom-wheels-enabled", m_zoomWheelsEnabled).toBool(); 48 settings.value("zoom-wheels-enabled", m_zoomWheelsEnabled).toBool();
48 settings.endGroup(); 49 settings.endGroup();
49 50
50 connect(this, 51 connect(this,
51 SIGNAL(centreFrameChanged(void *, unsigned long, bool)),
52 SLOT(considerSeek(void *, unsigned long, bool)));
53
54 connect(this,
55 SIGNAL(zoomLevelChanged(void *, unsigned long, bool)), 52 SIGNAL(zoomLevelChanged(void *, unsigned long, bool)),
56 SLOT(considerZoomChange(void *, unsigned long, bool))); 53 SLOT(considerZoomChange(void *, unsigned long, bool)));
57 } 54 }
58 55
59 ViewManager::~ViewManager() 56 ViewManager::~ViewManager()
74 { 71 {
75 #ifdef DEBUG_VIEW_MANAGER 72 #ifdef DEBUG_VIEW_MANAGER
76 std::cout << "ViewManager::setGlobalCentreFrame to " << f << std::endl; 73 std::cout << "ViewManager::setGlobalCentreFrame to " << f << std::endl;
77 #endif 74 #endif
78 m_globalCentreFrame = f; 75 m_globalCentreFrame = f;
76 emit globalCentreFrameChanged(f);
79 } 77 }
80 78
81 unsigned long 79 unsigned long
82 ViewManager::getGlobalZoom() const 80 ViewManager::getGlobalZoom() const
83 { 81 {
333 { 331 {
334 return m_playSource && m_playSource->isPlaying(); 332 return m_playSource && m_playSource->isPlaying();
335 } 333 }
336 334
337 void 335 void
338 ViewManager::considerSeek(void *p, unsigned long f, bool locked) 336 ViewManager::viewCentreFrameChanged(unsigned long f, bool locked,
339 { 337 PlaybackFollowMode mode)
338 {
339 View *v = dynamic_cast<View *>(sender());
340
340 if (locked) { 341 if (locked) {
341 m_globalCentreFrame = f; 342 m_globalCentreFrame = f;
342 } 343 emit globalCentreFrameChanged(f);
343 344 } else {
345 if (v) emit viewCentreFrameChanged(v, f);
346 }
347
348 if (mode == PlaybackIgnore) {
349 return;
350 }
351
352 seek(f);
353 }
354
355 void
356 ViewManager::seek(unsigned long f)
357 {
344 #ifdef DEBUG_VIEW_MANAGER 358 #ifdef DEBUG_VIEW_MANAGER
345 std::cout << "ViewManager::considerSeek(" << p << ", " << f << ", " << locked << ")" << std::endl; 359 std::cout << "ViewManager::seek(" << f << ")" << std::endl;
346 #endif 360 #endif
347
348 if (p == this || !locked) return;
349 361
350 if (m_playSource && m_playSource->isPlaying()) { 362 if (m_playSource && m_playSource->isPlaying()) {
351 unsigned long playFrame = m_playSource->getCurrentPlayingFrame(); 363 unsigned long playFrame = m_playSource->getCurrentPlayingFrame();
352 unsigned long diff = std::max(f, playFrame) - std::min(f, playFrame); 364 unsigned long diff = std::max(f, playFrame) - std::min(f, playFrame);
353 if (diff > 20000) { 365 if (diff > 20000) {
354 m_playbackFrame = f; 366 m_playbackFrame = f;
355 m_playSource->play(f); 367 m_playSource->play(f);
356 #ifdef DEBUG_VIEW_MANAGER 368 #ifdef DEBUG_VIEW_MANAGER
357 std::cout << "ViewManager::considerSeek: reseeking from " << playFrame << " to " << f << std::endl; 369 std::cout << "ViewManager::considerSeek: reseeking from " << playFrame << " to " << f << std::endl;
358 #endif 370 #endif
371 emit playbackFrameChanged(f);
359 } 372 }
360 } else { 373 } else {
361 m_playbackFrame = f; //!!! only if that view is in scroll mode? 374 if (m_playbackFrame != f) {
375 m_playbackFrame = f;
376 emit playbackFrameChanged(f);
377 }
362 } 378 }
363 } 379 }
364 380
365 void 381 void
366 ViewManager::considerZoomChange(void *p, unsigned long z, bool locked) 382 ViewManager::considerZoomChange(void *p, unsigned long z, bool locked)