comparison view/Overview.cpp @ 374:64e84e5efb76 spectrogram-cache-rejig

* Merge from trunk
author Chris Cannam
date Wed, 27 Feb 2008 11:59:42 +0000
parents cd2492c5fe45
children 2ed4e572d0d4
comparison
equal deleted inserted replaced
332:6440e280122e 374:64e84e5efb76
69 } 69 }
70 70
71 void 71 void
72 Overview::modelReplaced() 72 Overview::modelReplaced()
73 { 73 {
74 m_playPointerFrame = getAlignedPlaybackFrame();
74 View::modelReplaced(); 75 View::modelReplaced();
75 } 76 }
76 77
77 void 78 void
78 Overview::registerView(View *view) 79 Overview::registerView(View *view)
113 114
114 void 115 void
115 Overview::viewManagerPlaybackFrameChanged(unsigned long f) 116 Overview::viewManagerPlaybackFrameChanged(unsigned long f)
116 { 117 {
117 bool changed = false; 118 bool changed = false;
119
120 f = getAlignedPlaybackFrame();
118 121
119 if (getXForFrame(m_playPointerFrame) != getXForFrame(f)) changed = true; 122 if (getXForFrame(m_playPointerFrame) != getXForFrame(f)) changed = true;
120 m_playPointerFrame = f; 123 m_playPointerFrame = f;
121 124
122 if (changed) update(); 125 if (changed) update();
177 View *w = (View *)*i; 180 View *w = (View *)*i;
178 181
179 long f0 = w->getFrameForX(0); 182 long f0 = w->getFrameForX(0);
180 long f1 = w->getFrameForX(w->width()); 183 long f1 = w->getFrameForX(w->width());
181 184
185 if (f0 >= 0) {
186 size_t rf0 = w->alignToReference(f0);
187 f0 = alignFromReference(rf0);
188 }
189 if (f1 >= 0) {
190 size_t rf1 = w->alignToReference(f1);
191 f1 = alignFromReference(rf1);
192 }
193
182 int x0 = getXForFrame(f0); 194 int x0 = getXForFrame(f0);
183 int x1 = getXForFrame(f1); 195 int x1 = getXForFrame(f1);
184 196
185 if (x0 != prevx0 || x1 != prevx1) { 197 if (x0 != prevx0 || x1 != prevx1) {
186 y += height() / 10 + 1; 198 y += height() / 10 + 1;
198 210
199 void 211 void
200 Overview::mousePressEvent(QMouseEvent *e) 212 Overview::mousePressEvent(QMouseEvent *e)
201 { 213 {
202 m_clickPos = e->pos(); 214 m_clickPos = e->pos();
215 long clickFrame = getFrameForX(m_clickPos.x());
216 if (clickFrame > 0) m_dragCentreFrame = clickFrame;
217 else m_dragCentreFrame = 0;
218 m_clickedInRange = true;
219
203 for (ViewSet::iterator i = m_views.begin(); i != m_views.end(); ++i) { 220 for (ViewSet::iterator i = m_views.begin(); i != m_views.end(); ++i) {
204 if (*i) { 221 if (*i && (*i)->getAligningModel() == getAligningModel()) {
205 m_clickedInRange = true; 222 m_dragCentreFrame = (*i)->getCentreFrame();
206 m_dragCentreFrame = ((View *)*i)->getCentreFrame(); 223 break;
207 break; 224 }
208 }
209 } 225 }
210 } 226 }
211 227
212 void 228 void
213 Overview::mouseReleaseEvent(QMouseEvent *e) 229 Overview::mouseReleaseEvent(QMouseEvent *e)
240 if (newCentreFrame > 0) --newCentreFrame; 256 if (newCentreFrame > 0) --newCentreFrame;
241 } 257 }
242 258
243 if (std::max(m_centreFrame, newCentreFrame) - 259 if (std::max(m_centreFrame, newCentreFrame) -
244 std::min(m_centreFrame, newCentreFrame) > size_t(m_zoomLevel)) { 260 std::min(m_centreFrame, newCentreFrame) > size_t(m_zoomLevel)) {
245 emit centreFrameChanged(newCentreFrame, true, PlaybackScrollContinuous); 261 size_t rf = alignToReference(newCentreFrame);
262 emit centreFrameChanged(rf, true, PlaybackScrollContinuous);
246 } 263 }
247 } 264 }
248 265
249 void 266 void
250 Overview::mouseDoubleClickEvent(QMouseEvent *e) 267 Overview::mouseDoubleClickEvent(QMouseEvent *e)
251 { 268 {
252 long frame = getFrameForX(e->x()); 269 long frame = getFrameForX(e->x());
253 emit centreFrameChanged(frame, true, PlaybackScrollContinuous); 270 size_t rf = 0;
271 if (frame > 0) rf = alignToReference(frame);
272 emit centreFrameChanged(rf, true, PlaybackScrollContinuous);
254 } 273 }
255 274
256 void 275 void
257 Overview::enterEvent(QEvent *) 276 Overview::enterEvent(QEvent *)
258 { 277 {