Mercurial > hg > svgui
comparison view/Pane.cpp @ 1148:c0d841cb8ab9 tony-2.0-integration
Merge latest SV 3.0 branch code
author | Chris Cannam |
---|---|
date | Fri, 19 Aug 2016 15:58:57 +0100 |
parents | ee01a4062747 |
children | ba379b4d4555 |
comparison
equal
deleted
inserted
replaced
1009:96cf499fad62 | 1148:c0d841cb8ab9 |
---|---|
23 #include "widgets/CommandHistory.h" | 23 #include "widgets/CommandHistory.h" |
24 #include "widgets/TextAbbrev.h" | 24 #include "widgets/TextAbbrev.h" |
25 #include "base/Preferences.h" | 25 #include "base/Preferences.h" |
26 #include "layer/WaveformLayer.h" | 26 #include "layer/WaveformLayer.h" |
27 #include "layer/TimeRulerLayer.h" | 27 #include "layer/TimeRulerLayer.h" |
28 #include "layer/PaintAssistant.h" | |
28 | 29 |
29 // GF: added so we can propagate the mouse move event to the note layer for context handling. | 30 // GF: added so we can propagate the mouse move event to the note layer for context handling. |
30 #include "layer/LayerFactory.h" | 31 #include "layer/LayerFactory.h" |
31 #include "layer/FlexiNoteLayer.h" | 32 #include "layer/FlexiNoteLayer.h" |
32 | 33 |
715 } | 716 } |
716 | 717 |
717 void | 718 void |
718 Pane::drawCentreLine(sv_samplerate_t sampleRate, QPainter &paint, bool omitLine) | 719 Pane::drawCentreLine(sv_samplerate_t sampleRate, QPainter &paint, bool omitLine) |
719 { | 720 { |
721 if (omitLine && m_manager->getMainModelSampleRate() == 0) { | |
722 return; | |
723 } | |
724 | |
720 int fontHeight = paint.fontMetrics().height(); | 725 int fontHeight = paint.fontMetrics().height(); |
721 int fontAscent = paint.fontMetrics().ascent(); | 726 int fontAscent = paint.fontMetrics().ascent(); |
722 | 727 |
723 QColor c = QColor(0, 0, 0); | 728 QColor c = QColor(0, 0, 0); |
724 if (!hasLightBackground()) { | 729 if (!hasLightBackground()) { |
771 .toText(true))); | 776 .toText(true))); |
772 | 777 |
773 int tw = paint.fontMetrics().width(text); | 778 int tw = paint.fontMetrics().width(text); |
774 int x = width()/2 - 4 - tw; | 779 int x = width()/2 - 4 - tw; |
775 | 780 |
776 drawVisibleText(paint, x, y, text, OutlinedText); | 781 PaintAssistant::drawVisibleText(this, paint, x, y, text, PaintAssistant::OutlinedText); |
777 } | 782 } |
778 | 783 |
779 QString text = QString("%1").arg(m_centreFrame); | 784 QString text = QString("%1").arg(m_centreFrame); |
780 | 785 |
781 int x = width()/2 + 4; | 786 int x = width()/2 + 4; |
782 | 787 |
783 drawVisibleText(paint, x, y, text, OutlinedText); | 788 PaintAssistant::drawVisibleText(this, paint, x, y, text, PaintAssistant::OutlinedText); |
784 } | 789 } |
785 } | 790 } |
786 | 791 |
787 void | 792 void |
788 Pane::drawModelTimeExtents(QRect r, QPainter &paint, const Model *model) | 793 Pane::drawModelTimeExtents(QRect r, QPainter &paint, const Model *model) |
860 if (r.top() > h + y || r.left() > w + m_scaleWidth + 5) { | 865 if (r.top() > h + y || r.left() > w + m_scaleWidth + 5) { |
861 paint.restore(); | 866 paint.restore(); |
862 return; | 867 return; |
863 } | 868 } |
864 | 869 |
865 drawVisibleText(paint, m_scaleWidth + 5, | 870 PaintAssistant::drawVisibleText(this, paint, m_scaleWidth + 5, |
866 paint.fontMetrics().ascent() + y, text, OutlinedText); | 871 paint.fontMetrics().ascent() + y, text, PaintAssistant::OutlinedText); |
867 | 872 |
868 paint.restore(); | 873 paint.restore(); |
869 } | 874 } |
870 | 875 |
871 void | 876 void |
899 if (r.top() > h + y || r.left() > w + m_scaleWidth + 5) { | 904 if (r.top() > h + y || r.left() > w + m_scaleWidth + 5) { |
900 paint.restore(); | 905 paint.restore(); |
901 return; | 906 return; |
902 } | 907 } |
903 | 908 |
904 drawVisibleText(paint, m_scaleWidth + 5, | 909 PaintAssistant::drawVisibleText(this, paint, m_scaleWidth + 5, |
905 paint.fontMetrics().ascent() + y, text, OutlinedText); | 910 paint.fontMetrics().ascent() + y, text, PaintAssistant::OutlinedText); |
906 | 911 |
907 paint.restore(); | 912 paint.restore(); |
908 } | 913 } |
909 | 914 |
910 void | 915 void |
948 | 953 |
949 if (i + 1 == texts.size()) { | 954 if (i + 1 == texts.size()) { |
950 paint.setPen(getForeground()); | 955 paint.setPen(getForeground()); |
951 } | 956 } |
952 | 957 |
953 drawVisibleText(paint, llx, | 958 PaintAssistant::drawVisibleText(this, paint, llx, |
954 lly - fontHeight + fontAscent, | 959 lly - fontHeight + fontAscent, |
955 texts[i], OutlinedText); | 960 texts[i], PaintAssistant::OutlinedText); |
956 | 961 |
957 if (!pixmaps[i].isNull()) { | 962 if (!pixmaps[i].isNull()) { |
958 paint.drawPixmap(llx - fontAscent - 3, | 963 paint.drawPixmap(llx - fontAscent - 3, |
959 lly - fontHeight + (fontHeight-fontAscent)/2, | 964 lly - fontHeight + (fontHeight-fontAscent)/2, |
960 pixmaps[i]); | 965 pixmaps[i]); |
1012 .arg(offsetText); | 1017 .arg(offsetText); |
1013 if (newStart >= origStart) { | 1018 if (newStart >= origStart) { |
1014 offsetText = tr("+%1").arg(offsetText); | 1019 offsetText = tr("+%1").arg(offsetText); |
1015 } | 1020 } |
1016 } | 1021 } |
1017 drawVisibleText(paint, p0 + 2, fontAscent + fontHeight + 4, startText, OutlinedText); | 1022 PaintAssistant::drawVisibleText(this, paint, p0 + 2, fontAscent + fontHeight + 4, startText, PaintAssistant::OutlinedText); |
1018 drawVisibleText(paint, p1 + 2, fontAscent + fontHeight + 4, endText, OutlinedText); | 1023 PaintAssistant::drawVisibleText(this, paint, p1 + 2, fontAscent + fontHeight + 4, endText, PaintAssistant::OutlinedText); |
1019 drawVisibleText(paint, p0 + 2, fontAscent + fontHeight*2 + 4, offsetText, OutlinedText); | 1024 PaintAssistant::drawVisibleText(this, paint, p0 + 2, fontAscent + fontHeight*2 + 4, offsetText, PaintAssistant::OutlinedText); |
1020 drawVisibleText(paint, p1 + 2, fontAscent + fontHeight*2 + 4, offsetText, OutlinedText); | 1025 PaintAssistant::drawVisibleText(this, paint, p1 + 2, fontAscent + fontHeight*2 + 4, offsetText, PaintAssistant::OutlinedText); |
1021 | 1026 |
1022 //!!! duplicating display policy with View::drawSelections | 1027 //!!! duplicating display policy with View::drawSelections |
1023 | 1028 |
1024 if (m_editingSelectionEdge < 0) { | 1029 if (m_editingSelectionEdge < 0) { |
1025 paint.drawLine(p0, 1, p1, 1); | 1030 paint.drawLine(p0, 1, p1, 1); |
1078 int x = m_scaleWidth + 5; | 1083 int x = m_scaleWidth + 5; |
1079 int pbw = getProgressBarWidth(); | 1084 int pbw = getProgressBarWidth(); |
1080 if (x < pbw + 5) x = pbw + 5; | 1085 if (x < pbw + 5) x = pbw + 5; |
1081 | 1086 |
1082 if (r.x() < x + paint.fontMetrics().width(desc)) { | 1087 if (r.x() < x + paint.fontMetrics().width(desc)) { |
1083 drawVisibleText(paint, x, | 1088 PaintAssistant::drawVisibleText(this, paint, x, |
1084 height() - fontHeight + fontAscent - 6, | 1089 height() - fontHeight + fontAscent - 6, |
1085 desc, OutlinedText); | 1090 desc, PaintAssistant::OutlinedText); |
1086 } | 1091 } |
1087 } | 1092 } |
1088 | 1093 |
1089 bool | 1094 bool |
1090 Pane::render(QPainter &paint, int xorigin, sv_frame_t f0, sv_frame_t f1) | 1095 Pane::render(QPainter &paint, int xorigin, sv_frame_t f0, sv_frame_t f1) |
1941 m_clickPos, | 1946 m_clickPos, |
1942 e->pos(), | 1947 e->pos(), |
1943 true, // can move horiz | 1948 true, // can move horiz |
1944 canTopLayerMoveVertical(), // can move vert | 1949 canTopLayerMoveVertical(), // can move vert |
1945 canTopLayerMoveVertical() || (m_manager && m_manager->isPlaying()), // resist horiz | 1950 canTopLayerMoveVertical() || (m_manager && m_manager->isPlaying()), // resist horiz |
1946 !(m_manager && m_manager->isPlaying())); // resist vert | 1951 true); // resist vert |
1947 | 1952 |
1948 if (m_dragMode == HorizontalDrag || | 1953 if (m_dragMode == HorizontalDrag || |
1949 m_dragMode == FreeDrag) { | 1954 m_dragMode == FreeDrag) { |
1950 | 1955 |
1951 sv_frame_t frameOff = getFrameForX(e->x()) - getFrameForX(m_clickPos.x()); | 1956 sv_frame_t frameOff = getFrameForX(e->x()) - getFrameForX(m_clickPos.x()); |
2310 // the first wheel event -- discard those entirely | 2315 // the first wheel event -- discard those entirely |
2311 if (abs(m_pendingWheelAngle) >= 600) { | 2316 if (abs(m_pendingWheelAngle) >= 600) { |
2312 m_pendingWheelAngle = 0; | 2317 m_pendingWheelAngle = 0; |
2313 return; | 2318 return; |
2314 } | 2319 } |
2315 | 2320 |
2316 while (abs(m_pendingWheelAngle) >= 120) { | 2321 while (abs(m_pendingWheelAngle) >= 120) { |
2317 | 2322 |
2318 int sign = (m_pendingWheelAngle < 0 ? -1 : 1); | 2323 int sign = (m_pendingWheelAngle < 0 ? -1 : 1); |
2319 | 2324 |
2320 if (horizontal) { | 2325 if (horizontal) { |