Mercurial > hg > svgui
comparison view/Overview.cpp @ 211:e2baee498ec8
* Rejig handling of scrolling views. Ensures, among other things, that playing
when there is a scroll mode view present (e.g. a spectrum) does not drag
any page mode views into scroll mode with it.
author | Chris Cannam |
---|---|
date | Thu, 01 Mar 2007 11:55:46 +0000 |
parents | 5b7472db612b |
children | df791d8c8f58 |
comparison
equal
deleted
inserted
replaced
210:748985c7e2c1 | 211:e2baee498ec8 |
---|---|
30 m_clickedInRange(false) | 30 m_clickedInRange(false) |
31 { | 31 { |
32 setObjectName(tr("Overview")); | 32 setObjectName(tr("Overview")); |
33 m_followPan = false; | 33 m_followPan = false; |
34 m_followZoom = false; | 34 m_followZoom = false; |
35 setPlaybackFollow(PlaybackIgnore); | |
35 } | 36 } |
36 | 37 |
37 void | 38 void |
38 Overview::modelChanged(size_t startFrame, size_t endFrame) | 39 Overview::modelChanged(size_t startFrame, size_t endFrame) |
39 { | 40 { |
45 { | 46 { |
46 View::modelReplaced(); | 47 View::modelReplaced(); |
47 } | 48 } |
48 | 49 |
49 void | 50 void |
50 Overview::registerView(View *widget) | 51 Overview::registerView(View *view) |
51 { | 52 { |
52 m_widgets.insert(widget); | 53 m_views.insert(view); |
53 update(); | 54 update(); |
54 } | 55 } |
55 | 56 |
56 void | 57 void |
57 Overview::unregisterView(View *widget) | 58 Overview::unregisterView(View *view) |
58 { | 59 { |
59 m_widgets.erase(widget); | 60 m_views.erase(view); |
60 update(); | 61 update(); |
61 } | 62 } |
62 | 63 |
63 void | 64 void |
64 Overview::viewManagerCentreFrameChanged(void *p, unsigned long f, bool) | 65 Overview::globalCentreFrameChanged(unsigned long f) |
65 { | 66 { |
66 // std::cerr << "Overview[" << this << "]::viewManagerCentreFrameChanged(" | 67 update(); |
67 // << p << ", " << f << ")" << std::endl; | 68 } |
68 | 69 |
70 void | |
71 Overview::viewCentreFrameChanged(View *v, unsigned long f) | |
72 { | |
73 if (m_views.find(v) != m_views.end()) { | |
74 update(); | |
75 } | |
76 } | |
77 | |
78 void | |
79 Overview::viewManagerZoomLevelChanged(void *p, unsigned long z, bool) | |
80 { | |
69 if (p == this) return; | 81 if (p == this) return; |
70 if (m_widgets.find(p) != m_widgets.end()) { | 82 View *v = (View *)p; |
71 update(); | 83 if (m_views.find(v) != m_views.end()) { |
72 } | |
73 } | |
74 | |
75 void | |
76 Overview::viewManagerZoomLevelChanged(void *p, unsigned long z, bool) | |
77 { | |
78 if (p == this) return; | |
79 if (m_widgets.find(p) != m_widgets.end()) { | |
80 update(); | 84 update(); |
81 } | 85 } |
82 } | 86 } |
83 | 87 |
84 void | 88 void |
111 if (centreFrame > (startFrame + getModelsEndFrame())/2) { | 115 if (centreFrame > (startFrame + getModelsEndFrame())/2) { |
112 centreFrame = (startFrame + getModelsEndFrame())/2; | 116 centreFrame = (startFrame + getModelsEndFrame())/2; |
113 } | 117 } |
114 if (centreFrame != m_centreFrame) { | 118 if (centreFrame != m_centreFrame) { |
115 m_centreFrame = centreFrame; | 119 m_centreFrame = centreFrame; |
116 emit centreFrameChanged(this, m_centreFrame, false); | 120 emit centreFrameChanged(m_centreFrame, false, PlaybackIgnore); |
117 } | 121 } |
118 | 122 |
119 View::paintEvent(e); | 123 View::paintEvent(e); |
120 | 124 |
121 QPainter paint; | 125 QPainter paint; |
133 int y = 0; | 137 int y = 0; |
134 | 138 |
135 int prevx0 = -10; | 139 int prevx0 = -10; |
136 int prevx1 = -10; | 140 int prevx1 = -10; |
137 | 141 |
138 for (WidgetSet::iterator i = m_widgets.begin(); i != m_widgets.end(); ++i) { | 142 for (ViewSet::iterator i = m_views.begin(); i != m_views.end(); ++i) { |
139 if (!*i) continue; | 143 if (!*i) continue; |
140 | 144 |
141 View *w = (View *)*i; | 145 View *w = (View *)*i; |
142 | 146 |
143 long f0 = w->getFrameForX(0); | 147 long f0 = w->getFrameForX(0); |
162 | 166 |
163 void | 167 void |
164 Overview::mousePressEvent(QMouseEvent *e) | 168 Overview::mousePressEvent(QMouseEvent *e) |
165 { | 169 { |
166 m_clickPos = e->pos(); | 170 m_clickPos = e->pos(); |
167 for (WidgetSet::iterator i = m_widgets.begin(); i != m_widgets.end(); ++i) { | 171 for (ViewSet::iterator i = m_views.begin(); i != m_views.end(); ++i) { |
168 if (*i) { | 172 if (*i) { |
169 m_clickedInRange = true; | 173 m_clickedInRange = true; |
170 m_dragCentreFrame = ((View *)*i)->getCentreFrame(); | 174 m_dragCentreFrame = ((View *)*i)->getCentreFrame(); |
171 break; | 175 break; |
172 } | 176 } |
204 if (newCentreFrame > 0) --newCentreFrame; | 208 if (newCentreFrame > 0) --newCentreFrame; |
205 } | 209 } |
206 | 210 |
207 if (std::max(m_centreFrame, newCentreFrame) - | 211 if (std::max(m_centreFrame, newCentreFrame) - |
208 std::min(m_centreFrame, newCentreFrame) > size_t(m_zoomLevel)) { | 212 std::min(m_centreFrame, newCentreFrame) > size_t(m_zoomLevel)) { |
209 emit centreFrameChanged(this, newCentreFrame, true); | 213 emit centreFrameChanged(newCentreFrame, true, PlaybackIgnore); |
210 } | 214 } |
211 } | 215 } |
212 | 216 |
213 void | 217 void |
214 Overview::mouseDoubleClickEvent(QMouseEvent *e) | 218 Overview::mouseDoubleClickEvent(QMouseEvent *e) |
215 { | 219 { |
216 long frame = getFrameForX(e->x()); | 220 long frame = getFrameForX(e->x()); |
217 emit centreFrameChanged(this, frame, true); | 221 emit centreFrameChanged(frame, true, PlaybackIgnore); |
218 } | 222 } |
219 | 223 |
220 void | 224 void |
221 Overview::enterEvent(QEvent *) | 225 Overview::enterEvent(QEvent *) |
222 { | 226 { |