comparison view/View.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 305c129a2c4f
children df791d8c8f58
comparison
equal deleted inserted replaced
210:748985c7e2c1 211:e2baee498ec8
325 update(); 325 update();
326 326
327 changeVisible = true; 327 changeVisible = true;
328 } 328 }
329 329
330 if (e) emit centreFrameChanged(this, f, m_followPan); 330 if (e) emit centreFrameChanged(f, m_followPan, m_followPlay);
331 } 331 }
332 332
333 return changeVisible; 333 return changeVisible;
334 } 334 }
335 335
529 529
530 void 530 void
531 View::setViewManager(ViewManager *manager) 531 View::setViewManager(ViewManager *manager)
532 { 532 {
533 if (m_manager) { 533 if (m_manager) {
534 m_manager->disconnect(this, SLOT(viewManagerCentreFrameChanged(void *, unsigned long, bool))); 534 m_manager->disconnect(this, SLOT(globalCentreFrameChanged(unsigned long)));
535 m_manager->disconnect(this, SLOT(viewCentreFrameChanged(View *, unsigned long)));
536 m_manager->disconnect(this, SLOT(viewManagerPlaybackFrameChanged(unsigned long)));
535 m_manager->disconnect(this, SLOT(viewManagerZoomLevelChanged(void *, unsigned long, bool))); 537 m_manager->disconnect(this, SLOT(viewManagerZoomLevelChanged(void *, unsigned long, bool)));
536 disconnect(m_manager, SIGNAL(centreFrameChanged(void *, unsigned long, bool))); 538 m_manager->disconnect(this, SLOT(toolModeChanged()));
539 m_manager->disconnect(this, SLOT(selectionChanged()));
540 m_manager->disconnect(this, SLOT(overlayModeChanged()));
541 m_manager->disconnect(this, SLOT(zoomWheelsEnabledChanged()));
542 disconnect(m_manager, SIGNAL(viewCentreFrameChanged(unsigned long, bool, PlaybackFollowMode)));
537 disconnect(m_manager, SIGNAL(zoomLevelChanged(void *, unsigned long, bool))); 543 disconnect(m_manager, SIGNAL(zoomLevelChanged(void *, unsigned long, bool)));
538 disconnect(m_manager, SIGNAL(toolModeChanged()));
539 disconnect(m_manager, SIGNAL(selectionChanged()));
540 disconnect(m_manager, SIGNAL(inProgressSelectionChanged()));
541 } 544 }
542 545
543 m_manager = manager; 546 m_manager = manager;
544 if (m_followPan) setCentreFrame(m_manager->getGlobalCentreFrame(), false); 547 if (m_followPan) setCentreFrame(m_manager->getGlobalCentreFrame(), false);
545 if (m_followZoom) setZoomLevel(m_manager->getGlobalZoom()); 548 if (m_followZoom) setZoomLevel(m_manager->getGlobalZoom());
546 549
547 connect(m_manager, SIGNAL(centreFrameChanged(void *, unsigned long, bool)), 550 connect(m_manager, SIGNAL(globalCentreFrameChanged(unsigned long)),
548 this, SLOT(viewManagerCentreFrameChanged(void *, unsigned long, bool))); 551 this, SLOT(globalCentreFrameChanged(unsigned long)));
552 connect(m_manager, SIGNAL(viewCentreFrameChanged(unsigned long)),
553 this, SLOT(viewCentreFrameChanged(View *, unsigned long)));
549 connect(m_manager, SIGNAL(playbackFrameChanged(unsigned long)), 554 connect(m_manager, SIGNAL(playbackFrameChanged(unsigned long)),
550 this, SLOT(viewManagerPlaybackFrameChanged(unsigned long))); 555 this, SLOT(viewManagerPlaybackFrameChanged(unsigned long)));
556
551 connect(m_manager, SIGNAL(zoomLevelChanged(void *, unsigned long, bool)), 557 connect(m_manager, SIGNAL(zoomLevelChanged(void *, unsigned long, bool)),
552 this, SLOT(viewManagerZoomLevelChanged(void *, unsigned long, bool))); 558 this, SLOT(viewManagerZoomLevelChanged(void *, unsigned long, bool)));
559
553 connect(m_manager, SIGNAL(toolModeChanged()), 560 connect(m_manager, SIGNAL(toolModeChanged()),
554 this, SLOT(toolModeChanged())); 561 this, SLOT(toolModeChanged()));
555 connect(m_manager, SIGNAL(selectionChanged()), 562 connect(m_manager, SIGNAL(selectionChanged()),
556 this, SLOT(selectionChanged())); 563 this, SLOT(selectionChanged()));
557 connect(m_manager, SIGNAL(inProgressSelectionChanged()), 564 connect(m_manager, SIGNAL(inProgressSelectionChanged()),
559 connect(m_manager, SIGNAL(overlayModeChanged()), 566 connect(m_manager, SIGNAL(overlayModeChanged()),
560 this, SLOT(overlayModeChanged())); 567 this, SLOT(overlayModeChanged()));
561 connect(m_manager, SIGNAL(zoomWheelsEnabledChanged()), 568 connect(m_manager, SIGNAL(zoomWheelsEnabledChanged()),
562 this, SLOT(zoomWheelsEnabledChanged())); 569 this, SLOT(zoomWheelsEnabledChanged()));
563 570
564 connect(this, SIGNAL(centreFrameChanged(void *, unsigned long, bool)), 571 connect(this, SIGNAL(centreFrameChanged(unsigned long, bool,
565 m_manager, SIGNAL(centreFrameChanged(void *, unsigned long, bool))); 572 PlaybackFollowMode)),
573 m_manager, SLOT(viewCentreFrameChanged(unsigned long, bool,
574 PlaybackFollowMode)));
575
566 connect(this, SIGNAL(zoomLevelChanged(void *, unsigned long, bool)), 576 connect(this, SIGNAL(zoomLevelChanged(void *, unsigned long, bool)),
567 m_manager, SIGNAL(zoomLevelChanged(void *, unsigned long, bool))); 577 m_manager, SIGNAL(zoomLevelChanged(void *, unsigned long, bool)));
568 578
569 toolModeChanged(); 579 toolModeChanged();
570 } 580 }
703 } 713 }
704 714
705 if (long(startFrame) < myStartFrame) startFrame = myStartFrame; 715 if (long(startFrame) < myStartFrame) startFrame = myStartFrame;
706 if (endFrame > myEndFrame) endFrame = myEndFrame; 716 if (endFrame > myEndFrame) endFrame = myEndFrame;
707 717
708 int x0 = getXForFrame(startFrame);
709 int x1 = getXForFrame(endFrame + 1);
710 if (x1 < x0) x1 = x0;
711
712 checkProgress(obj); 718 checkProgress(obj);
713 719
714 update(); 720 update();
715 //!!! update(x0, 0, x1 - x0 + 1, height());
716 } 721 }
717 722
718 void 723 void
719 View::modelCompletionChanged() 724 View::modelCompletionChanged()
720 { 725 {
765 Layer *layer = dynamic_cast<Layer *>(sender()); 770 Layer *layer = dynamic_cast<Layer *>(sender());
766 if (layer) emit propertyContainerNameChanged(layer); 771 if (layer) emit propertyContainerNameChanged(layer);
767 } 772 }
768 773
769 void 774 void
770 View::viewManagerCentreFrameChanged(void *p, unsigned long f, bool locked) 775 View::globalCentreFrameChanged(unsigned long f)
771 { 776 {
772 if (m_followPan && p != this && locked) { 777 if (m_followPan) {
773 if (m_manager && (sender() == m_manager)) { 778 setCentreFrame(f, false);
774 #ifdef DEBUG_VIEW_WIDGET_PAINT 779 }
775 std::cerr << this << ": manager frame changed " << f << " from " << p << std::endl; 780 }
776 #endif 781
777 setCentreFrame(f); 782 void
778 if (p == this) repaint(); 783 View::viewCentreFrameChanged(View *v, unsigned long f)
779 } 784 {
780 } 785 // We do nothing with this, but a subclass might
781 } 786 }
782 787
783 void 788 void
784 View::viewManagerPlaybackFrameChanged(unsigned long f) 789 View::viewManagerPlaybackFrameChanged(unsigned long f)
785 { 790 {
795 800
796 switch (m_followPlay) { 801 switch (m_followPlay) {
797 802
798 case PlaybackScrollContinuous: 803 case PlaybackScrollContinuous:
799 if (QApplication::mouseButtons() == Qt::NoButton) { 804 if (QApplication::mouseButtons() == Qt::NoButton) {
800 setCentreFrame(f, true); //!!! 805 setCentreFrame(f, false);
801 } 806 }
802 break; 807 break;
803 808
804 case PlaybackScrollPage: 809 case PlaybackScrollPage:
805 { 810 {
1389 if (!m_selectionCached) { 1394 if (!m_selectionCached) {
1390 drawSelections(paint); 1395 drawSelections(paint);
1391 } 1396 }
1392 paint.end(); 1397 paint.end();
1393 1398
1394 if (m_followPlay != PlaybackScrollContinuous) { 1399 bool showPlayPointer = true;
1400 if (m_followPlay == PlaybackScrollContinuous) {
1401 showPlayPointer = false;
1402 } else if (long(m_playPointerFrame) <= getStartFrame() ||
1403 m_playPointerFrame >= getEndFrame()) {
1404 showPlayPointer = false;
1405 } else if (m_manager && !m_manager->isPlaying()) {
1406 if (m_playPointerFrame == getCentreFrame() &&
1407 m_followPlay != PlaybackIgnore) {
1408 showPlayPointer = false;
1409 }
1410 }
1411
1412 if (showPlayPointer) {
1395 1413
1396 paint.begin(this); 1414 paint.begin(this);
1397 1415
1398 if (long(m_playPointerFrame) > getStartFrame() && 1416 int playx = getXForFrame(m_playPointerFrame);
1399 m_playPointerFrame < getEndFrame()) { 1417
1400 1418 paint.setPen(Qt::black);
1401 int playx = getXForFrame(m_playPointerFrame); 1419 paint.drawLine(playx - 1, 0, playx - 1, height() - 1);
1402 1420 paint.drawLine(playx + 1, 0, playx + 1, height() - 1);
1403 paint.setPen(Qt::black); 1421 paint.drawPoint(playx, 0);
1404 paint.drawLine(playx - 1, 0, playx - 1, height() - 1); 1422 paint.drawPoint(playx, height() - 1);
1405 paint.drawLine(playx + 1, 0, playx + 1, height() - 1); 1423 paint.setPen(Qt::white);
1406 paint.drawPoint(playx, 0); 1424 paint.drawLine(playx, 1, playx, height() - 2);
1407 paint.drawPoint(playx, height() - 1);
1408 paint.setPen(Qt::white);
1409 paint.drawLine(playx, 1, playx, height() - 2);
1410 }
1411 1425
1412 paint.end(); 1426 paint.end();
1413 } 1427 }
1414 1428
1415 QFrame::paintEvent(e); 1429 QFrame::paintEvent(e);