Mercurial > hg > svgui
comparison view/View.cpp @ 1045:f535f6e5dbb0 alignment-simple
Merge in from SV 3.0-integration branches
author | Chris Cannam |
---|---|
date | Wed, 02 Mar 2016 17:25:27 +0000 |
parents | 4e5c1c326794 |
children | ee01a4062747 |
comparison
equal
deleted
inserted
replaced
976:f2c63ec85901 | 1045:f535f6e5dbb0 |
---|---|
18 #include "data/model/Model.h" | 18 #include "data/model/Model.h" |
19 #include "base/ZoomConstraint.h" | 19 #include "base/ZoomConstraint.h" |
20 #include "base/Profiler.h" | 20 #include "base/Profiler.h" |
21 #include "base/Pitch.h" | 21 #include "base/Pitch.h" |
22 #include "base/Preferences.h" | 22 #include "base/Preferences.h" |
23 #include "ViewProxy.h" | |
23 | 24 |
24 #include "layer/TimeRulerLayer.h" | 25 #include "layer/TimeRulerLayer.h" |
25 #include "layer/SingleColourLayer.h" | 26 #include "layer/SingleColourLayer.h" |
26 #include "data/model/PowerOfSqrtTwoZoomConstraint.h" | 27 #include "data/model/PowerOfSqrtTwoZoomConstraint.h" |
27 #include "data/model/RangeSummarisableTimeValueModel.h" | 28 #include "data/model/RangeSummarisableTimeValueModel.h" |
35 #include <QProgressDialog> | 36 #include <QProgressDialog> |
36 #include <QTextStream> | 37 #include <QTextStream> |
37 #include <QFont> | 38 #include <QFont> |
38 #include <QMessageBox> | 39 #include <QMessageBox> |
39 #include <QPushButton> | 40 #include <QPushButton> |
41 #include <QSettings> | |
40 | 42 |
41 #include <iostream> | 43 #include <iostream> |
42 #include <cassert> | 44 #include <cassert> |
43 #include <cmath> | 45 #include <cmath> |
44 | 46 |
45 #include <unistd.h> | 47 #include <unistd.h> |
46 | 48 |
47 //#define DEBUG_VIEW 1 | 49 //#define DEBUG_VIEW 1 |
48 //#define DEBUG_VIEW_WIDGET_PAINT 1 | 50 //#define DEBUG_VIEW_WIDGET_PAINT 1 |
49 | 51 |
50 | |
51 View::View(QWidget *w, bool showProgress) : | 52 View::View(QWidget *w, bool showProgress) : |
52 QFrame(w), | 53 QFrame(w), |
54 m_id(getNextId()), | |
53 m_centreFrame(0), | 55 m_centreFrame(0), |
54 m_zoomLevel(1024), | 56 m_zoomLevel(1024), |
55 m_followPan(true), | 57 m_followPan(true), |
56 m_followZoom(true), | 58 m_followZoom(true), |
57 m_followPlay(PlaybackScrollPageWithCentre), | 59 m_followPlay(PlaybackScrollPageWithCentre), |
58 m_followPlayIsDetached(false), | 60 m_followPlayIsDetached(false), |
59 m_playPointerFrame(0), | 61 m_playPointerFrame(0), |
60 m_showProgress(showProgress), | 62 m_showProgress(showProgress), |
61 m_cache(0), | 63 m_cache(0), |
64 m_buffer(0), | |
62 m_cacheCentreFrame(0), | 65 m_cacheCentreFrame(0), |
63 m_cacheZoomLevel(1024), | 66 m_cacheZoomLevel(1024), |
64 m_selectionCached(false), | 67 m_selectionCached(false), |
65 m_deleting(false), | 68 m_deleting(false), |
66 m_haveSelectedLayer(false), | 69 m_haveSelectedLayer(false), |
360 } | 363 } |
361 | 364 |
362 sv_frame_t | 365 sv_frame_t |
363 View::getFrameForX(int x) const | 366 View::getFrameForX(int x) const |
364 { | 367 { |
365 int z = m_zoomLevel; | 368 sv_frame_t z = m_zoomLevel; // nb not just int, or multiplication may overflow |
366 sv_frame_t frame = m_centreFrame - (width()/2) * z; | 369 sv_frame_t frame = m_centreFrame - (width()/2) * z; |
367 | 370 |
371 frame = (frame / z) * z; // this is start frame | |
372 frame = frame + x * z; | |
373 | |
368 #ifdef DEBUG_VIEW_WIDGET_PAINT | 374 #ifdef DEBUG_VIEW_WIDGET_PAINT |
369 SVDEBUG << "View::getFrameForX(" << x << "): z = " << z << ", m_centreFrame = " << m_centreFrame << ", width() = " << width() << ", frame = " << frame << endl; | 375 cerr << "View::getFrameForX(" << x << "): z = " << z << ", m_centreFrame = " << m_centreFrame << ", width() = " << width() << ", frame = " << frame << endl; |
370 #endif | 376 #endif |
371 | 377 |
372 frame = (frame / z) * z; // this is start frame | 378 return frame; |
373 return frame + x * z; | |
374 } | 379 } |
375 | 380 |
376 double | 381 double |
377 View::getYForFrequency(double frequency, | 382 View::getYForFrequency(double frequency, |
378 double minf, | 383 double minf, |
446 // cout << "zoom level: " << m_zoomLevel << endl; | 451 // cout << "zoom level: " << m_zoomLevel << endl; |
447 #endif | 452 #endif |
448 return m_zoomLevel; | 453 return m_zoomLevel; |
449 } | 454 } |
450 | 455 |
456 int | |
457 View::effectiveDevicePixelRatio() const | |
458 { | |
459 #ifdef Q_OS_MAC | |
460 int dpratio = devicePixelRatio(); | |
461 if (dpratio > 1) { | |
462 QSettings settings; | |
463 settings.beginGroup("Preferences"); | |
464 if (!settings.value("scaledHiDpi", true).toBool()) { | |
465 dpratio = 1; | |
466 } | |
467 settings.endGroup(); | |
468 } | |
469 return dpratio; | |
470 #else | |
471 return 1; | |
472 #endif | |
473 } | |
474 | |
451 void | 475 void |
452 View::setZoomLevel(int z) | 476 View::setZoomLevel(int z) |
453 { | 477 { |
478 int dpratio = effectiveDevicePixelRatio(); | |
479 if (z < dpratio) return; | |
454 if (z < 1) z = 1; | 480 if (z < 1) z = 1; |
455 if (m_zoomLevel != int(z)) { | 481 if (m_zoomLevel != int(z)) { |
456 m_zoomLevel = z; | 482 m_zoomLevel = z; |
457 emit zoomLevelChanged(z, m_followZoom); | 483 emit zoomLevelChanged(z, m_followZoom); |
458 update(); | 484 update(); |
1025 #endif | 1051 #endif |
1026 | 1052 |
1027 f = getAlignedPlaybackFrame(); | 1053 f = getAlignedPlaybackFrame(); |
1028 | 1054 |
1029 #ifdef DEBUG_VIEW | 1055 #ifdef DEBUG_VIEW |
1030 cerr << " -> aligned frame = " << af << endl; | 1056 cerr << " -> aligned frame = " << f << endl; |
1031 #endif | 1057 #endif |
1032 | 1058 |
1033 movePlayPointer(f); | 1059 movePlayPointer(f); |
1034 } | 1060 } |
1035 | 1061 |
1651 } | 1677 } |
1652 | 1678 |
1653 void | 1679 void |
1654 View::setPaintFont(QPainter &paint) | 1680 View::setPaintFont(QPainter &paint) |
1655 { | 1681 { |
1682 int scaleFactor = 1; | |
1683 int dpratio = effectiveDevicePixelRatio(); | |
1684 if (dpratio > 1) { | |
1685 QPaintDevice *dev = paint.device(); | |
1686 if (dynamic_cast<QPixmap *>(dev) || dynamic_cast<QImage *>(dev)) { | |
1687 scaleFactor = dpratio; | |
1688 } | |
1689 } | |
1690 | |
1656 QFont font(paint.font()); | 1691 QFont font(paint.font()); |
1657 font.setPointSize(Preferences::getInstance()->getViewFontSize()); | 1692 font.setPointSize(Preferences::getInstance()->getViewFontSize() |
1693 * scaleFactor); | |
1658 paint.setFont(font); | 1694 paint.setFont(font); |
1695 } | |
1696 | |
1697 QRect | |
1698 View::getPaintRect() const | |
1699 { | |
1700 return rect(); | |
1659 } | 1701 } |
1660 | 1702 |
1661 void | 1703 void |
1662 View::paintEvent(QPaintEvent *e) | 1704 View::paintEvent(QPaintEvent *e) |
1663 { | 1705 { |
1692 #endif | 1734 #endif |
1693 } | 1735 } |
1694 | 1736 |
1695 QRect nonCacheRect(cacheRect); | 1737 QRect nonCacheRect(cacheRect); |
1696 | 1738 |
1739 int dpratio = effectiveDevicePixelRatio(); | |
1740 | |
1697 // If not all layers are scrollable, but some of the back layers | 1741 // If not all layers are scrollable, but some of the back layers |
1698 // are, we should store only those in the cache. | 1742 // are, we should store only those in the cache. |
1699 | 1743 |
1700 bool layersChanged = false; | 1744 bool layersChanged = false; |
1701 LayerList scrollables = getScrollableBackLayers(true, layersChanged); | 1745 LayerList scrollables = getScrollableBackLayers(true, layersChanged); |
1703 bool selectionCacheable = nonScrollables.empty(); | 1747 bool selectionCacheable = nonScrollables.empty(); |
1704 bool haveSelections = m_manager && !m_manager->getSelections().empty(); | 1748 bool haveSelections = m_manager && !m_manager->getSelections().empty(); |
1705 | 1749 |
1706 // If all the non-scrollable layers are non-opaque, then we draw | 1750 // If all the non-scrollable layers are non-opaque, then we draw |
1707 // the selection rectangle behind them and cache it. If any are | 1751 // the selection rectangle behind them and cache it. If any are |
1708 // opaque, however, we can't cache. | 1752 // opaque, however, or if our device-pixel ratio is not 1 (so we |
1753 // need to paint direct to the widget), then we can't cache. | |
1709 // | 1754 // |
1710 if (!selectionCacheable) { | 1755 if (dpratio == 1) { |
1711 selectionCacheable = true; | 1756 |
1712 for (LayerList::const_iterator i = nonScrollables.begin(); | 1757 if (!selectionCacheable) { |
1713 i != nonScrollables.end(); ++i) { | 1758 selectionCacheable = true; |
1714 if ((*i)->isLayerOpaque()) { | 1759 for (LayerList::const_iterator i = nonScrollables.begin(); |
1715 selectionCacheable = false; | 1760 i != nonScrollables.end(); ++i) { |
1716 break; | 1761 if ((*i)->isLayerOpaque()) { |
1717 } | 1762 selectionCacheable = false; |
1718 } | 1763 break; |
1719 } | 1764 } |
1720 | 1765 } |
1721 if (selectionCacheable) { | 1766 } |
1722 QPoint localPos; | 1767 |
1723 bool closeToLeft, closeToRight; | 1768 if (selectionCacheable) { |
1724 if (shouldIlluminateLocalSelection(localPos, closeToLeft, closeToRight)) { | 1769 QPoint localPos; |
1725 selectionCacheable = false; | 1770 bool closeToLeft, closeToRight; |
1726 } | 1771 if (shouldIlluminateLocalSelection |
1772 (localPos, closeToLeft, closeToRight)) { | |
1773 selectionCacheable = false; | |
1774 } | |
1775 } | |
1776 | |
1777 } else { | |
1778 | |
1779 selectionCacheable = false; | |
1727 } | 1780 } |
1728 | 1781 |
1729 #ifdef DEBUG_VIEW_WIDGET_PAINT | 1782 #ifdef DEBUG_VIEW_WIDGET_PAINT |
1730 cerr << "View(" << this << ")::paintEvent: have " << scrollables.size() | 1783 cerr << "View(" << this << ")::paintEvent: have " << scrollables.size() |
1731 << " scrollable back layers and " << nonScrollables.size() | 1784 << " scrollable back layers and " << nonScrollables.size() |
1739 delete m_cache; | 1792 delete m_cache; |
1740 m_cache = 0; | 1793 m_cache = 0; |
1741 m_selectionCached = false; | 1794 m_selectionCached = false; |
1742 } | 1795 } |
1743 | 1796 |
1797 QSize scaledCacheSize(scaledSize(size(), dpratio)); | |
1798 QRect scaledCacheRect(scaledRect(cacheRect, dpratio)); | |
1799 | |
1800 if (!m_buffer || scaledCacheSize != m_buffer->size()) { | |
1801 delete m_buffer; | |
1802 m_buffer = new QPixmap(scaledCacheSize); | |
1803 } | |
1804 | |
1744 if (!scrollables.empty()) { | 1805 if (!scrollables.empty()) { |
1745 | 1806 |
1746 #ifdef DEBUG_VIEW_WIDGET_PAINT | 1807 #ifdef DEBUG_VIEW_WIDGET_PAINT |
1747 cerr << "View(" << this << "): cache " << m_cache << ", cache zoom " | 1808 cerr << "View(" << this << "): cache " << m_cache << ", cache zoom " |
1748 << m_cacheZoomLevel << ", zoom " << m_zoomLevel << endl; | 1809 << m_cacheZoomLevel << ", zoom " << m_zoomLevel << endl; |
1749 #endif | 1810 #endif |
1750 | 1811 |
1751 if (!m_cache || | 1812 if (!m_cache || |
1752 m_cacheZoomLevel != m_zoomLevel || | 1813 m_cacheZoomLevel != m_zoomLevel || |
1753 width() != m_cache->width() || | 1814 scaledCacheSize != m_cache->size()) { |
1754 height() != m_cache->height()) { | |
1755 | 1815 |
1756 // cache is not valid | 1816 // cache is not valid |
1757 | 1817 |
1758 if (cacheRect.width() < width()/10) { | 1818 if (cacheRect.width() < width()/10) { |
1759 delete m_cache; | 1819 delete m_cache; |
1761 #ifdef DEBUG_VIEW_WIDGET_PAINT | 1821 #ifdef DEBUG_VIEW_WIDGET_PAINT |
1762 cerr << "View(" << this << ")::paintEvent: small repaint, not bothering to recreate cache" << endl; | 1822 cerr << "View(" << this << ")::paintEvent: small repaint, not bothering to recreate cache" << endl; |
1763 #endif | 1823 #endif |
1764 } else { | 1824 } else { |
1765 delete m_cache; | 1825 delete m_cache; |
1766 m_cache = new QPixmap(width(), height()); | 1826 m_cache = new QPixmap(scaledCacheSize); |
1767 #ifdef DEBUG_VIEW_WIDGET_PAINT | 1827 #ifdef DEBUG_VIEW_WIDGET_PAINT |
1768 cerr << "View(" << this << ")::paintEvent: recreated cache" << endl; | 1828 cerr << "View(" << this << ")::paintEvent: recreated cache" << endl; |
1769 #endif | 1829 #endif |
1770 cacheRect = rect(); | 1830 cacheRect = rect(); |
1771 repaintCache = true; | 1831 repaintCache = true; |
1776 int dx = | 1836 int dx = |
1777 getXForFrame(m_cacheCentreFrame) - | 1837 getXForFrame(m_cacheCentreFrame) - |
1778 getXForFrame(m_centreFrame); | 1838 getXForFrame(m_centreFrame); |
1779 | 1839 |
1780 if (dx > -width() && dx < width()) { | 1840 if (dx > -width() && dx < width()) { |
1781 #ifdef PIXMAP_COPY_TO_SELF | |
1782 // This is not normally defined. Copying a pixmap to | |
1783 // itself doesn't work properly on Windows, Mac, or | |
1784 // X11 with the raster backend (it only works when | |
1785 // moving in one direction and then presumably only by | |
1786 // accident). It does actually seem to be fine on X11 | |
1787 // with the native backend, but we prefer not to use | |
1788 // that anyway | |
1789 paint.begin(m_cache); | |
1790 paint.drawPixmap(dx, 0, *m_cache); | |
1791 paint.end(); | |
1792 #else | |
1793 static QPixmap *tmpPixmap = 0; | 1841 static QPixmap *tmpPixmap = 0; |
1794 if (!tmpPixmap || | 1842 if (!tmpPixmap || tmpPixmap->size() != scaledCacheSize) { |
1795 tmpPixmap->width() != width() || | |
1796 tmpPixmap->height() != height()) { | |
1797 delete tmpPixmap; | 1843 delete tmpPixmap; |
1798 tmpPixmap = new QPixmap(width(), height()); | 1844 tmpPixmap = new QPixmap(scaledCacheSize); |
1799 } | 1845 } |
1800 paint.begin(tmpPixmap); | 1846 paint.begin(tmpPixmap); |
1801 paint.drawPixmap(0, 0, *m_cache); | 1847 paint.drawPixmap(0, 0, *m_cache); |
1802 paint.end(); | 1848 paint.end(); |
1803 paint.begin(m_cache); | 1849 paint.begin(m_cache); |
1804 paint.drawPixmap(dx, 0, *tmpPixmap); | 1850 paint.drawPixmap(dx, 0, *tmpPixmap); |
1805 paint.end(); | 1851 paint.end(); |
1806 #endif | |
1807 if (dx < 0) { | 1852 if (dx < 0) { |
1808 cacheRect = QRect(width() + dx, 0, -dx, height()); | 1853 cacheRect = QRect(width() + dx, 0, -dx, height()); |
1809 } else { | 1854 } else { |
1810 cacheRect = QRect(0, 0, dx, height()); | 1855 cacheRect = QRect(0, 0, dx, height()); |
1811 } | 1856 } |
1822 | 1867 |
1823 } else { | 1868 } else { |
1824 #ifdef DEBUG_VIEW_WIDGET_PAINT | 1869 #ifdef DEBUG_VIEW_WIDGET_PAINT |
1825 cerr << "View(" << this << ")::paintEvent: cache is good" << endl; | 1870 cerr << "View(" << this << ")::paintEvent: cache is good" << endl; |
1826 #endif | 1871 #endif |
1827 paint.begin(this); | 1872 paint.begin(m_buffer); |
1828 paint.drawPixmap(cacheRect, *m_cache, cacheRect); | 1873 paint.drawPixmap(scaledCacheRect, *m_cache, scaledCacheRect); |
1829 paint.end(); | 1874 paint.end(); |
1830 QFrame::paintEvent(e); | 1875 QFrame::paintEvent(e); |
1831 paintedCacheRect = true; | 1876 paintedCacheRect = true; |
1832 } | 1877 } |
1833 | 1878 |
1839 // cerr << "View(" << this << ")::paintEvent: cacheRect " << cacheRect << ", nonCacheRect " << (nonCacheRect | cacheRect) << ", repaintCache " << repaintCache << ", paintedCacheRect " << paintedCacheRect << endl; | 1884 // cerr << "View(" << this << ")::paintEvent: cacheRect " << cacheRect << ", nonCacheRect " << (nonCacheRect | cacheRect) << ", repaintCache " << repaintCache << ", paintedCacheRect " << paintedCacheRect << endl; |
1840 #endif | 1885 #endif |
1841 | 1886 |
1842 // Scrollable (cacheable) items first | 1887 // Scrollable (cacheable) items first |
1843 | 1888 |
1889 ViewProxy proxy(this, dpratio); | |
1890 | |
1844 if (!paintedCacheRect) { | 1891 if (!paintedCacheRect) { |
1845 | 1892 |
1846 if (repaintCache) paint.begin(m_cache); | 1893 QRect rectToPaint; |
1847 else paint.begin(this); | 1894 |
1895 if (repaintCache) { | |
1896 paint.begin(m_cache); | |
1897 rectToPaint = scaledCacheRect; | |
1898 } else { | |
1899 paint.begin(m_buffer); | |
1900 rectToPaint = scaledCacheRect; | |
1901 } | |
1902 | |
1848 setPaintFont(paint); | 1903 setPaintFont(paint); |
1849 paint.setClipRect(cacheRect); | 1904 paint.setClipRect(rectToPaint); |
1850 | 1905 |
1851 paint.setPen(getBackground()); | 1906 paint.setPen(getBackground()); |
1852 paint.setBrush(getBackground()); | 1907 paint.setBrush(getBackground()); |
1853 paint.drawRect(cacheRect); | 1908 paint.drawRect(rectToPaint); |
1854 | 1909 |
1855 paint.setPen(getForeground()); | 1910 paint.setPen(getForeground()); |
1856 paint.setBrush(Qt::NoBrush); | 1911 paint.setBrush(Qt::NoBrush); |
1857 | 1912 |
1858 for (LayerList::iterator i = scrollables.begin(); i != scrollables.end(); ++i) { | 1913 for (LayerList::iterator i = scrollables.begin(); i != scrollables.end(); ++i) { |
1859 paint.setRenderHint(QPainter::Antialiasing, false); | 1914 paint.setRenderHint(QPainter::Antialiasing, false); |
1860 paint.save(); | 1915 paint.save(); |
1861 (*i)->paint(this, paint, cacheRect); | 1916 #ifdef DEBUG_VIEW_WIDGET_PAINT |
1917 cerr << "Painting scrollable layer " << *i << " using proxy with repaintCache = " << repaintCache << ", dpratio = " << dpratio << ", rectToPaint = " << rectToPaint.x() << "," << rectToPaint.y() << " " << rectToPaint.width() << "x" << rectToPaint.height() << endl; | |
1918 #endif | |
1919 (*i)->paint(&proxy, paint, rectToPaint); | |
1862 paint.restore(); | 1920 paint.restore(); |
1863 } | 1921 } |
1864 | 1922 |
1865 if (haveSelections && selectionCacheable) { | 1923 if (haveSelections && selectionCacheable) { |
1866 drawSelections(paint); | 1924 drawSelections(paint); |
1869 | 1927 |
1870 paint.end(); | 1928 paint.end(); |
1871 | 1929 |
1872 if (repaintCache) { | 1930 if (repaintCache) { |
1873 cacheRect |= (e ? e->rect() : rect()); | 1931 cacheRect |= (e ? e->rect() : rect()); |
1874 paint.begin(this); | 1932 scaledCacheRect = scaledRect(cacheRect, dpratio); |
1875 paint.drawPixmap(cacheRect, *m_cache, cacheRect); | 1933 paint.begin(m_buffer); |
1934 paint.drawPixmap(scaledCacheRect, *m_cache, scaledCacheRect); | |
1876 paint.end(); | 1935 paint.end(); |
1877 } | 1936 } |
1878 } | 1937 } |
1879 | 1938 |
1880 // Now non-cacheable items. We always need to redraw the | 1939 // Now non-cacheable items. We always need to redraw the |
1881 // non-cacheable items across at least the area we drew of the | 1940 // non-cacheable items across at least the area we drew of the |
1882 // cacheable items. | 1941 // cacheable items. |
1883 | 1942 |
1884 nonCacheRect |= cacheRect; | 1943 nonCacheRect |= cacheRect; |
1885 | 1944 |
1886 paint.begin(this); | 1945 QRect scaledNonCacheRect = scaledRect(nonCacheRect, dpratio); |
1887 paint.setClipRect(nonCacheRect); | 1946 |
1947 paint.begin(m_buffer); | |
1948 paint.setClipRect(scaledNonCacheRect); | |
1888 setPaintFont(paint); | 1949 setPaintFont(paint); |
1889 if (scrollables.empty()) { | 1950 if (scrollables.empty()) { |
1890 paint.setPen(getBackground()); | 1951 paint.setPen(getBackground()); |
1891 paint.setBrush(getBackground()); | 1952 paint.setBrush(getBackground()); |
1892 paint.drawRect(nonCacheRect); | 1953 paint.drawRect(scaledNonCacheRect); |
1893 } | 1954 } |
1894 | 1955 |
1895 paint.setPen(getForeground()); | 1956 paint.setPen(getForeground()); |
1896 paint.setBrush(Qt::NoBrush); | 1957 paint.setBrush(Qt::NoBrush); |
1897 | 1958 |
1898 for (LayerList::iterator i = nonScrollables.begin(); i != nonScrollables.end(); ++i) { | 1959 for (LayerList::iterator i = nonScrollables.begin(); i != nonScrollables.end(); ++i) { |
1899 // Profiler profiler2("View::paintEvent non-cacheable"); | 1960 // Profiler profiler2("View::paintEvent non-cacheable"); |
1900 (*i)->paint(this, paint, nonCacheRect); | 1961 #ifdef DEBUG_VIEW_WIDGET_PAINT |
1962 cerr << "Painting non-scrollable layer " << *i << " without proxy with repaintCache = " << repaintCache << ", dpratio = " << dpratio << ", rectToPaint = " << nonCacheRect.x() << "," << nonCacheRect.y() << " " << nonCacheRect.width() << "x" << nonCacheRect.height() << endl; | |
1963 #endif | |
1964 (*i)->paint(&proxy, paint, scaledNonCacheRect); | |
1901 } | 1965 } |
1902 | 1966 |
1967 paint.end(); | |
1968 | |
1969 paint.begin(this); | |
1970 QRect finalPaintRect = e ? e->rect() : rect(); | |
1971 paint.drawPixmap(finalPaintRect, *m_buffer, scaledRect(finalPaintRect, dpratio)); | |
1903 paint.end(); | 1972 paint.end(); |
1904 | 1973 |
1905 paint.begin(this); | 1974 paint.begin(this); |
1906 setPaintFont(paint); | 1975 setPaintFont(paint); |
1907 if (e) paint.setClipRect(e->rect()); | 1976 if (e) paint.setClipRect(e->rect()); |
1923 // Don't show the play pointer when it is redundant with | 1992 // Don't show the play pointer when it is redundant with |
1924 // the centre line | 1993 // the centre line |
1925 showPlayPointer = false; | 1994 showPlayPointer = false; |
1926 } | 1995 } |
1927 } | 1996 } |
1928 | 1997 |
1929 if (showPlayPointer) { | 1998 if (showPlayPointer) { |
1930 | 1999 |
1931 paint.begin(this); | 2000 paint.begin(this); |
1932 | 2001 |
1933 int playx = getXForFrame(m_playPointerFrame); | 2002 int playx = getXForFrame(m_playPointerFrame); |
2410 paint.setPen(getForeground()); | 2479 paint.setPen(getForeground()); |
2411 paint.setBrush(Qt::NoBrush); | 2480 paint.setBrush(Qt::NoBrush); |
2412 | 2481 |
2413 for (LayerList::iterator i = m_layerStack.begin(); | 2482 for (LayerList::iterator i = m_layerStack.begin(); |
2414 i != m_layerStack.end(); ++i) { | 2483 i != m_layerStack.end(); ++i) { |
2415 if(!((*i)->isLayerDormant(this))){ | 2484 if (!((*i)->isLayerDormant(this))){ |
2416 | 2485 |
2417 paint.setRenderHint(QPainter::Antialiasing, false); | 2486 paint.setRenderHint(QPainter::Antialiasing, false); |
2418 | 2487 |
2419 paint.save(); | 2488 paint.save(); |
2420 paint.translate(xorigin + x, 0); | 2489 paint.translate(xorigin + x, 0); |
2421 | 2490 |
2422 cerr << "Centre frame now: " << m_centreFrame << " drawing to " << chunk.x() + x + xorigin << ", " << chunk.width() << endl; | 2491 cerr << "Centre frame now: " << m_centreFrame << " drawing to " << chunk.x() + x + xorigin << ", " << chunk.width() << endl; |
2423 | 2492 |
2424 (*i)->setSynchronousPainting(true); | 2493 (*i)->setSynchronousPainting(true); |
2425 | 2494 |
2426 (*i)->paint(this, paint, chunk); | 2495 (*i)->paint(this, paint, chunk); |
2427 | 2496 |
2428 (*i)->setSynchronousPainting(false); | 2497 (*i)->setSynchronousPainting(false); |
2429 | 2498 |
2430 paint.restore(); | 2499 paint.restore(); |
2431 } | 2500 } |
2432 } | 2501 } |
2433 } | 2502 } |
2434 | 2503 |
2435 m_centreFrame = origCentreFrame; | 2504 m_centreFrame = origCentreFrame; |
2436 update(); | 2505 update(); |