Mercurial > hg > svgui
comparison view/Overview.cpp @ 1266:a34a2a25907c
Untabify
author | Chris Cannam |
---|---|
date | Thu, 01 Mar 2018 18:02:22 +0000 |
parents | 97d0c798c2ac |
children | 13d9b422f7fe |
comparison
equal
deleted
inserted
replaced
1265:6e724c81f18f | 1266:a34a2a25907c |
---|---|
48 | 48 |
49 sv_frame_t frameCount = getModelsEndFrame() - getModelsStartFrame(); | 49 sv_frame_t frameCount = getModelsEndFrame() - getModelsStartFrame(); |
50 int zoomLevel = int(frameCount / width()); | 50 int zoomLevel = int(frameCount / width()); |
51 if (zoomLevel < 1) zoomLevel = 1; | 51 if (zoomLevel < 1) zoomLevel = 1; |
52 zoomLevel = getZoomConstraintBlockSize(zoomLevel, | 52 zoomLevel = getZoomConstraintBlockSize(zoomLevel, |
53 ZoomConstraint::RoundUp); | 53 ZoomConstraint::RoundUp); |
54 if (zoomLevel != m_zoomLevel) { | 54 if (zoomLevel != m_zoomLevel) { |
55 zoomChanged = true; | 55 zoomChanged = true; |
56 } | 56 } |
57 | 57 |
58 if (!zoomChanged) { | 58 if (!zoomChanged) { |
116 { | 116 { |
117 #ifdef DEBUG_OVERVIEW | 117 #ifdef DEBUG_OVERVIEW |
118 cerr << "Overview[" << this << "]::viewCentreFrameChanged(" << v << "): " << f << endl; | 118 cerr << "Overview[" << this << "]::viewCentreFrameChanged(" << v << "): " << f << endl; |
119 #endif | 119 #endif |
120 if (m_views.find(v) != m_views.end()) { | 120 if (m_views.find(v) != m_views.end()) { |
121 update(); | 121 update(); |
122 } | 122 } |
123 } | 123 } |
124 | 124 |
125 void | 125 void |
126 Overview::viewZoomLevelChanged(View *v, int, bool) | 126 Overview::viewZoomLevelChanged(View *v, int, bool) |
127 { | 127 { |
128 if (v == this) return; | 128 if (v == this) return; |
129 if (m_views.find(v) != m_views.end()) { | 129 if (m_views.find(v) != m_views.end()) { |
130 update(); | 130 update(); |
131 } | 131 } |
132 } | 132 } |
133 | 133 |
134 void | 134 void |
135 Overview::viewManagerPlaybackFrameChanged(sv_frame_t f) | 135 Overview::viewManagerPlaybackFrameChanged(sv_frame_t f) |
180 sv_frame_t startFrame = getModelsStartFrame(); | 180 sv_frame_t startFrame = getModelsStartFrame(); |
181 sv_frame_t frameCount = getModelsEndFrame() - getModelsStartFrame(); | 181 sv_frame_t frameCount = getModelsEndFrame() - getModelsStartFrame(); |
182 int zoomLevel = int(frameCount / width()); | 182 int zoomLevel = int(frameCount / width()); |
183 if (zoomLevel < 1) zoomLevel = 1; | 183 if (zoomLevel < 1) zoomLevel = 1; |
184 zoomLevel = getZoomConstraintBlockSize(zoomLevel, | 184 zoomLevel = getZoomConstraintBlockSize(zoomLevel, |
185 ZoomConstraint::RoundUp); | 185 ZoomConstraint::RoundUp); |
186 if (zoomLevel != m_zoomLevel) { | 186 if (zoomLevel != m_zoomLevel) { |
187 m_zoomLevel = zoomLevel; | 187 m_zoomLevel = zoomLevel; |
188 emit zoomLevelChanged(m_zoomLevel, m_followZoom); | 188 emit zoomLevelChanged(m_zoomLevel, m_followZoom); |
189 } | 189 } |
190 | 190 |
191 sv_frame_t centreFrame = startFrame + m_zoomLevel * (width() / 2); | 191 sv_frame_t centreFrame = startFrame + m_zoomLevel * (width() / 2); |
192 if (centreFrame > (startFrame + getModelsEndFrame())/2) { | 192 if (centreFrame > (startFrame + getModelsEndFrame())/2) { |
193 centreFrame = (startFrame + getModelsEndFrame())/2; | 193 centreFrame = (startFrame + getModelsEndFrame())/2; |
194 } | 194 } |
195 if (centreFrame != m_centreFrame) { | 195 if (centreFrame != m_centreFrame) { |
196 #ifdef DEBUG_OVERVIEW | 196 #ifdef DEBUG_OVERVIEW |
197 cerr << "Overview::paintEvent: Centre frame changed from " | 197 cerr << "Overview::paintEvent: Centre frame changed from " |
198 << m_centreFrame << " to " << centreFrame << " and thus start frame from " << getStartFrame(); | 198 << m_centreFrame << " to " << centreFrame << " and thus start frame from " << getStartFrame(); |
199 #endif | 199 #endif |
200 m_centreFrame = centreFrame; | 200 m_centreFrame = centreFrame; |
201 #ifdef DEBUG_OVERVIEW | 201 #ifdef DEBUG_OVERVIEW |
202 cerr << " to " << getStartFrame() << endl; | 202 cerr << " to " << getStartFrame() << endl; |
203 #endif | 203 #endif |
204 emit centreFrameChanged(m_centreFrame, false, PlaybackIgnore); | 204 emit centreFrameChanged(m_centreFrame, false, PlaybackIgnore); |
205 } | 205 } |
206 | 206 |
207 View::paintEvent(e); | 207 View::paintEvent(e); |
208 | 208 |
209 QPainter paint; | 209 QPainter paint; |
222 QRect primary; | 222 QRect primary; |
223 | 223 |
224 int y = 0; | 224 int y = 0; |
225 | 225 |
226 for (ViewSet::iterator i = m_views.begin(); i != m_views.end(); ++i) { | 226 for (ViewSet::iterator i = m_views.begin(); i != m_views.end(); ++i) { |
227 if (!*i) continue; | 227 if (!*i) continue; |
228 | 228 |
229 View *w = (View *)*i; | 229 View *w = (View *)*i; |
230 | 230 |
231 sv_frame_t f0 = w->getFrameForX(0); | 231 sv_frame_t f0 = w->getFrameForX(0); |
232 sv_frame_t f1 = w->getFrameForX(w->width()); | 232 sv_frame_t f1 = w->getFrameForX(w->width()); |
233 | 233 |
234 if (f0 >= 0) { | 234 if (f0 >= 0) { |
235 sv_frame_t rf0 = w->alignToReference(f0); | 235 sv_frame_t rf0 = w->alignToReference(f0); |
236 f0 = alignFromReference(rf0); | 236 f0 = alignFromReference(rf0); |
237 } | 237 } |
238 if (f1 >= 0) { | 238 if (f1 >= 0) { |
239 sv_frame_t rf1 = w->alignToReference(f1); | 239 sv_frame_t rf1 = w->alignToReference(f1); |
240 f1 = alignFromReference(rf1); | 240 f1 = alignFromReference(rf1); |
241 } | 241 } |
242 | 242 |
243 int x0 = getXForFrame(f0); | 243 int x0 = getXForFrame(f0); |
244 int x1 = getXForFrame(f1); | 244 int x1 = getXForFrame(f1); |
245 | 245 |
246 if (x1 <= x0) x1 = x0 + 1; | 246 if (x1 <= x0) x1 = x0 + 1; |
247 | 247 |
248 std::pair<int, int> extent(x0, x1); | 248 std::pair<int, int> extent(x0, x1); |
249 | 249 |
250 if (extents.find(extent) == extents.end()) { | 250 if (extents.find(extent) == extents.end()) { |
251 | 251 |
252 y += height() / 10 + 1; | 252 y += height() / 10 + 1; |
253 extents.insert(extent); | 253 extents.insert(extent); |
254 | 254 |
255 QRect vr(x0, y, x1 - x0, height() - 2 * y); | 255 QRect vr(x0, y, x1 - x0, height() - 2 * y); |
256 rects.push_back(vr); | 256 rects.push_back(vr); |
257 primary = vr; //!!! for now | 257 primary = vr; //!!! for now |
285 if (clickFrame > 0) m_dragCentreFrame = clickFrame; | 285 if (clickFrame > 0) m_dragCentreFrame = clickFrame; |
286 else m_dragCentreFrame = 0; | 286 else m_dragCentreFrame = 0; |
287 m_clickedInRange = true; | 287 m_clickedInRange = true; |
288 | 288 |
289 for (ViewSet::iterator i = m_views.begin(); i != m_views.end(); ++i) { | 289 for (ViewSet::iterator i = m_views.begin(); i != m_views.end(); ++i) { |
290 if (*i && (*i)->getAligningModel() == getAligningModel()) { | 290 if (*i && (*i)->getAligningModel() == getAligningModel()) { |
291 m_dragCentreFrame = (*i)->getCentreFrame(); | 291 m_dragCentreFrame = (*i)->getCentreFrame(); |
292 break; | 292 break; |
293 } | 293 } |
294 } | 294 } |
295 } | 295 } |
296 | 296 |
297 void | 297 void |
298 Overview::mouseReleaseEvent(QMouseEvent *e) | 298 Overview::mouseReleaseEvent(QMouseEvent *e) |
299 { | 299 { |
300 if (m_clickedInRange) { | 300 if (m_clickedInRange) { |
301 mouseMoveEvent(e); | 301 mouseMoveEvent(e); |
302 } | 302 } |
303 m_clickedInRange = false; | 303 m_clickedInRange = false; |
304 } | 304 } |
305 | 305 |
306 void | 306 void |
311 int xoff = int(e->x()) - int(m_clickPos.x()); | 311 int xoff = int(e->x()) - int(m_clickPos.x()); |
312 sv_frame_t frameOff = xoff * m_zoomLevel; | 312 sv_frame_t frameOff = xoff * m_zoomLevel; |
313 | 313 |
314 sv_frame_t newCentreFrame = m_dragCentreFrame; | 314 sv_frame_t newCentreFrame = m_dragCentreFrame; |
315 if (frameOff > 0) { | 315 if (frameOff > 0) { |
316 newCentreFrame += frameOff; | 316 newCentreFrame += frameOff; |
317 } else if (newCentreFrame >= -frameOff) { | 317 } else if (newCentreFrame >= -frameOff) { |
318 newCentreFrame += frameOff; | 318 newCentreFrame += frameOff; |
319 } else { | 319 } else { |
320 newCentreFrame = 0; | 320 newCentreFrame = 0; |
321 } | 321 } |
322 | 322 |
323 if (newCentreFrame >= getModelsEndFrame()) { | 323 if (newCentreFrame >= getModelsEndFrame()) { |
324 newCentreFrame = getModelsEndFrame(); | 324 newCentreFrame = getModelsEndFrame(); |
325 if (newCentreFrame > 0) --newCentreFrame; | 325 if (newCentreFrame > 0) --newCentreFrame; |
326 } | 326 } |
327 | 327 |
328 if (std::max(m_centreFrame, newCentreFrame) - | 328 if (std::max(m_centreFrame, newCentreFrame) - |
329 std::min(m_centreFrame, newCentreFrame) > m_zoomLevel) { | 329 std::min(m_centreFrame, newCentreFrame) > m_zoomLevel) { |
330 sv_frame_t rf = alignToReference(newCentreFrame); | 330 sv_frame_t rf = alignToReference(newCentreFrame); |
331 #ifdef DEBUG_OVERVIEW | 331 #ifdef DEBUG_OVERVIEW |
332 cerr << "Overview::mouseMoveEvent: x " << e->x() << " and click x " << m_clickPos.x() << " -> frame " << newCentreFrame << " -> rf " << rf << endl; | 332 cerr << "Overview::mouseMoveEvent: x " << e->x() << " and click x " << m_clickPos.x() << " -> frame " << newCentreFrame << " -> rf " << rf << endl; |
333 #endif | 333 #endif |
334 if (m_followPlay == PlaybackScrollContinuous || | 334 if (m_followPlay == PlaybackScrollContinuous || |