Mercurial > hg > svcore
comparison base/View.cpp @ 46:5364a9d338a2
* Add Insert Instant function in main window
* Ensure selections and window geometry are saved in session file
* Add wait cursor on session file save
* Various improvements to display of texts in pane (clearer readability)
* Use commands for setting properties on layers and panes
(still need to batch up multiple sets on the same property)
* Fix failure of spectrogram to refresh when initial part became visible
* Some fixes & paint optimisations in View &c
* Make curve mode for time value layers work properly when resolution == 1
* Some vague improvements for time value layer vertical scale
author | Chris Cannam |
---|---|
date | Thu, 16 Mar 2006 18:46:00 +0000 |
parents | b11edc8b8ea0 |
children | 39ae3dee27b9 |
comparison
equal
deleted
inserted
replaced
45:b11edc8b8ea0 | 46:5364a9d338a2 |
---|---|
468 m_followZoom = f; | 468 m_followZoom = f; |
469 emit propertyContainerPropertyChanged(m_propertyContainer); | 469 emit propertyContainerPropertyChanged(m_propertyContainer); |
470 } | 470 } |
471 | 471 |
472 void | 472 void |
473 View::drawVisibleText(int x, int y, QString text, TextStyle style) | 473 View::drawVisibleText(QPainter &paint, int x, int y, QString text, TextStyle style) |
474 { | 474 { |
475 //!!! blah. | 475 if (style == OutlinedText) { |
476 | |
477 QColor origPenColour = paint.pen().color(); | |
478 QColor penColour = origPenColour; | |
479 QColor surroundColour = Qt::white; //palette().background().color(); | |
480 | |
481 if (!hasLightBackground()) { | |
482 int h, s, v; | |
483 penColour.getHsv(&h, &s, &v); | |
484 penColour = QColor::fromHsv(h, s, 255 - v); | |
485 surroundColour = Qt::black; | |
486 } | |
487 | |
488 paint.setPen(surroundColour); | |
489 | |
490 for (int dx = -1; dx <= 1; ++dx) { | |
491 for (int dy = -1; dy <= 1; ++dy) { | |
492 if (!(dx || dy)) continue; | |
493 paint.drawText(x + dx, y + dy, text); | |
494 } | |
495 } | |
496 | |
497 paint.setPen(penColour); | |
498 | |
499 paint.drawText(x, y, text); | |
500 | |
501 paint.setPen(origPenColour); | |
502 | |
503 } else { | |
504 | |
505 std::cerr << "ERROR: View::drawVisibleText: Boxed style not yet implemented!" << std::endl; | |
506 } | |
476 } | 507 } |
477 | 508 |
478 void | 509 void |
479 View::setPlaybackFollow(PlaybackFollowMode m) | 510 View::setPlaybackFollow(PlaybackFollowMode m) |
480 { | 511 { |
809 View::LayerList | 840 View::LayerList |
810 View::getScrollableBackLayers(bool testChanged, bool &changed) const | 841 View::getScrollableBackLayers(bool testChanged, bool &changed) const |
811 { | 842 { |
812 changed = false; | 843 changed = false; |
813 | 844 |
845 // We want a list of all the scrollable layers that are behind the | |
846 // backmost non-scrollable layer. | |
847 | |
814 LayerList scrollables; | 848 LayerList scrollables; |
815 for (LayerList::const_iterator i = m_layers.begin(); i != m_layers.end(); ++i) { | 849 for (LayerList::const_iterator i = m_layers.begin(); i != m_layers.end(); ++i) { |
816 if ((*i)->isLayerDormant(this)) continue; | 850 if ((*i)->isLayerDormant(this)) continue; |
851 if ((*i)->isLayerOpaque()) { | |
852 // You can't see anything behind an opaque layer! | |
853 scrollables.clear(); | |
854 } | |
817 if ((*i)->isLayerScrollable(this)) scrollables.push_back(*i); | 855 if ((*i)->isLayerScrollable(this)) scrollables.push_back(*i); |
818 else { | 856 else break; |
819 if (testChanged && scrollables != m_lastScrollableBackLayers) { | |
820 m_lastScrollableBackLayers = scrollables; | |
821 changed = true; | |
822 } | |
823 return scrollables; | |
824 } | |
825 } | |
826 | |
827 if (scrollables.size() == 1 && | |
828 dynamic_cast<TimeRulerLayer *>(*scrollables.begin())) { | |
829 | |
830 // If only the ruler is scrollable, it's not worth the bother | |
831 // -- it probably redraws as quickly as it refreshes from | |
832 // cache | |
833 scrollables.clear(); | |
834 } | 857 } |
835 | 858 |
836 if (testChanged && scrollables != m_lastScrollableBackLayers) { | 859 if (testChanged && scrollables != m_lastScrollableBackLayers) { |
837 m_lastScrollableBackLayers = scrollables; | 860 m_lastScrollableBackLayers = scrollables; |
838 changed = true; | 861 changed = true; |
848 LayerList nonScrollables; | 871 LayerList nonScrollables; |
849 | 872 |
850 // Everything in front of the first non-scrollable from the back | 873 // Everything in front of the first non-scrollable from the back |
851 // should also be considered non-scrollable | 874 // should also be considered non-scrollable |
852 | 875 |
853 size_t count = 0; | 876 bool started = false; |
877 | |
854 for (LayerList::const_iterator i = m_layers.begin(); i != m_layers.end(); ++i) { | 878 for (LayerList::const_iterator i = m_layers.begin(); i != m_layers.end(); ++i) { |
855 if ((*i)->isLayerDormant(this)) continue; | 879 if ((*i)->isLayerDormant(this)) continue; |
856 if (count < scrollables.size()) { | 880 if (!started && (*i)->isLayerScrollable(this)) { |
857 ++count; | |
858 continue; | 881 continue; |
882 } | |
883 started = true; | |
884 if ((*i)->isLayerOpaque()) { | |
885 // You can't see anything behind an opaque layer! | |
886 nonScrollables.clear(); | |
859 } | 887 } |
860 nonScrollables.push_back(*i); | 888 nonScrollables.push_back(*i); |
861 } | 889 } |
862 | 890 |
863 if (testChanged && nonScrollables != m_lastNonScrollableBackLayers) { | 891 if (testChanged && nonScrollables != m_lastNonScrollableBackLayers) { |
1004 } | 1032 } |
1005 | 1033 |
1006 QRect nonCacheRect(cacheRect); | 1034 QRect nonCacheRect(cacheRect); |
1007 | 1035 |
1008 // If not all layers are scrollable, but some of the back layers | 1036 // If not all layers are scrollable, but some of the back layers |
1009 // are, we should store only those in the cache | 1037 // are, we should store only those in the cache. |
1010 | 1038 |
1011 bool layersChanged = false; | 1039 bool layersChanged = false; |
1012 LayerList scrollables = getScrollableBackLayers(true, layersChanged); | 1040 LayerList scrollables = getScrollableBackLayers(true, layersChanged); |
1013 LayerList nonScrollables = getNonScrollableFrontLayers(true, layersChanged); | 1041 LayerList nonScrollables = getNonScrollableFrontLayers(true, layersChanged); |
1014 bool selectionCacheable = nonScrollables.empty(); | 1042 bool selectionCacheable = nonScrollables.empty(); |
1015 bool haveSelections = m_manager && !m_manager->getSelections().empty(); | 1043 bool haveSelections = m_manager && !m_manager->getSelections().empty(); |
1016 bool selectionDrawn = false; | 1044 bool selectionDrawn = false; |
1017 | 1045 |
1046 // If all the non-scrollable layers are non-opaque, then we draw | |
1047 // the selection rectangle behind them and cache it. If any are | |
1048 // opaque, however, we can't cache. | |
1049 // | |
1018 if (!selectionCacheable) { | 1050 if (!selectionCacheable) { |
1019 selectionCacheable = true; | 1051 selectionCacheable = true; |
1020 for (LayerList::const_iterator i = nonScrollables.begin(); | 1052 for (LayerList::const_iterator i = nonScrollables.begin(); |
1021 i != nonScrollables.end(); ++i) { | 1053 i != nonScrollables.end(); ++i) { |
1022 if ((*i)->isLayerOpaque()) { | 1054 if ((*i)->isLayerOpaque()) { |