Mercurial > hg > svgui
comparison view/View.cpp @ 1266:a34a2a25907c
Untabify
author | Chris Cannam |
---|---|
date | Thu, 01 Mar 2018 18:02:22 +0000 |
parents | c603aba61702 |
children | 7527701c8076 |
comparison
equal
deleted
inserted
replaced
1265:6e724c81f18f | 1266:a34a2a25907c |
---|---|
112 return PropertyContainer::InvalidProperty; | 112 return PropertyContainer::InvalidProperty; |
113 } | 113 } |
114 | 114 |
115 int | 115 int |
116 View::getPropertyRangeAndValue(const PropertyContainer::PropertyName &name, | 116 View::getPropertyRangeAndValue(const PropertyContainer::PropertyName &name, |
117 int *min, int *max, int *deflt) const | 117 int *min, int *max, int *deflt) const |
118 { | 118 { |
119 if (deflt) *deflt = 1; | 119 if (deflt) *deflt = 1; |
120 if (name == "Global Scroll") return m_followPan; | 120 if (name == "Global Scroll") return m_followPan; |
121 if (name == "Global Zoom") return m_followZoom; | 121 if (name == "Global Zoom") return m_followZoom; |
122 if (name == "Follow Playback") { | 122 if (name == "Follow Playback") { |
123 if (min) *min = 0; | 123 if (min) *min = 0; |
124 if (max) *max = 2; | 124 if (max) *max = 2; |
125 if (deflt) *deflt = int(PlaybackScrollPageWithCentre); | 125 if (deflt) *deflt = int(PlaybackScrollPageWithCentre); |
126 switch (m_followPlay) { | 126 switch (m_followPlay) { |
127 case PlaybackScrollContinuous: return 0; | 127 case PlaybackScrollContinuous: return 0; |
128 case PlaybackScrollPageWithCentre: case PlaybackScrollPage: return 1; | 128 case PlaybackScrollPageWithCentre: case PlaybackScrollPage: return 1; |
129 case PlaybackIgnore: return 2; | 129 case PlaybackIgnore: return 2; |
135 return 0; | 135 return 0; |
136 } | 136 } |
137 | 137 |
138 QString | 138 QString |
139 View::getPropertyValueLabel(const PropertyContainer::PropertyName &name, | 139 View::getPropertyValueLabel(const PropertyContainer::PropertyName &name, |
140 int value) const | 140 int value) const |
141 { | 141 { |
142 if (name == "Follow Playback") { | 142 if (name == "Follow Playback") { |
143 switch (value) { | 143 switch (value) { |
144 default: | 144 default: |
145 case 0: return tr("Scroll"); | 145 case 0: return tr("Scroll"); |
146 case 1: return tr("Page"); | 146 case 1: return tr("Page"); |
147 case 2: return tr("Off"); | 147 case 2: return tr("Off"); |
148 } | 148 } |
149 } | 149 } |
150 return tr("<unknown>"); | 150 return tr("<unknown>"); |
151 } | 151 } |
152 | 152 |
153 void | 153 void |
154 View::setProperty(const PropertyContainer::PropertyName &name, int value) | 154 View::setProperty(const PropertyContainer::PropertyName &name, int value) |
155 { | 155 { |
156 if (name == "Global Scroll") { | 156 if (name == "Global Scroll") { |
157 setFollowGlobalPan(value != 0); | 157 setFollowGlobalPan(value != 0); |
158 } else if (name == "Global Zoom") { | 158 } else if (name == "Global Zoom") { |
159 setFollowGlobalZoom(value != 0); | 159 setFollowGlobalZoom(value != 0); |
160 } else if (name == "Follow Playback") { | 160 } else if (name == "Follow Playback") { |
161 switch (value) { | 161 switch (value) { |
162 default: | 162 default: |
163 case 0: setPlaybackFollow(PlaybackScrollContinuous); break; | 163 case 0: setPlaybackFollow(PlaybackScrollContinuous); break; |
164 case 1: setPlaybackFollow(PlaybackScrollPageWithCentre); break; | 164 case 1: setPlaybackFollow(PlaybackScrollPageWithCentre); break; |
165 case 2: setPlaybackFollow(PlaybackIgnore); break; | 165 case 2: setPlaybackFollow(PlaybackIgnore); break; |
166 } | 166 } |
167 } | 167 } |
168 } | 168 } |
169 | 169 |
170 int | 170 int |
171 View::getPropertyContainerCount() const | 171 View::getPropertyContainerCount() const |
175 | 175 |
176 const PropertyContainer * | 176 const PropertyContainer * |
177 View::getPropertyContainer(int i) const | 177 View::getPropertyContainer(int i) const |
178 { | 178 { |
179 return (const PropertyContainer *)(((View *)this)-> | 179 return (const PropertyContainer *)(((View *)this)-> |
180 getPropertyContainer(i)); | 180 getPropertyContainer(i)); |
181 } | 181 } |
182 | 182 |
183 PropertyContainer * | 183 PropertyContainer * |
184 View::getPropertyContainer(int i) | 184 View::getPropertyContainer(int i) |
185 { | 185 { |
251 View::propertyContainerSelected(View *client, PropertyContainer *pc) | 251 View::propertyContainerSelected(View *client, PropertyContainer *pc) |
252 { | 252 { |
253 if (client != this) return; | 253 if (client != this) return; |
254 | 254 |
255 if (pc == m_propertyContainer) { | 255 if (pc == m_propertyContainer) { |
256 if (m_haveSelectedLayer) { | 256 if (m_haveSelectedLayer) { |
257 m_haveSelectedLayer = false; | 257 m_haveSelectedLayer = false; |
258 update(); | 258 update(); |
259 } | 259 } |
260 return; | 260 return; |
261 } | 261 } |
262 | 262 |
263 delete m_cache; | 263 delete m_cache; |
264 m_cache = 0; | 264 m_cache = 0; |
265 | 265 |
266 Layer *selectedLayer = 0; | 266 Layer *selectedLayer = 0; |
267 | 267 |
268 for (LayerList::iterator i = m_layerStack.begin(); i != m_layerStack.end(); ++i) { | 268 for (LayerList::iterator i = m_layerStack.begin(); i != m_layerStack.end(); ++i) { |
269 if (*i == pc) { | 269 if (*i == pc) { |
270 selectedLayer = *i; | 270 selectedLayer = *i; |
271 m_layerStack.erase(i); | 271 m_layerStack.erase(i); |
272 break; | 272 break; |
273 } | 273 } |
274 } | 274 } |
275 | 275 |
276 if (selectedLayer) { | 276 if (selectedLayer) { |
277 m_haveSelectedLayer = true; | 277 m_haveSelectedLayer = true; |
278 m_layerStack.push_back(selectedLayer); | 278 m_layerStack.push_back(selectedLayer); |
279 update(); | 279 update(); |
280 } else { | 280 } else { |
281 m_haveSelectedLayer = false; | 281 m_haveSelectedLayer = false; |
282 } | 282 } |
283 | 283 |
284 emit propertyContainerSelected(pc); | 284 emit propertyContainerSelected(pc); |
285 } | 285 } |
286 | 286 |
327 { | 327 { |
328 bool changeVisible = false; | 328 bool changeVisible = false; |
329 | 329 |
330 if (m_centreFrame != f) { | 330 if (m_centreFrame != f) { |
331 | 331 |
332 int formerPixel = int(m_centreFrame / m_zoomLevel); | 332 int formerPixel = int(m_centreFrame / m_zoomLevel); |
333 | 333 |
334 m_centreFrame = f; | 334 m_centreFrame = f; |
335 | 335 |
336 int newPixel = int(m_centreFrame / m_zoomLevel); | 336 int newPixel = int(m_centreFrame / m_zoomLevel); |
337 | 337 |
338 if (newPixel != formerPixel) { | 338 if (newPixel != formerPixel) { |
339 | 339 |
340 #ifdef DEBUG_VIEW_WIDGET_PAINT | 340 #ifdef DEBUG_VIEW_WIDGET_PAINT |
341 cout << "View(" << this << ")::setCentreFrame: newPixel " << newPixel << ", formerPixel " << formerPixel << endl; | 341 cout << "View(" << this << ")::setCentreFrame: newPixel " << newPixel << ", formerPixel " << formerPixel << endl; |
342 #endif | 342 #endif |
343 update(); | 343 update(); |
344 | 344 |
345 changeVisible = true; | 345 changeVisible = true; |
346 } | 346 } |
347 | 347 |
348 if (e) { | 348 if (e) { |
349 sv_frame_t rf = alignToReference(f); | 349 sv_frame_t rf = alignToReference(f); |
350 #ifdef DEBUG_VIEW | 350 #ifdef DEBUG_VIEW |
351 cerr << "View[" << this << "]::setCentreFrame(" << f | 351 cerr << "View[" << this << "]::setCentreFrame(" << f |
352 << "): emitting centreFrameChanged(" | 352 << "): emitting centreFrameChanged(" |
353 << rf << ")" << endl; | 353 << rf << ")" << endl; |
381 return frame; | 381 return frame; |
382 } | 382 } |
383 | 383 |
384 double | 384 double |
385 View::getYForFrequency(double frequency, | 385 View::getYForFrequency(double frequency, |
386 double minf, | 386 double minf, |
387 double maxf, | 387 double maxf, |
388 bool logarithmic) const | 388 bool logarithmic) const |
389 { | 389 { |
390 Profiler profiler("View::getYForFrequency"); | 390 Profiler profiler("View::getYForFrequency"); |
391 | 391 |
392 int h = height(); | 392 int h = height(); |
393 | 393 |
394 if (logarithmic) { | 394 if (logarithmic) { |
395 | 395 |
396 static double lastminf = 0.0, lastmaxf = 0.0; | 396 static double lastminf = 0.0, lastmaxf = 0.0; |
397 static double logminf = 0.0, logmaxf = 0.0; | 397 static double logminf = 0.0, logmaxf = 0.0; |
398 | 398 |
399 if (lastminf != minf) { | 399 if (lastminf != minf) { |
400 lastminf = (minf == 0.0 ? 1.0 : minf); | 400 lastminf = (minf == 0.0 ? 1.0 : minf); |
401 logminf = log10(minf); | 401 logminf = log10(minf); |
402 } | 402 } |
403 if (lastmaxf != maxf) { | 403 if (lastmaxf != maxf) { |
404 lastmaxf = (maxf < lastminf ? lastminf : maxf); | 404 lastmaxf = (maxf < lastminf ? lastminf : maxf); |
405 logmaxf = log10(maxf); | 405 logmaxf = log10(maxf); |
406 } | 406 } |
407 | 407 |
408 if (logminf == logmaxf) return 0; | 408 if (logminf == logmaxf) return 0; |
409 return h - (h * (log10(frequency) - logminf)) / (logmaxf - logminf); | 409 return h - (h * (log10(frequency) - logminf)) / (logmaxf - logminf); |
410 | 410 |
411 } else { | 411 } else { |
412 | 412 |
413 if (minf == maxf) return 0; | 413 if (minf == maxf) return 0; |
414 return h - (h * (frequency - minf)) / (maxf - minf); | 414 return h - (h * (frequency - minf)) / (maxf - minf); |
415 } | 415 } |
416 } | 416 } |
417 | 417 |
418 double | 418 double |
419 View::getFrequencyForY(double y, | 419 View::getFrequencyForY(double y, |
420 double minf, | 420 double minf, |
421 double maxf, | 421 double maxf, |
422 bool logarithmic) const | 422 bool logarithmic) const |
423 { | 423 { |
424 double h = height(); | 424 double h = height(); |
425 | 425 |
426 if (logarithmic) { | 426 if (logarithmic) { |
427 | 427 |
428 static double lastminf = 0.0, lastmaxf = 0.0; | 428 static double lastminf = 0.0, lastmaxf = 0.0; |
429 static double logminf = 0.0, logmaxf = 0.0; | 429 static double logminf = 0.0, logmaxf = 0.0; |
430 | 430 |
431 if (lastminf != minf) { | 431 if (lastminf != minf) { |
432 lastminf = (minf == 0.0 ? 1.0 : minf); | 432 lastminf = (minf == 0.0 ? 1.0 : minf); |
433 logminf = log10(minf); | 433 logminf = log10(minf); |
434 } | 434 } |
435 if (lastmaxf != maxf) { | 435 if (lastmaxf != maxf) { |
436 lastmaxf = (maxf < lastminf ? lastminf : maxf); | 436 lastmaxf = (maxf < lastminf ? lastminf : maxf); |
437 logmaxf = log10(maxf); | 437 logmaxf = log10(maxf); |
438 } | 438 } |
439 | 439 |
440 if (logminf == logmaxf) return 0; | 440 if (logminf == logmaxf) return 0; |
441 return pow(10.0, logminf + ((logmaxf - logminf) * (h - y)) / h); | 441 return pow(10.0, logminf + ((logmaxf - logminf) * (h - y)) / h); |
442 | 442 |
443 } else { | 443 } else { |
444 | 444 |
445 if (minf == maxf) return 0; | 445 if (minf == maxf) return 0; |
446 return minf + ((h - y) * (maxf - minf)) / h; | 446 return minf + ((h - y) * (maxf - minf)) / h; |
447 } | 447 } |
448 } | 448 } |
449 | 449 |
450 int | 450 int |
451 View::getZoomLevel() const | 451 View::getZoomLevel() const |
452 { | 452 { |
453 #ifdef DEBUG_VIEW_WIDGET_PAINT | 453 #ifdef DEBUG_VIEW_WIDGET_PAINT |
454 // cout << "zoom level: " << m_zoomLevel << endl; | 454 // cout << "zoom level: " << m_zoomLevel << endl; |
455 #endif | 455 #endif |
456 return m_zoomLevel; | 456 return m_zoomLevel; |
457 } | 457 } |
458 | 458 |
459 int | 459 int |
480 { | 480 { |
481 int dpratio = effectiveDevicePixelRatio(); | 481 int dpratio = effectiveDevicePixelRatio(); |
482 if (z < dpratio) return; | 482 if (z < dpratio) return; |
483 if (z < 1) z = 1; | 483 if (z < 1) z = 1; |
484 if (m_zoomLevel != int(z)) { | 484 if (m_zoomLevel != int(z)) { |
485 m_zoomLevel = z; | 485 m_zoomLevel = z; |
486 emit zoomLevelChanged(z, m_followZoom); | 486 emit zoomLevelChanged(z, m_followZoom); |
487 update(); | 487 update(); |
488 } | 488 } |
489 } | 489 } |
490 | 490 |
491 bool | 491 bool |
492 View::hasLightBackground() const | 492 View::hasLightBackground() const |
594 | 594 |
595 pb->setFont(f); | 595 pb->setFont(f); |
596 pb->hide(); | 596 pb->hide(); |
597 | 597 |
598 connect(layer, SIGNAL(layerParametersChanged()), | 598 connect(layer, SIGNAL(layerParametersChanged()), |
599 this, SLOT(layerParametersChanged())); | 599 this, SLOT(layerParametersChanged())); |
600 connect(layer, SIGNAL(layerParameterRangesChanged()), | 600 connect(layer, SIGNAL(layerParameterRangesChanged()), |
601 this, SLOT(layerParameterRangesChanged())); | 601 this, SLOT(layerParameterRangesChanged())); |
602 connect(layer, SIGNAL(layerMeasurementRectsChanged()), | 602 connect(layer, SIGNAL(layerMeasurementRectsChanged()), |
603 this, SLOT(layerMeasurementRectsChanged())); | 603 this, SLOT(layerMeasurementRectsChanged())); |
604 connect(layer, SIGNAL(layerNameChanged()), | 604 connect(layer, SIGNAL(layerNameChanged()), |
605 this, SLOT(layerNameChanged())); | 605 this, SLOT(layerNameChanged())); |
606 connect(layer, SIGNAL(modelChanged()), | 606 connect(layer, SIGNAL(modelChanged()), |
607 this, SLOT(modelChanged())); | 607 this, SLOT(modelChanged())); |
608 connect(layer, SIGNAL(modelCompletionChanged()), | 608 connect(layer, SIGNAL(modelCompletionChanged()), |
609 this, SLOT(modelCompletionChanged())); | 609 this, SLOT(modelCompletionChanged())); |
610 connect(layer, SIGNAL(modelAlignmentCompletionChanged()), | 610 connect(layer, SIGNAL(modelAlignmentCompletionChanged()), |
611 this, SLOT(modelAlignmentCompletionChanged())); | 611 this, SLOT(modelAlignmentCompletionChanged())); |
612 connect(layer, SIGNAL(modelChangedWithin(sv_frame_t, sv_frame_t)), | 612 connect(layer, SIGNAL(modelChangedWithin(sv_frame_t, sv_frame_t)), |
613 this, SLOT(modelChangedWithin(sv_frame_t, sv_frame_t))); | 613 this, SLOT(modelChangedWithin(sv_frame_t, sv_frame_t))); |
614 connect(layer, SIGNAL(modelReplaced()), | 614 connect(layer, SIGNAL(modelReplaced()), |
615 this, SLOT(modelReplaced())); | 615 this, SLOT(modelReplaced())); |
616 | 616 |
617 update(); | 617 update(); |
618 | 618 |
619 emit propertyContainerAdded(layer); | 619 emit propertyContainerAdded(layer); |
620 } | 620 } |
621 | 621 |
622 void | 622 void |
623 View::removeLayer(Layer *layer) | 623 View::removeLayer(Layer *layer) |
624 { | 624 { |
625 if (m_deleting) { | 625 if (m_deleting) { |
626 return; | 626 return; |
627 } | 627 } |
628 | 628 |
629 delete m_cache; | 629 delete m_cache; |
630 m_cache = 0; | 630 m_cache = 0; |
631 | 631 |
632 for (LayerList::iterator i = m_fixedOrderLayers.begin(); | 632 for (LayerList::iterator i = m_fixedOrderLayers.begin(); |
633 i != m_fixedOrderLayers.end(); | 633 i != m_fixedOrderLayers.end(); |
634 ++i) { | 634 ++i) { |
635 if (*i == layer) { | 635 if (*i == layer) { |
636 m_fixedOrderLayers.erase(i); | 636 m_fixedOrderLayers.erase(i); |
637 break; | 637 break; |
638 } | 638 } |
639 } | 639 } |
640 | 640 |
641 for (LayerList::iterator i = m_layerStack.begin(); | 641 for (LayerList::iterator i = m_layerStack.begin(); |
642 i != m_layerStack.end(); | 642 i != m_layerStack.end(); |
643 ++i) { | 643 ++i) { |
644 if (*i == layer) { | 644 if (*i == layer) { |
645 m_layerStack.erase(i); | 645 m_layerStack.erase(i); |
646 if (m_progressBars.find(layer) != m_progressBars.end()) { | 646 if (m_progressBars.find(layer) != m_progressBars.end()) { |
647 delete m_progressBars[layer].bar; | 647 delete m_progressBars[layer].bar; |
648 delete m_progressBars[layer].cancel; | 648 delete m_progressBars[layer].cancel; |
649 delete m_progressBars[layer].checkTimer; | 649 delete m_progressBars[layer].checkTimer; |
650 m_progressBars.erase(layer); | 650 m_progressBars.erase(layer); |
651 } | 651 } |
652 break; | 652 break; |
653 } | 653 } |
654 } | 654 } |
655 | 655 |
656 disconnect(layer, SIGNAL(layerParametersChanged()), | 656 disconnect(layer, SIGNAL(layerParametersChanged()), |
657 this, SLOT(layerParametersChanged())); | 657 this, SLOT(layerParametersChanged())); |
658 disconnect(layer, SIGNAL(layerParameterRangesChanged()), | 658 disconnect(layer, SIGNAL(layerParameterRangesChanged()), |
705 View::getSelectedLayer() | 705 View::getSelectedLayer() |
706 { | 706 { |
707 if (m_haveSelectedLayer && !m_layerStack.empty()) { | 707 if (m_haveSelectedLayer && !m_layerStack.empty()) { |
708 return getLayer(getLayerCount() - 1); | 708 return getLayer(getLayerCount() - 1); |
709 } else { | 709 } else { |
710 return 0; | 710 return 0; |
711 } | 711 } |
712 } | 712 } |
713 | 713 |
714 const Layer * | 714 const Layer * |
715 View::getSelectedLayer() const | 715 View::getSelectedLayer() const |
719 | 719 |
720 void | 720 void |
721 View::setViewManager(ViewManager *manager) | 721 View::setViewManager(ViewManager *manager) |
722 { | 722 { |
723 if (m_manager) { | 723 if (m_manager) { |
724 m_manager->disconnect(this, SLOT(globalCentreFrameChanged(sv_frame_t))); | 724 m_manager->disconnect(this, SLOT(globalCentreFrameChanged(sv_frame_t))); |
725 m_manager->disconnect(this, SLOT(viewCentreFrameChanged(View *, sv_frame_t))); | 725 m_manager->disconnect(this, SLOT(viewCentreFrameChanged(View *, sv_frame_t))); |
726 m_manager->disconnect(this, SLOT(viewManagerPlaybackFrameChanged(sv_frame_t))); | 726 m_manager->disconnect(this, SLOT(viewManagerPlaybackFrameChanged(sv_frame_t))); |
727 m_manager->disconnect(this, SLOT(viewZoomLevelChanged(View *, int, bool))); | 727 m_manager->disconnect(this, SLOT(viewZoomLevelChanged(View *, int, bool))); |
728 m_manager->disconnect(this, SLOT(toolModeChanged())); | 728 m_manager->disconnect(this, SLOT(toolModeChanged())); |
729 m_manager->disconnect(this, SLOT(selectionChanged())); | 729 m_manager->disconnect(this, SLOT(selectionChanged())); |
730 m_manager->disconnect(this, SLOT(overlayModeChanged())); | 730 m_manager->disconnect(this, SLOT(overlayModeChanged())); |
731 m_manager->disconnect(this, SLOT(zoomWheelsEnabledChanged())); | 731 m_manager->disconnect(this, SLOT(zoomWheelsEnabledChanged())); |
732 disconnect(m_manager, SLOT(viewCentreFrameChanged(sv_frame_t, bool, PlaybackFollowMode))); | 732 disconnect(m_manager, SLOT(viewCentreFrameChanged(sv_frame_t, bool, PlaybackFollowMode))); |
733 disconnect(m_manager, SLOT(zoomLevelChanged(int, bool))); | 733 disconnect(m_manager, SLOT(zoomLevelChanged(int, bool))); |
734 } | 734 } |
735 | 735 |
736 m_manager = manager; | 736 m_manager = manager; |
737 | 737 |
738 connect(m_manager, SIGNAL(globalCentreFrameChanged(sv_frame_t)), | 738 connect(m_manager, SIGNAL(globalCentreFrameChanged(sv_frame_t)), |
739 this, SLOT(globalCentreFrameChanged(sv_frame_t))); | 739 this, SLOT(globalCentreFrameChanged(sv_frame_t))); |
740 connect(m_manager, SIGNAL(viewCentreFrameChanged(View *, sv_frame_t)), | 740 connect(m_manager, SIGNAL(viewCentreFrameChanged(View *, sv_frame_t)), |
741 this, SLOT(viewCentreFrameChanged(View *, sv_frame_t))); | 741 this, SLOT(viewCentreFrameChanged(View *, sv_frame_t))); |
742 connect(m_manager, SIGNAL(playbackFrameChanged(sv_frame_t)), | 742 connect(m_manager, SIGNAL(playbackFrameChanged(sv_frame_t)), |
743 this, SLOT(viewManagerPlaybackFrameChanged(sv_frame_t))); | 743 this, SLOT(viewManagerPlaybackFrameChanged(sv_frame_t))); |
744 | 744 |
745 connect(m_manager, SIGNAL(viewZoomLevelChanged(View *, int, bool)), | 745 connect(m_manager, SIGNAL(viewZoomLevelChanged(View *, int, bool)), |
746 this, SLOT(viewZoomLevelChanged(View *, int, bool))); | 746 this, SLOT(viewZoomLevelChanged(View *, int, bool))); |
747 | 747 |
748 connect(m_manager, SIGNAL(toolModeChanged()), | 748 connect(m_manager, SIGNAL(toolModeChanged()), |
749 this, SLOT(toolModeChanged())); | 749 this, SLOT(toolModeChanged())); |
750 connect(m_manager, SIGNAL(selectionChanged()), | 750 connect(m_manager, SIGNAL(selectionChanged()), |
751 this, SLOT(selectionChanged())); | 751 this, SLOT(selectionChanged())); |
752 connect(m_manager, SIGNAL(inProgressSelectionChanged()), | 752 connect(m_manager, SIGNAL(inProgressSelectionChanged()), |
753 this, SLOT(selectionChanged())); | 753 this, SLOT(selectionChanged())); |
754 connect(m_manager, SIGNAL(overlayModeChanged()), | 754 connect(m_manager, SIGNAL(overlayModeChanged()), |
755 this, SLOT(overlayModeChanged())); | 755 this, SLOT(overlayModeChanged())); |
756 connect(m_manager, SIGNAL(showCentreLineChanged()), | 756 connect(m_manager, SIGNAL(showCentreLineChanged()), |
757 this, SLOT(overlayModeChanged())); | 757 this, SLOT(overlayModeChanged())); |
758 connect(m_manager, SIGNAL(zoomWheelsEnabledChanged()), | 758 connect(m_manager, SIGNAL(zoomWheelsEnabledChanged()), |
762 PlaybackFollowMode)), | 762 PlaybackFollowMode)), |
763 m_manager, SLOT(viewCentreFrameChanged(sv_frame_t, bool, | 763 m_manager, SLOT(viewCentreFrameChanged(sv_frame_t, bool, |
764 PlaybackFollowMode))); | 764 PlaybackFollowMode))); |
765 | 765 |
766 connect(this, SIGNAL(zoomLevelChanged(int, bool)), | 766 connect(this, SIGNAL(zoomLevelChanged(int, bool)), |
767 m_manager, SLOT(viewZoomLevelChanged(int, bool))); | 767 m_manager, SLOT(viewZoomLevelChanged(int, bool))); |
768 | 768 |
769 switch (m_followPlay) { | 769 switch (m_followPlay) { |
770 | 770 |
771 case PlaybackScrollPage: | 771 case PlaybackScrollPage: |
772 case PlaybackScrollPageWithCentre: | 772 case PlaybackScrollPageWithCentre: |
834 bool recreate = false; | 834 bool recreate = false; |
835 | 835 |
836 bool discard; | 836 bool discard; |
837 LayerList scrollables = getScrollableBackLayers(false, discard); | 837 LayerList scrollables = getScrollableBackLayers(false, discard); |
838 for (LayerList::const_iterator i = scrollables.begin(); | 838 for (LayerList::const_iterator i = scrollables.begin(); |
839 i != scrollables.end(); ++i) { | 839 i != scrollables.end(); ++i) { |
840 if (*i == obj || (*i)->getModel() == obj) { | 840 if (*i == obj || (*i)->getModel() == obj) { |
841 recreate = true; | 841 recreate = true; |
842 break; | 842 break; |
843 } | 843 } |
844 } | 844 } |
845 | 845 |
846 if (recreate) { | 846 if (recreate) { |
847 delete m_cache; | 847 delete m_cache; |
848 m_cache = 0; | 848 m_cache = 0; |
849 } | 849 } |
850 | 850 |
851 emit layerModelChanged(); | 851 emit layerModelChanged(); |
852 | 852 |
853 checkProgress(obj); | 853 checkProgress(obj); |
866 #ifdef DEBUG_VIEW_WIDGET_PAINT | 866 #ifdef DEBUG_VIEW_WIDGET_PAINT |
867 cerr << "View(" << this << ")::modelChangedWithin(" << startFrame << "," << endFrame << ") [me " << myStartFrame << "," << myEndFrame << "]" << endl; | 867 cerr << "View(" << this << ")::modelChangedWithin(" << startFrame << "," << endFrame << ") [me " << myStartFrame << "," << myEndFrame << "]" << endl; |
868 #endif | 868 #endif |
869 | 869 |
870 if (myStartFrame > 0 && endFrame < myStartFrame) { | 870 if (myStartFrame > 0 && endFrame < myStartFrame) { |
871 checkProgress(obj); | 871 checkProgress(obj); |
872 return; | 872 return; |
873 } | 873 } |
874 if (startFrame > myEndFrame) { | 874 if (startFrame > myEndFrame) { |
875 checkProgress(obj); | 875 checkProgress(obj); |
876 return; | 876 return; |
877 } | 877 } |
878 | 878 |
879 // If the model that has changed is not used by any of the cached | 879 // If the model that has changed is not used by any of the cached |
880 // layers, we won't need to recreate the cache | 880 // layers, we won't need to recreate the cache |
881 | 881 |
882 bool recreate = false; | 882 bool recreate = false; |
883 | 883 |
884 bool discard; | 884 bool discard; |
885 LayerList scrollables = getScrollableBackLayers(false, discard); | 885 LayerList scrollables = getScrollableBackLayers(false, discard); |
886 for (LayerList::const_iterator i = scrollables.begin(); | 886 for (LayerList::const_iterator i = scrollables.begin(); |
887 i != scrollables.end(); ++i) { | 887 i != scrollables.end(); ++i) { |
888 if (*i == obj || (*i)->getModel() == obj) { | 888 if (*i == obj || (*i)->getModel() == obj) { |
889 recreate = true; | 889 recreate = true; |
890 break; | 890 break; |
891 } | 891 } |
892 } | 892 } |
893 | 893 |
894 if (recreate) { | 894 if (recreate) { |
895 delete m_cache; | 895 delete m_cache; |
896 m_cache = 0; | 896 m_cache = 0; |
897 } | 897 } |
898 | 898 |
899 if (startFrame < myStartFrame) startFrame = myStartFrame; | 899 if (startFrame < myStartFrame) startFrame = myStartFrame; |
900 if (endFrame > myEndFrame) endFrame = myEndFrame; | 900 if (endFrame > myEndFrame) endFrame = myEndFrame; |
901 | 901 |
946 delete m_cache; | 946 delete m_cache; |
947 m_cache = 0; | 947 m_cache = 0; |
948 update(); | 948 update(); |
949 | 949 |
950 if (layer) { | 950 if (layer) { |
951 emit propertyContainerPropertyChanged(layer); | 951 emit propertyContainerPropertyChanged(layer); |
952 } | 952 } |
953 } | 953 } |
954 | 954 |
955 void | 955 void |
956 View::layerParameterRangesChanged() | 956 View::layerParameterRangesChanged() |
994 | 994 |
995 void | 995 void |
996 View::viewManagerPlaybackFrameChanged(sv_frame_t f) | 996 View::viewManagerPlaybackFrameChanged(sv_frame_t f) |
997 { | 997 { |
998 if (m_manager) { | 998 if (m_manager) { |
999 if (sender() != m_manager) return; | 999 if (sender() != m_manager) return; |
1000 } | 1000 } |
1001 | 1001 |
1002 #ifdef DEBUG_VIEW | 1002 #ifdef DEBUG_VIEW |
1003 cerr << "View::viewManagerPlaybackFrameChanged(" << f << ")" << endl; | 1003 cerr << "View::viewManagerPlaybackFrameChanged(" << f << ")" << endl; |
1004 #endif | 1004 #endif |
1029 bool somethingGoingOn = | 1029 bool somethingGoingOn = |
1030 ((QApplication::mouseButtons() != Qt::NoButton) || | 1030 ((QApplication::mouseButtons() != Qt::NoButton) || |
1031 (QApplication::keyboardModifiers() & Qt::AltModifier)); | 1031 (QApplication::keyboardModifiers() & Qt::AltModifier)); |
1032 | 1032 |
1033 bool pointerInVisibleArea = | 1033 bool pointerInVisibleArea = |
1034 long(m_playPointerFrame) >= getStartFrame() && | 1034 long(m_playPointerFrame) >= getStartFrame() && |
1035 (m_playPointerFrame < getEndFrame() || | 1035 (m_playPointerFrame < getEndFrame() || |
1036 // include old pointer location so we know to refresh when moving out | 1036 // include old pointer location so we know to refresh when moving out |
1037 oldPlayPointerFrame < getEndFrame()); | 1037 oldPlayPointerFrame < getEndFrame()); |
1038 | 1038 |
1039 switch (m_followPlay) { | 1039 switch (m_followPlay) { |
1040 | 1040 |
1041 case PlaybackScrollContinuous: | 1041 case PlaybackScrollContinuous: |
1042 if (!somethingGoingOn) { | 1042 if (!somethingGoingOn) { |
1043 setCentreFrame(m_playPointerFrame, false); | 1043 setCentreFrame(m_playPointerFrame, false); |
1044 } | 1044 } |
1045 break; | 1045 break; |
1046 | 1046 |
1047 case PlaybackScrollPage: | 1047 case PlaybackScrollPage: |
1048 case PlaybackScrollPageWithCentre: | 1048 case PlaybackScrollPageWithCentre: |
1049 | 1049 |
1050 if (!pointerInVisibleArea && somethingGoingOn) { | 1050 if (!pointerInVisibleArea && somethingGoingOn) { |
1115 update(xnew - 4, 0, 9, height()); | 1115 update(xnew - 4, 0, 9, height()); |
1116 } | 1116 } |
1117 break; | 1117 break; |
1118 | 1118 |
1119 case PlaybackIgnore: | 1119 case PlaybackIgnore: |
1120 if (m_playPointerFrame >= getStartFrame() && | 1120 if (m_playPointerFrame >= getStartFrame() && |
1121 m_playPointerFrame < getEndFrame()) { | 1121 m_playPointerFrame < getEndFrame()) { |
1122 update(); | 1122 update(); |
1123 } | 1123 } |
1124 break; | 1124 break; |
1125 } | 1125 } |
1126 } | 1126 } |
1127 | 1127 |
1128 void | 1128 void |
1129 View::viewZoomLevelChanged(View *p, int z, bool locked) | 1129 View::viewZoomLevelChanged(View *p, int z, bool locked) |
1138 | 1138 |
1139 void | 1139 void |
1140 View::selectionChanged() | 1140 View::selectionChanged() |
1141 { | 1141 { |
1142 if (m_selectionCached) { | 1142 if (m_selectionCached) { |
1143 delete m_cache; | 1143 delete m_cache; |
1144 m_cache = 0; | 1144 m_cache = 0; |
1145 m_selectionCached = false; | 1145 m_selectionCached = false; |
1146 } | 1146 } |
1147 update(); | 1147 update(); |
1148 } | 1148 } |
1149 | 1149 |
1150 sv_frame_t | 1150 sv_frame_t |
1171 bool first = true; | 1171 bool first = true; |
1172 sv_frame_t startFrame = 0; | 1172 sv_frame_t startFrame = 0; |
1173 | 1173 |
1174 for (LayerList::const_iterator i = m_layerStack.begin(); i != m_layerStack.end(); ++i) { | 1174 for (LayerList::const_iterator i = m_layerStack.begin(); i != m_layerStack.end(); ++i) { |
1175 | 1175 |
1176 if ((*i)->getModel() && (*i)->getModel()->isOK()) { | 1176 if ((*i)->getModel() && (*i)->getModel()->isOK()) { |
1177 | 1177 |
1178 sv_frame_t thisStartFrame = (*i)->getModel()->getStartFrame(); | 1178 sv_frame_t thisStartFrame = (*i)->getModel()->getStartFrame(); |
1179 | 1179 |
1180 if (first || thisStartFrame < startFrame) { | 1180 if (first || thisStartFrame < startFrame) { |
1181 startFrame = thisStartFrame; | 1181 startFrame = thisStartFrame; |
1182 } | 1182 } |
1183 first = false; | 1183 first = false; |
1184 } | 1184 } |
1185 } | 1185 } |
1186 return startFrame; | 1186 return startFrame; |
1187 } | 1187 } |
1188 | 1188 |
1189 sv_frame_t | 1189 sv_frame_t |
1192 bool first = true; | 1192 bool first = true; |
1193 sv_frame_t endFrame = 0; | 1193 sv_frame_t endFrame = 0; |
1194 | 1194 |
1195 for (LayerList::const_iterator i = m_layerStack.begin(); i != m_layerStack.end(); ++i) { | 1195 for (LayerList::const_iterator i = m_layerStack.begin(); i != m_layerStack.end(); ++i) { |
1196 | 1196 |
1197 if ((*i)->getModel() && (*i)->getModel()->isOK()) { | 1197 if ((*i)->getModel() && (*i)->getModel()->isOK()) { |
1198 | 1198 |
1199 sv_frame_t thisEndFrame = (*i)->getModel()->getEndFrame(); | 1199 sv_frame_t thisEndFrame = (*i)->getModel()->getEndFrame(); |
1200 | 1200 |
1201 if (first || thisEndFrame > endFrame) { | 1201 if (first || thisEndFrame > endFrame) { |
1202 endFrame = thisEndFrame; | 1202 endFrame = thisEndFrame; |
1203 } | 1203 } |
1204 first = false; | 1204 first = false; |
1205 } | 1205 } |
1206 } | 1206 } |
1207 | 1207 |
1208 if (first) return getModelsStartFrame(); | 1208 if (first) return getModelsStartFrame(); |
1209 return endFrame; | 1209 return endFrame; |
1210 } | 1210 } |
1217 // conversion in the model | 1217 // conversion in the model |
1218 | 1218 |
1219 //!!! nah, this wants to always return the sr of the main model! | 1219 //!!! nah, this wants to always return the sr of the main model! |
1220 | 1220 |
1221 for (LayerList::const_iterator i = m_layerStack.begin(); i != m_layerStack.end(); ++i) { | 1221 for (LayerList::const_iterator i = m_layerStack.begin(); i != m_layerStack.end(); ++i) { |
1222 if ((*i)->getModel() && (*i)->getModel()->isOK()) { | 1222 if ((*i)->getModel() && (*i)->getModel()->isOK()) { |
1223 return (*i)->getModel()->getSampleRate(); | 1223 return (*i)->getModel()->getSampleRate(); |
1224 } | 1224 } |
1225 } | 1225 } |
1226 return 0; | 1226 return 0; |
1227 } | 1227 } |
1228 | 1228 |
1229 View::ModelSet | 1229 View::ModelSet |
1324 bool | 1324 bool |
1325 View::areLayersScrollable() const | 1325 View::areLayersScrollable() const |
1326 { | 1326 { |
1327 // True iff all views are scrollable | 1327 // True iff all views are scrollable |
1328 for (LayerList::const_iterator i = m_layerStack.begin(); i != m_layerStack.end(); ++i) { | 1328 for (LayerList::const_iterator i = m_layerStack.begin(); i != m_layerStack.end(); ++i) { |
1329 if (!(*i)->isLayerScrollable(this)) return false; | 1329 if (!(*i)->isLayerScrollable(this)) return false; |
1330 } | 1330 } |
1331 return true; | 1331 return true; |
1332 } | 1332 } |
1333 | 1333 |
1334 View::LayerList | 1334 View::LayerList |
1345 for (LayerList::const_iterator i = m_layerStack.begin(); i != m_layerStack.end(); ++i) { | 1345 for (LayerList::const_iterator i = m_layerStack.begin(); i != m_layerStack.end(); ++i) { |
1346 // SVDEBUG << "View::getScrollableBackLayers: calling isLayerDormant on layer " << *i << endl; | 1346 // SVDEBUG << "View::getScrollableBackLayers: calling isLayerDormant on layer " << *i << endl; |
1347 // cerr << "(name is " << (*i)->objectName() << ")" | 1347 // cerr << "(name is " << (*i)->objectName() << ")" |
1348 // << endl; | 1348 // << endl; |
1349 // SVDEBUG << "View::getScrollableBackLayers: I am " << this << endl; | 1349 // SVDEBUG << "View::getScrollableBackLayers: I am " << this << endl; |
1350 if ((*i)->isLayerDormant(this)) continue; | 1350 if ((*i)->isLayerDormant(this)) continue; |
1351 if ((*i)->isLayerOpaque()) { | 1351 if ((*i)->isLayerOpaque()) { |
1352 // You can't see anything behind an opaque layer! | 1352 // You can't see anything behind an opaque layer! |
1353 scrollables.clear(); | 1353 scrollables.clear(); |
1354 if (metUnscrollable) break; | 1354 if (metUnscrollable) break; |
1355 } | 1355 } |
1356 if (!metUnscrollable && (*i)->isLayerScrollable(this)) { | 1356 if (!metUnscrollable && (*i)->isLayerScrollable(this)) { |
1357 scrollables.push_back(*i); | 1357 scrollables.push_back(*i); |
1358 } else { | 1358 } else { |
1359 metUnscrollable = true; | 1359 metUnscrollable = true; |
1360 } | 1360 } |
1361 } | 1361 } |
1362 | 1362 |
1363 if (testChanged && scrollables != m_lastScrollableBackLayers) { | 1363 if (testChanged && scrollables != m_lastScrollableBackLayers) { |
1364 m_lastScrollableBackLayers = scrollables; | 1364 m_lastScrollableBackLayers = scrollables; |
1365 changed = true; | 1365 changed = true; |
1366 } | 1366 } |
1367 return scrollables; | 1367 return scrollables; |
1368 } | 1368 } |
1369 | 1369 |
1370 View::LayerList | 1370 View::LayerList |
1377 // should also be considered non-scrollable | 1377 // should also be considered non-scrollable |
1378 | 1378 |
1379 bool started = false; | 1379 bool started = false; |
1380 | 1380 |
1381 for (LayerList::const_iterator i = m_layerStack.begin(); i != m_layerStack.end(); ++i) { | 1381 for (LayerList::const_iterator i = m_layerStack.begin(); i != m_layerStack.end(); ++i) { |
1382 if ((*i)->isLayerDormant(this)) continue; | 1382 if ((*i)->isLayerDormant(this)) continue; |
1383 if (!started && (*i)->isLayerScrollable(this)) { | 1383 if (!started && (*i)->isLayerScrollable(this)) { |
1384 continue; | 1384 continue; |
1385 } | 1385 } |
1386 started = true; | 1386 started = true; |
1387 if ((*i)->isLayerOpaque()) { | 1387 if ((*i)->isLayerOpaque()) { |
1388 // You can't see anything behind an opaque layer! | 1388 // You can't see anything behind an opaque layer! |
1389 nonScrollables.clear(); | 1389 nonScrollables.clear(); |
1390 } | 1390 } |
1391 nonScrollables.push_back(*i); | 1391 nonScrollables.push_back(*i); |
1392 } | 1392 } |
1393 | 1393 |
1394 if (testChanged && nonScrollables != m_lastNonScrollableBackLayers) { | 1394 if (testChanged && nonScrollables != m_lastNonScrollableBackLayers) { |
1395 m_lastNonScrollableBackLayers = nonScrollables; | 1395 m_lastNonScrollableBackLayers = nonScrollables; |
1396 changed = true; | 1396 changed = true; |
1397 } | 1397 } |
1398 | 1398 |
1399 return nonScrollables; | 1399 return nonScrollables; |
1400 } | 1400 } |
1401 | 1401 |
1402 int | 1402 int |
1403 View::getZoomConstraintBlockSize(int blockSize, | 1403 View::getZoomConstraintBlockSize(int blockSize, |
1404 ZoomConstraint::RoundingDirection dir) | 1404 ZoomConstraint::RoundingDirection dir) |
1405 const | 1405 const |
1406 { | 1406 { |
1407 int candidate = blockSize; | 1407 int candidate = blockSize; |
1408 bool haveCandidate = false; | 1408 bool haveCandidate = false; |
1409 | 1409 |
1410 PowerOfSqrtTwoZoomConstraint defaultZoomConstraint; | 1410 PowerOfSqrtTwoZoomConstraint defaultZoomConstraint; |
1411 | 1411 |
1412 for (LayerList::const_iterator i = m_layerStack.begin(); i != m_layerStack.end(); ++i) { | 1412 for (LayerList::const_iterator i = m_layerStack.begin(); i != m_layerStack.end(); ++i) { |
1413 | 1413 |
1414 const ZoomConstraint *zoomConstraint = (*i)->getZoomConstraint(); | 1414 const ZoomConstraint *zoomConstraint = (*i)->getZoomConstraint(); |
1415 if (!zoomConstraint) zoomConstraint = &defaultZoomConstraint; | 1415 if (!zoomConstraint) zoomConstraint = &defaultZoomConstraint; |
1416 | 1416 |
1417 int thisBlockSize = | 1417 int thisBlockSize = |
1418 zoomConstraint->getNearestBlockSize(blockSize, dir); | 1418 zoomConstraint->getNearestBlockSize(blockSize, dir); |
1419 | 1419 |
1420 // Go for the block size that's furthest from the one | 1420 // Go for the block size that's furthest from the one |
1421 // passed in. Most of the time, that's what we want. | 1421 // passed in. Most of the time, that's what we want. |
1422 if (!haveCandidate || | 1422 if (!haveCandidate || |
1423 (thisBlockSize > blockSize && thisBlockSize > candidate) || | 1423 (thisBlockSize > blockSize && thisBlockSize > candidate) || |
1424 (thisBlockSize < blockSize && thisBlockSize < candidate)) { | 1424 (thisBlockSize < blockSize && thisBlockSize < candidate)) { |
1425 candidate = thisBlockSize; | 1425 candidate = thisBlockSize; |
1426 haveCandidate = true; | 1426 haveCandidate = true; |
1427 } | 1427 } |
1428 } | 1428 } |
1429 | 1429 |
1430 return candidate; | 1430 return candidate; |
1431 } | 1431 } |
1432 | 1432 |
1433 bool | 1433 bool |
1434 View::areLayerColoursSignificant() const | 1434 View::areLayerColoursSignificant() const |
1435 { | 1435 { |
1436 for (LayerList::const_iterator i = m_layerStack.begin(); i != m_layerStack.end(); ++i) { | 1436 for (LayerList::const_iterator i = m_layerStack.begin(); i != m_layerStack.end(); ++i) { |
1437 if ((*i)->getLayerColourSignificance() == | 1437 if ((*i)->getLayerColourSignificance() == |
1438 Layer::ColourHasMeaningfulValue) return true; | 1438 Layer::ColourHasMeaningfulValue) return true; |
1439 if ((*i)->isLayerOpaque()) break; | 1439 if ((*i)->isLayerOpaque()) break; |
1440 } | 1440 } |
1441 return false; | 1441 return false; |
1442 } | 1442 } |
1454 View::zoom(bool in) | 1454 View::zoom(bool in) |
1455 { | 1455 { |
1456 int newZoomLevel = m_zoomLevel; | 1456 int newZoomLevel = m_zoomLevel; |
1457 | 1457 |
1458 if (in) { | 1458 if (in) { |
1459 newZoomLevel = getZoomConstraintBlockSize(newZoomLevel - 1, | 1459 newZoomLevel = getZoomConstraintBlockSize(newZoomLevel - 1, |
1460 ZoomConstraint::RoundDown); | 1460 ZoomConstraint::RoundDown); |
1461 } else { | 1461 } else { |
1462 newZoomLevel = getZoomConstraintBlockSize(newZoomLevel + 1, | 1462 newZoomLevel = getZoomConstraintBlockSize(newZoomLevel + 1, |
1463 ZoomConstraint::RoundUp); | 1463 ZoomConstraint::RoundUp); |
1464 } | 1464 } |
1465 | 1465 |
1466 if (newZoomLevel != m_zoomLevel) { | 1466 if (newZoomLevel != m_zoomLevel) { |
1467 setZoomLevel(newZoomLevel); | 1467 setZoomLevel(newZoomLevel); |
1468 } | 1468 } |
1469 } | 1469 } |
1470 | 1470 |
1471 void | 1471 void |
1472 View::scroll(bool right, bool lots, bool e) | 1472 View::scroll(bool right, bool lots, bool e) |
1473 { | 1473 { |
1474 sv_frame_t delta; | 1474 sv_frame_t delta; |
1475 if (lots) { | 1475 if (lots) { |
1476 delta = (getEndFrame() - getStartFrame()) / 2; | 1476 delta = (getEndFrame() - getStartFrame()) / 2; |
1477 } else { | 1477 } else { |
1478 delta = (getEndFrame() - getStartFrame()) / 20; | 1478 delta = (getEndFrame() - getStartFrame()) / 20; |
1479 } | 1479 } |
1480 if (right) delta = -delta; | 1480 if (right) delta = -delta; |
1481 | 1481 |
1482 if (m_centreFrame < delta) { | 1482 if (m_centreFrame < delta) { |
1483 setCentreFrame(0, e); | 1483 setCentreFrame(0, e); |
1484 } else if (m_centreFrame - delta >= getModelsEndFrame()) { | 1484 } else if (m_centreFrame - delta >= getModelsEndFrame()) { |
1485 setCentreFrame(getModelsEndFrame(), e); | 1485 setCentreFrame(getModelsEndFrame(), e); |
1486 } else { | 1486 } else { |
1487 setCentreFrame(m_centreFrame - delta, e); | 1487 setCentreFrame(m_centreFrame - delta, e); |
1488 } | 1488 } |
1489 } | 1489 } |
1490 | 1490 |
1491 void | 1491 void |
1492 View::cancelClicked() | 1492 View::cancelClicked() |
1493 { | 1493 { |
1494 QPushButton *cancel = qobject_cast<QPushButton *>(sender()); | 1494 QPushButton *cancel = qobject_cast<QPushButton *>(sender()); |
1495 if (!cancel) return; | 1495 if (!cancel) return; |
1496 | 1496 |
1497 for (ProgressMap::iterator i = m_progressBars.begin(); | 1497 for (ProgressMap::iterator i = m_progressBars.begin(); |
1498 i != m_progressBars.end(); ++i) { | 1498 i != m_progressBars.end(); ++i) { |
1499 | 1499 |
1500 if (i->second.cancel == cancel) { | 1500 if (i->second.cancel == cancel) { |
1501 | 1501 |
1502 Layer *layer = i->first; | 1502 Layer *layer = i->first; |
1503 Model *model = layer->getModel(); | 1503 Model *model = layer->getModel(); |
1513 if (!m_showProgress) return; | 1513 if (!m_showProgress) return; |
1514 | 1514 |
1515 int ph = height(); | 1515 int ph = height(); |
1516 | 1516 |
1517 for (ProgressMap::iterator i = m_progressBars.begin(); | 1517 for (ProgressMap::iterator i = m_progressBars.begin(); |
1518 i != m_progressBars.end(); ++i) { | 1518 i != m_progressBars.end(); ++i) { |
1519 | 1519 |
1520 QProgressBar *pb = i->second.bar; | 1520 QProgressBar *pb = i->second.bar; |
1521 QPushButton *cancel = i->second.cancel; | 1521 QPushButton *cancel = i->second.cancel; |
1522 | 1522 |
1523 if (i->first == object) { | 1523 if (i->first == object) { |
1524 | 1524 |
1525 // The timer is used to test for stalls. If the progress | 1525 // The timer is used to test for stalls. If the progress |
1526 // bar does not get updated for some length of time, the | 1526 // bar does not get updated for some length of time, the |
1527 // timer prompts it to go back into "indeterminate" mode | 1527 // timer prompts it to go back into "indeterminate" mode |
1528 QTimer *timer = i->second.checkTimer; | 1528 QTimer *timer = i->second.checkTimer; |
1529 | 1529 |
1530 int completion = i->first->getCompletion(this); | 1530 int completion = i->first->getCompletion(this); |
1531 QString text = i->first->getPropertyContainerName(); | 1531 QString text = i->first->getPropertyContainerName(); |
1532 QString error = i->first->getError(this); | 1532 QString error = i->first->getError(this); |
1533 | 1533 |
1534 if (error != "" && error != m_lastError) { | 1534 if (error != "" && error != m_lastError) { |
1535 QMessageBox::critical(this, tr("Layer rendering error"), error); | 1535 QMessageBox::critical(this, tr("Layer rendering error"), error); |
1560 | 1560 |
1561 } else if (wfm) { | 1561 } else if (wfm) { |
1562 update(); // ensure duration &c gets updated | 1562 update(); // ensure duration &c gets updated |
1563 } | 1563 } |
1564 | 1564 |
1565 if (completion >= 100) { | 1565 if (completion >= 100) { |
1566 | 1566 |
1567 pb->hide(); | 1567 pb->hide(); |
1568 cancel->hide(); | 1568 cancel->hide(); |
1569 timer->stop(); | 1569 timer->stop(); |
1570 | 1570 |
1571 } else { | 1571 } else { |
1572 | 1572 |
1573 // cerr << "progress = " << completion << endl; | 1573 // cerr << "progress = " << completion << endl; |
1574 | 1574 |
1575 if (!pb->isVisible()) { | 1575 if (!pb->isVisible()) { |
1576 i->second.lastCheck = 0; | 1576 i->second.lastCheck = 0; |
1579 } | 1579 } |
1580 | 1580 |
1581 cancel->move(0, ph - pb->height()/2 - 10); | 1581 cancel->move(0, ph - pb->height()/2 - 10); |
1582 cancel->show(); | 1582 cancel->show(); |
1583 | 1583 |
1584 pb->setValue(completion); | 1584 pb->setValue(completion); |
1585 pb->move(20, ph - pb->height()); | 1585 pb->move(20, ph - pb->height()); |
1586 | 1586 |
1587 pb->show(); | 1587 pb->show(); |
1588 pb->update(); | 1588 pb->update(); |
1589 | 1589 |
1590 ph -= pb->height(); | 1590 ph -= pb->height(); |
1591 } | 1591 } |
1592 } else { | 1592 } else { |
1593 if (pb->isVisible()) { | 1593 if (pb->isVisible()) { |
1594 ph -= pb->height(); | 1594 ph -= pb->height(); |
1595 } | 1595 } |
1596 } | 1596 } |
1597 } | 1597 } |
1598 } | 1598 } |
1599 | 1599 |
1600 void | 1600 void |
1601 View::progressCheckStalledTimerElapsed() | 1601 View::progressCheckStalledTimerElapsed() |
1618 | 1618 |
1619 int | 1619 int |
1620 View::getProgressBarWidth() const | 1620 View::getProgressBarWidth() const |
1621 { | 1621 { |
1622 for (ProgressMap::const_iterator i = m_progressBars.begin(); | 1622 for (ProgressMap::const_iterator i = m_progressBars.begin(); |
1623 i != m_progressBars.end(); ++i) { | 1623 i != m_progressBars.end(); ++i) { |
1624 if (i->second.bar && i->second.bar->isVisible()) { | 1624 if (i->second.bar && i->second.bar->isVisible()) { |
1625 return i->second.bar->width(); | 1625 return i->second.bar->width(); |
1626 } | 1626 } |
1627 } | 1627 } |
1628 | 1628 |
1658 { | 1658 { |
1659 // Profiler prof("View::paintEvent", false); | 1659 // Profiler prof("View::paintEvent", false); |
1660 // cerr << "View::paintEvent: centre frame is " << m_centreFrame << endl; | 1660 // cerr << "View::paintEvent: centre frame is " << m_centreFrame << endl; |
1661 | 1661 |
1662 if (m_layerStack.empty()) { | 1662 if (m_layerStack.empty()) { |
1663 QFrame::paintEvent(e); | 1663 QFrame::paintEvent(e); |
1664 return; | 1664 return; |
1665 } | 1665 } |
1666 | 1666 |
1667 // ensure our constraints are met | 1667 // ensure our constraints are met |
1668 | 1668 |
1669 /*!!! Should we do this only if we have layers that can't support other | 1669 /*!!! Should we do this only if we have layers that can't support other |
1670 zoom levels? | 1670 zoom levels? |
1671 | 1671 |
1672 m_zoomLevel = getZoomConstraintBlockSize(m_zoomLevel, | 1672 m_zoomLevel = getZoomConstraintBlockSize(m_zoomLevel, |
1673 ZoomConstraint::RoundUp); | 1673 ZoomConstraint::RoundUp); |
1674 */ | 1674 */ |
1675 | 1675 |
1676 QPainter paint; | 1676 QPainter paint; |
1677 bool repaintCache = false; | 1677 bool repaintCache = false; |
1678 bool paintedCacheRect = false; | 1678 bool paintedCacheRect = false; |
1679 | 1679 |
1680 QRect cacheRect(rect()); | 1680 QRect cacheRect(rect()); |
1681 | 1681 |
1682 if (e) { | 1682 if (e) { |
1683 cacheRect &= e->rect(); | 1683 cacheRect &= e->rect(); |
1684 #ifdef DEBUG_VIEW_WIDGET_PAINT | 1684 #ifdef DEBUG_VIEW_WIDGET_PAINT |
1685 cerr << "paint rect " << cacheRect.width() << "x" << cacheRect.height() | 1685 cerr << "paint rect " << cacheRect.width() << "x" << cacheRect.height() |
1686 << ", my rect " << width() << "x" << height() << endl; | 1686 << ", my rect " << width() << "x" << height() << endl; |
1687 #endif | 1687 #endif |
1688 } | 1688 } |
1689 | 1689 |
1690 QRect nonCacheRect(cacheRect); | 1690 QRect nonCacheRect(cacheRect); |
1691 | 1691 |
1732 selectionCacheable = false; | 1732 selectionCacheable = false; |
1733 } | 1733 } |
1734 | 1734 |
1735 #ifdef DEBUG_VIEW_WIDGET_PAINT | 1735 #ifdef DEBUG_VIEW_WIDGET_PAINT |
1736 cerr << "View(" << this << ")::paintEvent: have " << scrollables.size() | 1736 cerr << "View(" << this << ")::paintEvent: have " << scrollables.size() |
1737 << " scrollable back layers and " << nonScrollables.size() | 1737 << " scrollable back layers and " << nonScrollables.size() |
1738 << " non-scrollable front layers" << endl; | 1738 << " non-scrollable front layers" << endl; |
1739 cerr << "haveSelections " << haveSelections << ", selectionCacheable " | 1739 cerr << "haveSelections " << haveSelections << ", selectionCacheable " |
1740 << selectionCacheable << ", m_selectionCached " << m_selectionCached << endl; | 1740 << selectionCacheable << ", m_selectionCached " << m_selectionCached << endl; |
1741 #endif | 1741 #endif |
1742 | 1742 |
1743 if (layersChanged || scrollables.empty() || | 1743 if (layersChanged || scrollables.empty() || |
1744 (haveSelections && (selectionCacheable != m_selectionCached))) { | 1744 (haveSelections && (selectionCacheable != m_selectionCached))) { |
1745 delete m_cache; | 1745 delete m_cache; |
1746 m_cache = 0; | 1746 m_cache = 0; |
1747 m_selectionCached = false; | 1747 m_selectionCached = false; |
1748 } | 1748 } |
1749 | 1749 |
1750 QSize scaledCacheSize(scaledSize(size(), dpratio)); | 1750 QSize scaledCacheSize(scaledSize(size(), dpratio)); |
1751 QRect scaledCacheRect(scaledRect(cacheRect, dpratio)); | 1751 QRect scaledCacheRect(scaledRect(cacheRect, dpratio)); |
1752 | 1752 |
1760 #ifdef DEBUG_VIEW_WIDGET_PAINT | 1760 #ifdef DEBUG_VIEW_WIDGET_PAINT |
1761 cerr << "View(" << this << "): cache " << m_cache << ", cache zoom " | 1761 cerr << "View(" << this << "): cache " << m_cache << ", cache zoom " |
1762 << m_cacheZoomLevel << ", zoom " << m_zoomLevel << endl; | 1762 << m_cacheZoomLevel << ", zoom " << m_zoomLevel << endl; |
1763 #endif | 1763 #endif |
1764 | 1764 |
1765 if (!m_cache || | 1765 if (!m_cache || |
1766 m_cacheZoomLevel != m_zoomLevel || | 1766 m_cacheZoomLevel != m_zoomLevel || |
1767 scaledCacheSize != m_cache->size()) { | 1767 scaledCacheSize != m_cache->size()) { |
1768 | 1768 |
1769 // cache is not valid | 1769 // cache is not valid |
1770 | 1770 |
1771 if (cacheRect.width() < width()/10) { | 1771 if (cacheRect.width() < width()/10) { |
1772 delete m_cache; | 1772 delete m_cache; |
1773 m_cache = 0; | 1773 m_cache = 0; |
1774 #ifdef DEBUG_VIEW_WIDGET_PAINT | 1774 #ifdef DEBUG_VIEW_WIDGET_PAINT |
1775 cerr << "View(" << this << ")::paintEvent: small repaint, not bothering to recreate cache" << endl; | 1775 cerr << "View(" << this << ")::paintEvent: small repaint, not bothering to recreate cache" << endl; |
1776 #endif | 1776 #endif |
1777 } else { | 1777 } else { |
1778 delete m_cache; | 1778 delete m_cache; |
1779 m_cache = new QPixmap(scaledCacheSize); | 1779 m_cache = new QPixmap(scaledCacheSize); |
1780 #ifdef DEBUG_VIEW_WIDGET_PAINT | 1780 #ifdef DEBUG_VIEW_WIDGET_PAINT |
1781 cerr << "View(" << this << ")::paintEvent: recreated cache" << endl; | 1781 cerr << "View(" << this << ")::paintEvent: recreated cache" << endl; |
1782 #endif | 1782 #endif |
1783 cacheRect = rect(); | 1783 cacheRect = rect(); |
1784 repaintCache = true; | 1784 repaintCache = true; |
1785 } | 1785 } |
1786 | 1786 |
1787 } else if (m_cacheCentreFrame != m_centreFrame) { | 1787 } else if (m_cacheCentreFrame != m_centreFrame) { |
1788 | 1788 |
1789 int dx = | 1789 int dx = |
1790 getXForFrame(m_cacheCentreFrame) - | 1790 getXForFrame(m_cacheCentreFrame) - |
1791 getXForFrame(m_centreFrame); | 1791 getXForFrame(m_centreFrame); |
1792 | 1792 |
1793 if (dx > -width() && dx < width()) { | 1793 if (dx > -width() && dx < width()) { |
1794 static QPixmap *tmpPixmap = 0; | 1794 static QPixmap *tmpPixmap = 0; |
1795 if (!tmpPixmap || tmpPixmap->size() != scaledCacheSize) { | 1795 if (!tmpPixmap || tmpPixmap->size() != scaledCacheSize) { |
1796 delete tmpPixmap; | 1796 delete tmpPixmap; |
1797 tmpPixmap = new QPixmap(scaledCacheSize); | 1797 tmpPixmap = new QPixmap(scaledCacheSize); |
1798 } | 1798 } |
1799 paint.begin(tmpPixmap); | 1799 paint.begin(tmpPixmap); |
1800 paint.drawPixmap(0, 0, *m_cache); | 1800 paint.drawPixmap(0, 0, *m_cache); |
1801 paint.end(); | 1801 paint.end(); |
1802 paint.begin(m_cache); | 1802 paint.begin(m_cache); |
1803 paint.drawPixmap(dx, 0, *tmpPixmap); | 1803 paint.drawPixmap(dx, 0, *tmpPixmap); |
1804 paint.end(); | 1804 paint.end(); |
1805 if (dx < 0) { | 1805 if (dx < 0) { |
1806 cacheRect = QRect(width() + dx, 0, -dx, height()); | 1806 cacheRect = QRect(width() + dx, 0, -dx, height()); |
1807 } else { | 1807 } else { |
1808 cacheRect = QRect(0, 0, dx, height()); | 1808 cacheRect = QRect(0, 0, dx, height()); |
1809 } | 1809 } |
1810 #ifdef DEBUG_VIEW_WIDGET_PAINT | 1810 #ifdef DEBUG_VIEW_WIDGET_PAINT |
1811 cerr << "View(" << this << ")::paintEvent: scrolled cache by " << dx << endl; | 1811 cerr << "View(" << this << ")::paintEvent: scrolled cache by " << dx << endl; |
1812 #endif | 1812 #endif |
1813 } else { | 1813 } else { |
1814 cacheRect = rect(); | 1814 cacheRect = rect(); |
1815 #ifdef DEBUG_VIEW_WIDGET_PAINT | 1815 #ifdef DEBUG_VIEW_WIDGET_PAINT |
1816 cerr << "View(" << this << ")::paintEvent: scrolling too far" << endl; | 1816 cerr << "View(" << this << ")::paintEvent: scrolling too far" << endl; |
1817 #endif | 1817 #endif |
1818 } | 1818 } |
1819 repaintCache = true; | 1819 repaintCache = true; |
1820 | 1820 |
1821 } else { | 1821 } else { |
1822 #ifdef DEBUG_VIEW_WIDGET_PAINT | 1822 #ifdef DEBUG_VIEW_WIDGET_PAINT |
1823 cerr << "View(" << this << ")::paintEvent: cache is good" << endl; | 1823 cerr << "View(" << this << ")::paintEvent: cache is good" << endl; |
1824 #endif | 1824 #endif |
1825 paint.begin(m_buffer); | 1825 paint.begin(m_buffer); |
1826 paint.drawPixmap(scaledCacheRect, *m_cache, scaledCacheRect); | 1826 paint.drawPixmap(scaledCacheRect, *m_cache, scaledCacheRect); |
1827 paint.end(); | 1827 paint.end(); |
1828 QFrame::paintEvent(e); | 1828 QFrame::paintEvent(e); |
1829 paintedCacheRect = true; | 1829 paintedCacheRect = true; |
1830 } | 1830 } |
1831 | 1831 |
1832 m_cacheCentreFrame = m_centreFrame; | 1832 m_cacheCentreFrame = m_centreFrame; |
1833 m_cacheZoomLevel = m_zoomLevel; | 1833 m_cacheZoomLevel = m_zoomLevel; |
1834 } | 1834 } |
1835 | 1835 |
1836 #ifdef DEBUG_VIEW_WIDGET_PAINT | 1836 #ifdef DEBUG_VIEW_WIDGET_PAINT |
1837 // cerr << "View(" << this << ")::paintEvent: cacheRect " << cacheRect << ", nonCacheRect " << (nonCacheRect | cacheRect) << ", repaintCache " << repaintCache << ", paintedCacheRect " << paintedCacheRect << endl; | 1837 // cerr << "View(" << this << ")::paintEvent: cacheRect " << cacheRect << ", nonCacheRect " << (nonCacheRect | cacheRect) << ", repaintCache " << repaintCache << ", paintedCacheRect " << paintedCacheRect << endl; |
1838 #endif | 1838 #endif |
1843 | 1843 |
1844 if (!paintedCacheRect) { | 1844 if (!paintedCacheRect) { |
1845 | 1845 |
1846 QRect rectToPaint; | 1846 QRect rectToPaint; |
1847 | 1847 |
1848 if (repaintCache) { | 1848 if (repaintCache) { |
1849 paint.begin(m_cache); | 1849 paint.begin(m_cache); |
1850 rectToPaint = scaledCacheRect; | 1850 rectToPaint = scaledCacheRect; |
1851 } else { | 1851 } else { |
1852 paint.begin(m_buffer); | 1852 paint.begin(m_buffer); |
1853 rectToPaint = scaledCacheRect; | 1853 rectToPaint = scaledCacheRect; |
1854 } | 1854 } |
1855 | 1855 |
1856 setPaintFont(paint); | 1856 setPaintFont(paint); |
1857 paint.setClipRect(rectToPaint); | 1857 paint.setClipRect(rectToPaint); |
1858 | 1858 |
1859 paint.setPen(getBackground()); | 1859 paint.setPen(getBackground()); |
1860 paint.setBrush(getBackground()); | 1860 paint.setBrush(getBackground()); |
1861 paint.drawRect(rectToPaint); | 1861 paint.drawRect(rectToPaint); |
1862 | 1862 |
1863 paint.setPen(getForeground()); | 1863 paint.setPen(getForeground()); |
1864 paint.setBrush(Qt::NoBrush); | 1864 paint.setBrush(Qt::NoBrush); |
1865 | 1865 |
1866 for (LayerList::iterator i = scrollables.begin(); i != scrollables.end(); ++i) { | 1866 for (LayerList::iterator i = scrollables.begin(); i != scrollables.end(); ++i) { |
1867 paint.setRenderHint(QPainter::Antialiasing, false); | 1867 paint.setRenderHint(QPainter::Antialiasing, false); |
1868 paint.save(); | 1868 paint.save(); |
1869 #ifdef DEBUG_VIEW_WIDGET_PAINT | 1869 #ifdef DEBUG_VIEW_WIDGET_PAINT |
1870 cerr << "Painting scrollable layer " << *i << " using proxy with repaintCache = " << repaintCache << ", dpratio = " << dpratio << ", rectToPaint = " << rectToPaint.x() << "," << rectToPaint.y() << " " << rectToPaint.width() << "x" << rectToPaint.height() << endl; | 1870 cerr << "Painting scrollable layer " << *i << " using proxy with repaintCache = " << repaintCache << ", dpratio = " << dpratio << ", rectToPaint = " << rectToPaint.x() << "," << rectToPaint.y() << " " << rectToPaint.width() << "x" << rectToPaint.height() << endl; |
1871 #endif | 1871 #endif |
1872 (*i)->paint(&proxy, paint, rectToPaint); | 1872 (*i)->paint(&proxy, paint, rectToPaint); |
1873 paint.restore(); | 1873 paint.restore(); |
1874 } | 1874 } |
1875 | 1875 |
1876 if (haveSelections && selectionCacheable) { | 1876 if (haveSelections && selectionCacheable) { |
1877 drawSelections(paint); | 1877 drawSelections(paint); |
1878 m_selectionCached = repaintCache; | 1878 m_selectionCached = repaintCache; |
1879 } | 1879 } |
1880 | 1880 |
1881 paint.end(); | 1881 paint.end(); |
1882 | 1882 |
1883 if (repaintCache) { | 1883 if (repaintCache) { |
1884 cacheRect |= (e ? e->rect() : rect()); | 1884 cacheRect |= (e ? e->rect() : rect()); |
1885 scaledCacheRect = scaledRect(cacheRect, dpratio); | 1885 scaledCacheRect = scaledRect(cacheRect, dpratio); |
1886 paint.begin(m_buffer); | 1886 paint.begin(m_buffer); |
1887 paint.drawPixmap(scaledCacheRect, *m_cache, scaledCacheRect); | 1887 paint.drawPixmap(scaledCacheRect, *m_cache, scaledCacheRect); |
1888 paint.end(); | 1888 paint.end(); |
1889 } | 1889 } |
1890 } | 1890 } |
1891 | 1891 |
1892 // Now non-cacheable items. We always need to redraw the | 1892 // Now non-cacheable items. We always need to redraw the |
1893 // non-cacheable items across at least the area we drew of the | 1893 // non-cacheable items across at least the area we drew of the |
1894 // cacheable items. | 1894 // cacheable items. |
1901 paint.setClipRect(scaledNonCacheRect); | 1901 paint.setClipRect(scaledNonCacheRect); |
1902 setPaintFont(paint); | 1902 setPaintFont(paint); |
1903 if (scrollables.empty()) { | 1903 if (scrollables.empty()) { |
1904 paint.setPen(getBackground()); | 1904 paint.setPen(getBackground()); |
1905 paint.setBrush(getBackground()); | 1905 paint.setBrush(getBackground()); |
1906 paint.drawRect(scaledNonCacheRect); | 1906 paint.drawRect(scaledNonCacheRect); |
1907 } | 1907 } |
1908 | 1908 |
1909 paint.setPen(getForeground()); | 1909 paint.setPen(getForeground()); |
1910 paint.setBrush(Qt::NoBrush); | 1910 paint.setBrush(Qt::NoBrush); |
1911 | 1911 |
1912 for (LayerList::iterator i = nonScrollables.begin(); i != nonScrollables.end(); ++i) { | 1912 for (LayerList::iterator i = nonScrollables.begin(); i != nonScrollables.end(); ++i) { |
1913 // Profiler profiler2("View::paintEvent non-cacheable"); | 1913 // Profiler profiler2("View::paintEvent non-cacheable"); |
1914 #ifdef DEBUG_VIEW_WIDGET_PAINT | 1914 #ifdef DEBUG_VIEW_WIDGET_PAINT |
1915 cerr << "Painting non-scrollable layer " << *i << " without proxy with repaintCache = " << repaintCache << ", dpratio = " << dpratio << ", rectToPaint = " << nonCacheRect.x() << "," << nonCacheRect.y() << " " << nonCacheRect.width() << "x" << nonCacheRect.height() << endl; | 1915 cerr << "Painting non-scrollable layer " << *i << " without proxy with repaintCache = " << repaintCache << ", dpratio = " << dpratio << ", rectToPaint = " << nonCacheRect.x() << "," << nonCacheRect.y() << " " << nonCacheRect.width() << "x" << nonCacheRect.height() << endl; |
1916 #endif | 1916 #endif |
1917 (*i)->paint(&proxy, paint, scaledNonCacheRect); | 1917 (*i)->paint(&proxy, paint, scaledNonCacheRect); |
1918 } | 1918 } |
1919 | 1919 |
1920 paint.end(); | 1920 paint.end(); |
1921 | 1921 |
1922 paint.begin(this); | 1922 paint.begin(this); |
1923 QRect finalPaintRect = e ? e->rect() : rect(); | 1923 QRect finalPaintRect = e ? e->rect() : rect(); |
1924 paint.drawPixmap(finalPaintRect, *m_buffer, scaledRect(finalPaintRect, dpratio)); | 1924 paint.drawPixmap(finalPaintRect, *m_buffer, scaledRect(finalPaintRect, dpratio)); |
1926 | 1926 |
1927 paint.begin(this); | 1927 paint.begin(this); |
1928 setPaintFont(paint); | 1928 setPaintFont(paint); |
1929 if (e) paint.setClipRect(e->rect()); | 1929 if (e) paint.setClipRect(e->rect()); |
1930 if (!m_selectionCached) { | 1930 if (!m_selectionCached) { |
1931 drawSelections(paint); | 1931 drawSelections(paint); |
1932 } | 1932 } |
1933 paint.end(); | 1933 paint.end(); |
1934 | 1934 |
1935 bool showPlayPointer = true; | 1935 bool showPlayPointer = true; |
1936 if (m_followPlay == PlaybackScrollContinuous) { | 1936 if (m_followPlay == PlaybackScrollContinuous) { |
1948 } | 1948 } |
1949 } | 1949 } |
1950 | 1950 |
1951 if (showPlayPointer) { | 1951 if (showPlayPointer) { |
1952 | 1952 |
1953 paint.begin(this); | 1953 paint.begin(this); |
1954 | 1954 |
1955 int playx = getXForFrame(m_playPointerFrame); | 1955 int playx = getXForFrame(m_playPointerFrame); |
1956 | 1956 |
1957 paint.setPen(getForeground()); | 1957 paint.setPen(getForeground()); |
1958 paint.drawLine(playx - 1, 0, playx - 1, height() - 1); | 1958 paint.drawLine(playx - 1, 0, playx - 1, height() - 1); |
1960 paint.drawPoint(playx, 0); | 1960 paint.drawPoint(playx, 0); |
1961 paint.drawPoint(playx, height() - 1); | 1961 paint.drawPoint(playx, height() - 1); |
1962 paint.setPen(getBackground()); | 1962 paint.setPen(getBackground()); |
1963 paint.drawLine(playx, 1, playx, height() - 2); | 1963 paint.drawLine(playx, 1, playx, height() - 2); |
1964 | 1964 |
1965 paint.end(); | 1965 paint.end(); |
1966 } | 1966 } |
1967 | 1967 |
1968 QFrame::paintEvent(e); | 1968 QFrame::paintEvent(e); |
1969 } | 1969 } |
1970 | 1970 |
1974 if (!hasTopLayerTimeXAxis()) return; | 1974 if (!hasTopLayerTimeXAxis()) return; |
1975 | 1975 |
1976 MultiSelection::SelectionList selections; | 1976 MultiSelection::SelectionList selections; |
1977 | 1977 |
1978 if (m_manager) { | 1978 if (m_manager) { |
1979 selections = m_manager->getSelections(); | 1979 selections = m_manager->getSelections(); |
1980 if (m_manager->haveInProgressSelection()) { | 1980 if (m_manager->haveInProgressSelection()) { |
1981 bool exclusive; | 1981 bool exclusive; |
1982 Selection inProgressSelection = | 1982 Selection inProgressSelection = |
1983 m_manager->getInProgressSelection(exclusive); | 1983 m_manager->getInProgressSelection(exclusive); |
1984 if (exclusive) selections.clear(); | 1984 if (exclusive) selections.clear(); |
1985 selections.insert(inProgressSelection); | 1985 selections.insert(inProgressSelection); |
1986 } | 1986 } |
1987 } | 1987 } |
1988 | 1988 |
1989 paint.save(); | 1989 paint.save(); |
1990 | 1990 |
1991 bool translucent = !areLayerColoursSignificant(); | 1991 bool translucent = !areLayerColoursSignificant(); |
2001 QPoint localPos; | 2001 QPoint localPos; |
2002 sv_frame_t illuminateFrame = -1; | 2002 sv_frame_t illuminateFrame = -1; |
2003 bool closeToLeft, closeToRight; | 2003 bool closeToLeft, closeToRight; |
2004 | 2004 |
2005 if (shouldIlluminateLocalSelection(localPos, closeToLeft, closeToRight)) { | 2005 if (shouldIlluminateLocalSelection(localPos, closeToLeft, closeToRight)) { |
2006 illuminateFrame = getFrameForX(localPos.x()); | 2006 illuminateFrame = getFrameForX(localPos.x()); |
2007 } | 2007 } |
2008 | 2008 |
2009 const QFontMetrics &metrics = paint.fontMetrics(); | 2009 const QFontMetrics &metrics = paint.fontMetrics(); |
2010 | 2010 |
2011 for (MultiSelection::SelectionList::iterator i = selections.begin(); | 2011 for (MultiSelection::SelectionList::iterator i = selections.begin(); |
2012 i != selections.end(); ++i) { | 2012 i != selections.end(); ++i) { |
2013 | 2013 |
2014 int p0 = getXForFrame(alignFromReference(i->getStartFrame())); | 2014 int p0 = getXForFrame(alignFromReference(i->getStartFrame())); |
2015 int p1 = getXForFrame(alignFromReference(i->getEndFrame())); | 2015 int p1 = getXForFrame(alignFromReference(i->getEndFrame())); |
2016 | 2016 |
2017 if (p1 < 0 || p0 > width()) continue; | 2017 if (p1 < 0 || p0 > width()) continue; |
2018 | 2018 |
2019 #ifdef DEBUG_VIEW_WIDGET_PAINT | 2019 #ifdef DEBUG_VIEW_WIDGET_PAINT |
2020 SVDEBUG << "View::drawSelections: " << p0 << ",-1 [" << (p1-p0) << "x" << (height()+1) << "]" << endl; | 2020 SVDEBUG << "View::drawSelections: " << p0 << ",-1 [" << (p1-p0) << "x" << (height()+1) << "]" << endl; |
2021 #endif | 2021 #endif |
2022 | 2022 |
2023 bool illuminateThis = | 2023 bool illuminateThis = |
2024 (illuminateFrame >= 0 && i->contains(illuminateFrame)); | 2024 (illuminateFrame >= 0 && i->contains(illuminateFrame)); |
2025 | 2025 |
2026 paint.setPen(QColor(150, 150, 255)); | 2026 paint.setPen(QColor(150, 150, 255)); |
2027 | 2027 |
2028 if (translucent && shouldLabelSelections()) { | 2028 if (translucent && shouldLabelSelections()) { |
2029 paint.drawRect(p0, -1, p1 - p0, height() + 1); | 2029 paint.drawRect(p0, -1, p1 - p0, height() + 1); |
2030 } else { | 2030 } else { |
2031 // Make the top & bottom lines of the box visible if we | 2031 // Make the top & bottom lines of the box visible if we |
2033 // particular logic to this, it's just a question of what | 2033 // particular logic to this, it's just a question of what |
2034 // I happen to think looks nice. | 2034 // I happen to think looks nice. |
2035 paint.drawRect(p0, 0, p1 - p0, height() - 1); | 2035 paint.drawRect(p0, 0, p1 - p0, height() - 1); |
2036 } | 2036 } |
2037 | 2037 |
2038 if (illuminateThis) { | 2038 if (illuminateThis) { |
2039 paint.save(); | 2039 paint.save(); |
2040 paint.setPen(QPen(getForeground(), 2)); | 2040 paint.setPen(QPen(getForeground(), 2)); |
2041 if (closeToLeft) { | 2041 if (closeToLeft) { |
2042 paint.drawLine(p0, 1, p1, 1); | 2042 paint.drawLine(p0, 1, p1, 1); |
2043 paint.drawLine(p0, 0, p0, height()); | 2043 paint.drawLine(p0, 0, p0, height()); |
2044 paint.drawLine(p0, height() - 1, p1, height() - 1); | 2044 paint.drawLine(p0, height() - 1, p1, height() - 1); |
2045 } else if (closeToRight) { | 2045 } else if (closeToRight) { |
2046 paint.drawLine(p0, 1, p1, 1); | 2046 paint.drawLine(p0, 1, p1, 1); |
2047 paint.drawLine(p1, 0, p1, height()); | 2047 paint.drawLine(p1, 0, p1, height()); |
2048 paint.drawLine(p0, height() - 1, p1, height() - 1); | 2048 paint.drawLine(p0, height() - 1, p1, height() - 1); |
2049 } else { | 2049 } else { |
2050 paint.setBrush(Qt::NoBrush); | 2050 paint.setBrush(Qt::NoBrush); |
2051 paint.drawRect(p0, 1, p1 - p0, height() - 2); | 2051 paint.drawRect(p0, 1, p1 - p0, height() - 2); |
2052 } | 2052 } |
2053 paint.restore(); | 2053 paint.restore(); |
2054 } | 2054 } |
2055 | 2055 |
2056 if (sampleRate && shouldLabelSelections() && m_manager && | 2056 if (sampleRate && shouldLabelSelections() && m_manager && |
2057 m_manager->shouldShowSelectionExtents()) { | 2057 m_manager->shouldShowSelectionExtents()) { |
2058 | 2058 |
2059 QString startText = QString("%1 / %2") | 2059 QString startText = QString("%1 / %2") |
2060 .arg(QString::fromStdString | 2060 .arg(QString::fromStdString |
2061 (RealTime::frame2RealTime | 2061 (RealTime::frame2RealTime |
2062 (i->getStartFrame(), sampleRate).toText(true))) | 2062 (i->getStartFrame(), sampleRate).toText(true))) |
2063 .arg(i->getStartFrame()); | 2063 .arg(i->getStartFrame()); |
2064 | 2064 |
2065 QString endText = QString(" %1 / %2") | 2065 QString endText = QString(" %1 / %2") |
2066 .arg(QString::fromStdString | 2066 .arg(QString::fromStdString |
2067 (RealTime::frame2RealTime | 2067 (RealTime::frame2RealTime |
2068 (i->getEndFrame(), sampleRate).toText(true))) | 2068 (i->getEndFrame(), sampleRate).toText(true))) |
2069 .arg(i->getEndFrame()); | 2069 .arg(i->getEndFrame()); |
2070 | 2070 |
2071 QString durationText = QString("(%1 / %2) ") | 2071 QString durationText = QString("(%1 / %2) ") |
2072 .arg(QString::fromStdString | 2072 .arg(QString::fromStdString |
2073 (RealTime::frame2RealTime | 2073 (RealTime::frame2RealTime |
2074 (i->getEndFrame() - i->getStartFrame(), sampleRate) | 2074 (i->getEndFrame() - i->getStartFrame(), sampleRate) |
2075 .toText(true))) | 2075 .toText(true))) |
2076 .arg(i->getEndFrame() - i->getStartFrame()); | 2076 .arg(i->getEndFrame() - i->getStartFrame()); |
2077 | 2077 |
2078 int sw = metrics.width(startText), | 2078 int sw = metrics.width(startText), |
2079 ew = metrics.width(endText), | 2079 ew = metrics.width(endText), |
2080 dw = metrics.width(durationText); | 2080 dw = metrics.width(durationText); |
2081 | 2081 |
2082 int sy = metrics.ascent() + metrics.height() + 4; | 2082 int sy = metrics.ascent() + metrics.height() + 4; |
2083 int ey = sy; | 2083 int ey = sy; |
2084 int dy = sy + metrics.height(); | 2084 int dy = sy + metrics.height(); |
2085 | 2085 |
2086 int sx = p0 + 2; | 2086 int sx = p0 + 2; |
2087 int ex = sx; | 2087 int ex = sx; |
2088 int dx = sx; | 2088 int dx = sx; |
2089 | 2089 |
2090 bool durationBothEnds = true; | 2090 bool durationBothEnds = true; |
2091 | 2091 |
2092 if (sw + ew > (p1 - p0)) { | 2092 if (sw + ew > (p1 - p0)) { |
2093 ey += metrics.height(); | 2093 ey += metrics.height(); |
2094 dy += metrics.height(); | 2094 dy += metrics.height(); |
2095 durationBothEnds = false; | 2095 durationBothEnds = false; |
2096 } | 2096 } |
2097 | 2097 |
2098 if (ew < (p1 - p0)) { | 2098 if (ew < (p1 - p0)) { |
2099 ex = p1 - 2 - ew; | 2099 ex = p1 - 2 - ew; |
2100 } | 2100 } |
2101 | 2101 |
2102 if (dw < (p1 - p0)) { | 2102 if (dw < (p1 - p0)) { |
2103 dx = p1 - 2 - dw; | 2103 dx = p1 - 2 - dw; |
2104 } | 2104 } |
2105 | 2105 |
2106 PaintAssistant::drawVisibleText(this, paint, sx, sy, startText, | 2106 PaintAssistant::drawVisibleText(this, paint, sx, sy, startText, |
2107 PaintAssistant::OutlinedText); | 2107 PaintAssistant::OutlinedText); |
2108 PaintAssistant::drawVisibleText(this, paint, ex, ey, endText, | 2108 PaintAssistant::drawVisibleText(this, paint, ex, ey, endText, |
2109 PaintAssistant::OutlinedText); | 2109 PaintAssistant::OutlinedText); |
2111 PaintAssistant::OutlinedText); | 2111 PaintAssistant::OutlinedText); |
2112 if (durationBothEnds) { | 2112 if (durationBothEnds) { |
2113 PaintAssistant::drawVisibleText(this, paint, sx, dy, durationText, | 2113 PaintAssistant::drawVisibleText(this, paint, sx, dy, durationText, |
2114 PaintAssistant::OutlinedText); | 2114 PaintAssistant::OutlinedText); |
2115 } | 2115 } |
2116 } | 2116 } |
2117 } | 2117 } |
2118 | 2118 |
2119 paint.restore(); | 2119 paint.restore(); |
2120 } | 2120 } |
2121 | 2121 |
2429 QRect chunk(0, 0, width(), height()); | 2429 QRect chunk(0, 0, width(), height()); |
2430 | 2430 |
2431 paint.setPen(getBackground()); | 2431 paint.setPen(getBackground()); |
2432 paint.setBrush(getBackground()); | 2432 paint.setBrush(getBackground()); |
2433 | 2433 |
2434 paint.drawRect(QRect(xorigin + x, 0, width(), height())); | 2434 paint.drawRect(QRect(xorigin + x, 0, width(), height())); |
2435 | 2435 |
2436 paint.setPen(getForeground()); | 2436 paint.setPen(getForeground()); |
2437 paint.setBrush(Qt::NoBrush); | 2437 paint.setBrush(Qt::NoBrush); |
2438 | 2438 |
2439 for (LayerList::iterator i = m_layerStack.begin(); | 2439 for (LayerList::iterator i = m_layerStack.begin(); |
2440 i != m_layerStack.end(); ++i) { | 2440 i != m_layerStack.end(); ++i) { |
2441 if (!((*i)->isLayerDormant(this))){ | 2441 if (!((*i)->isLayerDormant(this))){ |
2442 | 2442 |
2443 paint.setRenderHint(QPainter::Antialiasing, false); | 2443 paint.setRenderHint(QPainter::Antialiasing, false); |
2444 | 2444 |
2453 | 2453 |
2454 (*i)->setSynchronousPainting(false); | 2454 (*i)->setSynchronousPainting(false); |
2455 | 2455 |
2456 paint.restore(); | 2456 paint.restore(); |
2457 } | 2457 } |
2458 } | 2458 } |
2459 } | 2459 } |
2460 | 2460 |
2461 m_centreFrame = origCentreFrame; | 2461 m_centreFrame = origCentreFrame; |
2462 update(); | 2462 update(); |
2463 return true; | 2463 return true; |
2549 "zoom=\"%2\" " | 2549 "zoom=\"%2\" " |
2550 "followPan=\"%3\" " | 2550 "followPan=\"%3\" " |
2551 "followZoom=\"%4\" " | 2551 "followZoom=\"%4\" " |
2552 "tracking=\"%5\" " | 2552 "tracking=\"%5\" " |
2553 " %6>\n") | 2553 " %6>\n") |
2554 .arg(m_centreFrame) | 2554 .arg(m_centreFrame) |
2555 .arg(m_zoomLevel) | 2555 .arg(m_zoomLevel) |
2556 .arg(m_followPan) | 2556 .arg(m_followPan) |
2557 .arg(m_followZoom) | 2557 .arg(m_followZoom) |
2558 .arg(m_followPlay == PlaybackScrollContinuous ? "scroll" : | 2558 .arg(m_followPlay == PlaybackScrollContinuous ? "scroll" : |
2559 m_followPlay == PlaybackScrollPageWithCentre ? "page" : | 2559 m_followPlay == PlaybackScrollPageWithCentre ? "page" : |
2560 m_followPlay == PlaybackScrollPage ? "daw" : | 2560 m_followPlay == PlaybackScrollPage ? "daw" : |
2561 "ignore") | 2561 "ignore") |
2562 .arg(extraAttributes); | 2562 .arg(extraAttributes); |
2563 | 2563 |
2564 for (int i = 0; i < (int)m_fixedOrderLayers.size(); ++i) { | 2564 for (int i = 0; i < (int)m_fixedOrderLayers.size(); ++i) { |
2565 bool visible = !m_fixedOrderLayers[i]->isLayerDormant(this); | 2565 bool visible = !m_fixedOrderLayers[i]->isLayerDormant(this); |
2566 m_fixedOrderLayers[i]->toBriefXml(stream, indent + " ", | 2566 m_fixedOrderLayers[i]->toBriefXml(stream, indent + " ", |
2567 QString("visible=\"%1\"") | 2567 QString("visible=\"%1\"") |
2574 ViewPropertyContainer::ViewPropertyContainer(View *v) : | 2574 ViewPropertyContainer::ViewPropertyContainer(View *v) : |
2575 m_v(v) | 2575 m_v(v) |
2576 { | 2576 { |
2577 // cerr << "ViewPropertyContainer: " << this << " is owned by View " << v << endl; | 2577 // cerr << "ViewPropertyContainer: " << this << " is owned by View " << v << endl; |
2578 connect(m_v, SIGNAL(propertyChanged(PropertyContainer::PropertyName)), | 2578 connect(m_v, SIGNAL(propertyChanged(PropertyContainer::PropertyName)), |
2579 this, SIGNAL(propertyChanged(PropertyContainer::PropertyName))); | 2579 this, SIGNAL(propertyChanged(PropertyContainer::PropertyName))); |
2580 } | 2580 } |
2581 | 2581 |
2582 ViewPropertyContainer::~ViewPropertyContainer() | 2582 ViewPropertyContainer::~ViewPropertyContainer() |
2583 { | 2583 { |
2584 } | 2584 } |