Mercurial > hg > svgui
comparison view/Overview.cpp @ 922:26da827e8fb5 tonioni
Merge from cxx11 branch
author | Chris Cannam |
---|---|
date | Mon, 23 Mar 2015 11:26:28 +0000 |
parents | 2857e6352b06 4a578a360011 |
children | 1c529a22a6a7 |
comparison
equal
deleted
inserted
replaced
921:4968bbaf1ed8 | 922:26da827e8fb5 |
---|---|
36 setPlaybackFollow(PlaybackIgnore); | 36 setPlaybackFollow(PlaybackIgnore); |
37 m_modelTestTime.start(); | 37 m_modelTestTime.start(); |
38 } | 38 } |
39 | 39 |
40 void | 40 void |
41 Overview::modelChangedWithin(int startFrame, int endFrame) | 41 Overview::modelChangedWithin(sv_frame_t startFrame, sv_frame_t endFrame) |
42 { | 42 { |
43 bool zoomChanged = false; | 43 bool zoomChanged = false; |
44 | 44 |
45 int frameCount = getModelsEndFrame() - getModelsStartFrame(); | 45 sv_frame_t frameCount = getModelsEndFrame() - getModelsStartFrame(); |
46 int zoomLevel = frameCount / width(); | 46 int zoomLevel = int(frameCount / width()); |
47 if (zoomLevel < 1) zoomLevel = 1; | 47 if (zoomLevel < 1) zoomLevel = 1; |
48 zoomLevel = getZoomConstraintBlockSize(zoomLevel, | 48 zoomLevel = getZoomConstraintBlockSize(zoomLevel, |
49 ZoomConstraint::RoundUp); | 49 ZoomConstraint::RoundUp); |
50 if (zoomLevel != m_zoomLevel) { | 50 if (zoomLevel != m_zoomLevel) { |
51 zoomChanged = true; | 51 zoomChanged = true; |
89 m_views.erase(view); | 89 m_views.erase(view); |
90 update(); | 90 update(); |
91 } | 91 } |
92 | 92 |
93 void | 93 void |
94 Overview::globalCentreFrameChanged(int | 94 Overview::globalCentreFrameChanged(sv_frame_t |
95 #ifdef DEBUG_OVERVIEW | 95 #ifdef DEBUG_OVERVIEW |
96 f | 96 f |
97 #endif | 97 #endif |
98 ) | 98 ) |
99 { | 99 { |
102 #endif | 102 #endif |
103 update(); | 103 update(); |
104 } | 104 } |
105 | 105 |
106 void | 106 void |
107 Overview::viewCentreFrameChanged(View *v, int | 107 Overview::viewCentreFrameChanged(View *v, sv_frame_t |
108 #ifdef DEBUG_OVERVIEW | 108 #ifdef DEBUG_OVERVIEW |
109 f | 109 f |
110 #endif | 110 #endif |
111 ) | 111 ) |
112 { | 112 { |
126 update(); | 126 update(); |
127 } | 127 } |
128 } | 128 } |
129 | 129 |
130 void | 130 void |
131 Overview::viewManagerPlaybackFrameChanged(int f) | 131 Overview::viewManagerPlaybackFrameChanged(sv_frame_t f) |
132 { | 132 { |
133 #ifdef DEBUG_OVERVIEW | 133 #ifdef DEBUG_OVERVIEW |
134 cerr << "Overview[" << this << "]::viewManagerPlaybackFrameChanged(" << f << "): " << f << endl; | 134 cerr << "Overview[" << this << "]::viewManagerPlaybackFrameChanged(" << f << "): " << f << endl; |
135 #endif | 135 #endif |
136 | 136 |
165 | 165 |
166 #ifdef DEBUG_OVERVIEW | 166 #ifdef DEBUG_OVERVIEW |
167 cerr << "Overview::paintEvent: width is " << width() << ", centre frame " << m_centreFrame << endl; | 167 cerr << "Overview::paintEvent: width is " << width() << ", centre frame " << m_centreFrame << endl; |
168 #endif | 168 #endif |
169 | 169 |
170 int startFrame = getModelsStartFrame(); | 170 sv_frame_t startFrame = getModelsStartFrame(); |
171 int frameCount = getModelsEndFrame() - getModelsStartFrame(); | 171 sv_frame_t frameCount = getModelsEndFrame() - getModelsStartFrame(); |
172 int zoomLevel = frameCount / width(); | 172 int zoomLevel = int(frameCount / width()); |
173 if (zoomLevel < 1) zoomLevel = 1; | 173 if (zoomLevel < 1) zoomLevel = 1; |
174 zoomLevel = getZoomConstraintBlockSize(zoomLevel, | 174 zoomLevel = getZoomConstraintBlockSize(zoomLevel, |
175 ZoomConstraint::RoundUp); | 175 ZoomConstraint::RoundUp); |
176 if (zoomLevel != m_zoomLevel) { | 176 if (zoomLevel != m_zoomLevel) { |
177 m_zoomLevel = zoomLevel; | 177 m_zoomLevel = zoomLevel; |
178 emit zoomLevelChanged(m_zoomLevel, m_followZoom); | 178 emit zoomLevelChanged(m_zoomLevel, m_followZoom); |
179 } | 179 } |
180 | 180 |
181 int centreFrame = startFrame + m_zoomLevel * (width() / 2); | 181 sv_frame_t centreFrame = startFrame + m_zoomLevel * (width() / 2); |
182 if (centreFrame > (startFrame + getModelsEndFrame())/2) { | 182 if (centreFrame > (startFrame + getModelsEndFrame())/2) { |
183 centreFrame = (startFrame + getModelsEndFrame())/2; | 183 centreFrame = (startFrame + getModelsEndFrame())/2; |
184 } | 184 } |
185 if (centreFrame != m_centreFrame) { | 185 if (centreFrame != m_centreFrame) { |
186 #ifdef DEBUG_OVERVIEW | 186 #ifdef DEBUG_OVERVIEW |
212 std::set<std::pair<int, int> > extents; | 212 std::set<std::pair<int, int> > extents; |
213 std::vector<QRect> rects; | 213 std::vector<QRect> rects; |
214 QRect primary; | 214 QRect primary; |
215 | 215 |
216 int y = 0; | 216 int y = 0; |
217 | 217 |
218 for (ViewSet::iterator i = m_views.begin(); i != m_views.end(); ++i) { | 218 for (ViewSet::iterator i = m_views.begin(); i != m_views.end(); ++i) { |
219 if (!*i) continue; | 219 if (!*i) continue; |
220 | 220 |
221 View *w = (View *)*i; | 221 View *w = (View *)*i; |
222 | 222 |
223 int f0 = w->getFrameForX(0); | 223 sv_frame_t f0 = w->getFrameForX(0); |
224 int f1 = w->getFrameForX(w->width()); | 224 sv_frame_t f1 = w->getFrameForX(w->width()); |
225 | 225 |
226 if (f0 >= 0) { | 226 if (f0 >= 0) { |
227 int rf0 = w->alignToReference(f0); | 227 sv_frame_t rf0 = w->alignToReference(f0); |
228 f0 = alignFromReference(rf0); | 228 f0 = alignFromReference(rf0); |
229 } | 229 } |
230 if (f1 >= 0) { | 230 if (f1 >= 0) { |
231 int rf1 = w->alignToReference(f1); | 231 sv_frame_t rf1 = w->alignToReference(f1); |
232 f1 = alignFromReference(rf1); | 232 f1 = alignFromReference(rf1); |
233 } | 233 } |
234 | 234 |
235 int x0 = getXForFrame(f0); | 235 int x0 = getXForFrame(f0); |
236 int x1 = getXForFrame(f1); | 236 int x1 = getXForFrame(f1); |
271 | 271 |
272 void | 272 void |
273 Overview::mousePressEvent(QMouseEvent *e) | 273 Overview::mousePressEvent(QMouseEvent *e) |
274 { | 274 { |
275 m_clickPos = e->pos(); | 275 m_clickPos = e->pos(); |
276 int clickFrame = getFrameForX(m_clickPos.x()); | 276 sv_frame_t clickFrame = getFrameForX(m_clickPos.x()); |
277 if (clickFrame > 0) m_dragCentreFrame = clickFrame; | 277 if (clickFrame > 0) m_dragCentreFrame = clickFrame; |
278 else m_dragCentreFrame = 0; | 278 else m_dragCentreFrame = 0; |
279 m_clickedInRange = true; | 279 m_clickedInRange = true; |
280 | 280 |
281 for (ViewSet::iterator i = m_views.begin(); i != m_views.end(); ++i) { | 281 for (ViewSet::iterator i = m_views.begin(); i != m_views.end(); ++i) { |
299 Overview::mouseMoveEvent(QMouseEvent *e) | 299 Overview::mouseMoveEvent(QMouseEvent *e) |
300 { | 300 { |
301 if (!m_clickedInRange) return; | 301 if (!m_clickedInRange) return; |
302 | 302 |
303 int xoff = int(e->x()) - int(m_clickPos.x()); | 303 int xoff = int(e->x()) - int(m_clickPos.x()); |
304 int frameOff = xoff * m_zoomLevel; | 304 sv_frame_t frameOff = xoff * m_zoomLevel; |
305 | 305 |
306 int newCentreFrame = m_dragCentreFrame; | 306 sv_frame_t newCentreFrame = m_dragCentreFrame; |
307 if (frameOff > 0) { | 307 if (frameOff > 0) { |
308 newCentreFrame += frameOff; | 308 newCentreFrame += frameOff; |
309 } else if (newCentreFrame >= int(-frameOff)) { | 309 } else if (newCentreFrame >= -frameOff) { |
310 newCentreFrame += frameOff; | 310 newCentreFrame += frameOff; |
311 } else { | 311 } else { |
312 newCentreFrame = 0; | 312 newCentreFrame = 0; |
313 } | 313 } |
314 | 314 |
316 newCentreFrame = getModelsEndFrame(); | 316 newCentreFrame = getModelsEndFrame(); |
317 if (newCentreFrame > 0) --newCentreFrame; | 317 if (newCentreFrame > 0) --newCentreFrame; |
318 } | 318 } |
319 | 319 |
320 if (std::max(m_centreFrame, newCentreFrame) - | 320 if (std::max(m_centreFrame, newCentreFrame) - |
321 std::min(m_centreFrame, newCentreFrame) > int(m_zoomLevel)) { | 321 std::min(m_centreFrame, newCentreFrame) > m_zoomLevel) { |
322 int rf = alignToReference(newCentreFrame); | 322 sv_frame_t rf = alignToReference(newCentreFrame); |
323 #ifdef DEBUG_OVERVIEW | 323 #ifdef DEBUG_OVERVIEW |
324 cerr << "Overview::mouseMoveEvent: x " << e->x() << " and click x " << m_clickPos.x() << " -> frame " << newCentreFrame << " -> rf " << rf << endl; | 324 cerr << "Overview::mouseMoveEvent: x " << e->x() << " and click x " << m_clickPos.x() << " -> frame " << newCentreFrame << " -> rf " << rf << endl; |
325 #endif | 325 #endif |
326 if (m_followPlay == PlaybackScrollContinuous || | 326 if (m_followPlay == PlaybackScrollContinuous || |
327 m_followPlay == PlaybackScrollPageWithCentre) { | 327 m_followPlay == PlaybackScrollPageWithCentre) { |
333 } | 333 } |
334 | 334 |
335 void | 335 void |
336 Overview::mouseDoubleClickEvent(QMouseEvent *e) | 336 Overview::mouseDoubleClickEvent(QMouseEvent *e) |
337 { | 337 { |
338 int frame = getFrameForX(e->x()); | 338 sv_frame_t frame = getFrameForX(e->x()); |
339 int rf = 0; | 339 sv_frame_t rf = 0; |
340 if (frame > 0) rf = alignToReference(frame); | 340 if (frame > 0) rf = alignToReference(frame); |
341 #ifdef DEBUG_OVERVIEW | 341 #ifdef DEBUG_OVERVIEW |
342 cerr << "Overview::mouseDoubleClickEvent: frame " << frame << " -> rf " << rf << endl; | 342 cerr << "Overview::mouseDoubleClickEvent: frame " << frame << " -> rf " << rf << endl; |
343 #endif | 343 #endif |
344 m_clickedInRange = false; // we're not starting a drag with the second click | 344 m_clickedInRange = false; // we're not starting a drag with the second click |