1 /* |
1 /* |
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
4 * |
9 * Initial Contributors: |
5 * This program is free software: you can redistribute it and/or modify |
10 * Nokia Corporation - initial contribution. |
6 * it under the terms of the GNU Lesser General Public License as published by |
|
7 * the Free Software Foundation, version 2.1 of the License. |
11 * |
8 * |
12 * Contributors: |
9 * This program is distributed in the hope that it will be useful, |
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 * GNU Lesser General Public License for more details. |
13 * |
13 * |
14 * Description: |
14 * You should have received a copy of the GNU Lesser General Public License |
|
15 * along with this program. If not, |
|
16 * see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". |
|
17 * |
|
18 * Description: |
15 * |
19 * |
16 */ |
20 */ |
17 |
|
18 #include <QDebug> |
21 #include <QDebug> |
19 #include <QImage> |
22 #include <QImage> |
20 #include <QPainter> |
23 #include <QPainter> |
21 #include <QResizeEvent> |
24 #include <QResizeEvent> |
22 #include <QTimeLine> |
25 #include <QTimeLine> |
24 #include <QGraphicsSceneMouseEvent> |
27 #include <QGraphicsSceneMouseEvent> |
25 #include <QGraphicsSceneMoveEvent> |
28 #include <QGraphicsSceneMoveEvent> |
26 #include <QGraphicsDropShadowEffect> |
29 #include <QGraphicsDropShadowEffect> |
27 #include "linearflowsnippet.h" |
30 #include "linearflowsnippet.h" |
28 |
31 |
29 #define SAFE_DELETE(p) if(p) delete p; |
32 #define SAFE_DELETE(p) if (p) delete p; |
30 |
33 |
31 #define SNIPPET_AUTOHIDE_TIMEOUT 5000 //5secs |
34 #define SNIPPET_AUTOHIDE_TIMEOUT 5000 //5secs |
32 |
35 |
33 #define CALL_ON_PREV_PREV_FILM_STRIP(func) if (d->m_centerIndex - 2 >= 0) d->m_films[d->m_centerIndex - 2]->func; else if(d->m_centerIndex == 1) d->m_films[d->m_films.size() - 1]->func; else d->m_films[d->m_films.size() - 2]->func; |
36 #define CALL_ON_PREV_PREV_FILM_STRIP(func) if (d->m_centerIndex - 2 >= 0) d->m_films[d->m_centerIndex - 2]->func; else if (d->m_centerIndex == 1) d->m_films[d->m_films.size() - 1]->func; else d->m_films[d->m_films.size() - 2]->func; |
34 #define CALL_ON_CENTER_FILM_STRIP(func) if (d->m_centerIndex >= 0 && d->m_centerIndex < d->m_films.size()) d->m_films[d->m_centerIndex]->func; else if(d->m_centerIndex < 0) d->m_films[d->m_films.size() + d->m_centerIndex]->func; else d->m_films[(d->m_centerIndex)%d->m_films.size()]->func; |
37 #define CALL_ON_CENTER_FILM_STRIP(func) if (d->m_centerIndex >= 0 && d->m_centerIndex < d->m_films.size()) d->m_films[d->m_centerIndex]->func; else if (d->m_centerIndex < 0) d->m_films[d->m_films.size() + d->m_centerIndex]->func; else d->m_films[(d->m_centerIndex)%d->m_films.size()]->func; |
35 #define CALL_ON_PREV_PREV_PREV_FILM_STRIP(func) if (d->m_centerIndex - 3 >= 0) d->m_films[d->m_centerIndex - 3]->func; else if(d->m_centerIndex == 1) d->m_films[d->m_films.size() - 2]->func; else if(d->m_centerIndex == 2) d->m_films[d->m_films.size() - 1]->func; else d->m_films[d->m_films.size() - 3]->func; |
38 #define CALL_ON_PREV_PREV_PREV_FILM_STRIP(func) if (d->m_centerIndex - 3 >= 0) d->m_films[d->m_centerIndex - 3]->func; else if (d->m_centerIndex == 1) d->m_films[d->m_films.size() - 2]->func; else if (d->m_centerIndex == 2) d->m_films[d->m_films.size() - 1]->func; else d->m_films[d->m_films.size() - 3]->func; |
36 #define CALL_ON_NEXT_NEXT_NEXT_FILM_STRIP(func) if (d->m_centerIndex + 3 < d->m_films.size()) d->m_films[d->m_centerIndex + 3]->func; else d->m_films[(d->m_centerIndex + 3)%d->m_films.size()]->func; |
39 #define CALL_ON_NEXT_NEXT_NEXT_FILM_STRIP(func) if (d->m_centerIndex + 3 < d->m_films.size()) d->m_films[d->m_centerIndex + 3]->func; else d->m_films[(d->m_centerIndex + 3)%d->m_films.size()]->func; |
37 #define CALL_ON_NEXT_NEXT_FILM_STRIP(func) if (d->m_centerIndex + 2 < d->m_films.size()) d->m_films[d->m_centerIndex + 2]->func; else d->m_films[(d->m_centerIndex + 2)%d->m_films.size()]->func; |
40 #define CALL_ON_NEXT_NEXT_FILM_STRIP(func) if (d->m_centerIndex + 2 < d->m_films.size()) d->m_films[d->m_centerIndex + 2]->func; else d->m_films[(d->m_centerIndex + 2)%d->m_films.size()]->func; |
38 #define CALL_ON_PREV_FILM_STRIP(func) if (d->m_centerIndex - 1 >= 0) d->m_films[d->m_centerIndex - 1]->func; else d->m_films[d->m_films.size() - 1]->func; |
41 #define CALL_ON_PREV_FILM_STRIP(func) if (d->m_centerIndex - 1 >= 0) d->m_films[d->m_centerIndex - 1]->func; else d->m_films[d->m_films.size() - 1]->func; |
39 #define CALL_ON_NEXT_FILM_STRIP(func) if (d->m_centerIndex + 1 < d->m_films.size()) d->m_films[d->m_centerIndex + 1]->func; else d->m_films[(d->m_centerIndex + 1)%d->m_films.size()]->func; |
42 #define CALL_ON_NEXT_FILM_STRIP(func) if (d->m_centerIndex + 1 < d->m_films.size()) d->m_films[d->m_centerIndex + 1]->func; else d->m_films[(d->m_centerIndex + 1)%d->m_films.size()]->func; |
40 |
43 |
41 |
44 |
42 #define INVALID_INDEX -1 |
45 #define INVALID_INDEX -1 |
43 |
46 |
44 #define L_CENTER_WIDTH_P_C 0.27 |
47 #define L_CENTER_WIDTH_P_C 0.27 |
177 void paint(QPainter* painter); |
180 void paint(QPainter* painter); |
178 void paintName(QPainter* painter); |
181 void paintName(QPainter* painter); |
179 |
182 |
180 void freeze() {m_frozen = true;} |
183 void freeze() {m_frozen = true;} |
181 void updateMovie(FilmstripMovie* movie) {m_movie = movie; m_movieFrame = 0; m_frozen = false;} |
184 void updateMovie(FilmstripMovie* movie) {m_movie = movie; m_movieFrame = 0; m_frozen = false;} |
182 void updateMovieFrame(int frame) { if(!m_frozen) m_movieFrame = frame;} |
185 void updateMovieFrame(int frame) { if (!m_frozen) m_movieFrame = frame;} |
183 void setName(const QString& name) {m_name = name;} |
186 void setName(const QString& name) {m_name = name;} |
184 QImage& image() {return m_img;} |
187 QImage& image() {return m_img;} |
185 QString& name() {return m_name;} |
188 QString& name() {return m_name;} |
186 private: |
189 private: |
187 void createEmptyImage(); |
190 void createEmptyImage(); |
196 }; |
199 }; |
197 |
200 |
198 class FilmstripFlowPrivate |
201 class FilmstripFlowPrivate |
199 { |
202 { |
200 public: |
203 public: |
201 FilmstripFlowPrivate(): m_bgColor(QColor(99,105,115).rgb()), m_buffer(NULL), m_titleBuffer(NULL),m_closeIcon(NULL), m_centerTopSpace(0), m_sideTopSpace(0), m_space(0), m_incIndex(0), m_centerIndex(INVALID_INDEX) {} |
204 FilmstripFlowPrivate(): m_bgColor(QColor(68,88,125).rgb()), m_buffer(NULL), m_titleBuffer(NULL),m_closeIcon(NULL), m_centerTopSpace(0), m_sideTopSpace(0), m_space(0), m_incIndex(0), m_centerIndex(INVALID_INDEX) {} |
202 |
205 |
203 ~FilmstripFlowPrivate() { |
206 ~FilmstripFlowPrivate() { |
204 for (int i = 0; i < m_films.size(); i++) |
207 for (int i = 0; i < m_films.size(); i++) |
205 SAFE_DELETE(m_films[i]); |
208 SAFE_DELETE(m_films[i]); |
206 m_films.clear(); |
209 m_films.clear(); |
255 { |
258 { |
256 Q_ASSERT(painter); |
259 Q_ASSERT(painter); |
257 |
260 |
258 if (!m_movie) |
261 if (!m_movie) |
259 return; |
262 return; |
260 |
263 |
261 QRectF target; |
264 QRectF target; |
262 |
265 |
263 bool needFade = (m_movie->m_movieType == FilmstripMovie::FADE_OUT); |
266 bool needFade = (m_movie->m_movieType == FilmstripMovie::FADE_OUT); |
264 if (needFade) // FIXME: no fade out support now |
267 if (needFade) // FIXME: no fade out support now |
265 target = m_movie->movieClip(0); |
268 target = m_movie->movieClip(0); |
266 else |
269 else |
267 target = m_movie->movieClip(m_movieFrame); |
270 target = m_movie->movieClip(m_movieFrame); |
268 |
271 |
269 if(target.right() > 0 || target.left() < m_filmstripFlowData->m_widgetSize.width()) { |
272 if (target.right() > 0 || target.left() < m_filmstripFlowData->m_widgetSize.width()) { |
270 if (needFade) |
273 if (needFade) |
271 painter->setOpacity((ANIMATION_MAX_FRAME - m_movieFrame) / ANIMATION_MAX_FRAME); |
274 painter->setOpacity((ANIMATION_MAX_FRAME - m_movieFrame) / ANIMATION_MAX_FRAME); |
272 |
275 |
273 painter->fillRect(target.adjusted(-FRAME_WIDTH,-FRAME_WIDTH,FRAME_WIDTH,FRAME_WIDTH), QColor(Qt::gray)); |
276 painter->fillRect(target.adjusted(-FRAME_WIDTH,-FRAME_WIDTH,FRAME_WIDTH,FRAME_WIDTH), QColor(Qt::gray)); |
274 |
277 |
275 if(!m_img.isNull()) |
278 if (!m_img.isNull()) |
276 painter->drawImage(target, m_img); |
279 painter->drawImage(target, m_img); |
277 |
280 |
278 else { |
281 else { |
279 painter->save(); |
282 painter->save(); |
280 painter->setPen(QColor(Qt::black)); |
283 painter->setPen(QColor(Qt::black)); |
281 painter->setFont(QFont("Arial", 4)); |
284 painter->setFont(QFont("Arial", 4)); |
282 painter->drawText(target, Qt::AlignVCenter,m_name); |
285 painter->drawText(target, Qt::AlignVCenter,m_name); |
283 painter->restore(); |
286 painter->restore(); |
284 } |
287 } |
285 |
288 |
286 if (needFade) |
289 if (needFade) |
287 painter->setOpacity(1); // restore opacity |
290 painter->setOpacity(1); // restore opacity |
288 } |
291 } |
289 } |
292 } |
290 |
293 |
291 void Filmstrip::paintName(QPainter* painter) |
294 void Filmstrip::paintName(QPainter* painter) |
292 { |
295 { |
366 createLeftLeftInMovie(movie); |
369 createLeftLeftInMovie(movie); |
367 else if (name == BreakinRightRight) |
370 else if (name == BreakinRightRight) |
368 createRightRightInMovie(movie); |
371 createRightRightInMovie(movie); |
369 else if (name == BreakoutLeftLeft) |
372 else if (name == BreakoutLeftLeft) |
370 createLeftLeftOutMovie(movie); |
373 createLeftLeftOutMovie(movie); |
371 else if (name == BreakoutRightRight) |
374 else if (name == BreakoutRightRight) |
372 createRightRightOutMovie(movie); |
375 createRightRightOutMovie(movie); |
373 else if (name == LeftLeftToLeft) |
376 else if (name == LeftLeftToLeft) |
374 createLeftLeftToLeftMovie(movie); |
377 createLeftLeftToLeftMovie(movie); |
375 else if (name == LeftToLeftLeft) |
378 else if (name == LeftToLeftLeft) |
376 createLeftToLeftLeftMovie(movie); |
379 createLeftToLeftLeftMovie(movie); |
377 else if (name == RightToRightRight) |
380 else if (name == RightToRightRight) |
378 createRightToRightRightMovie(movie); |
381 createRightToRightRightMovie(movie); |
379 else if(name == RightRightToRight) |
382 else if (name == RightRightToRight) |
380 createRightRightToRightMovie(movie); |
383 createRightRightToRightMovie(movie); |
381 |
384 |
382 m_moviesCache[name] = movie; |
385 m_moviesCache[name] = movie; |
383 } else { |
386 } else { |
384 movie = m_moviesCache.value(name); |
387 movie = m_moviesCache.value(name); |
385 } |
388 } |
386 return movie; |
389 return movie; |
387 } |
390 } |
388 |
391 |
389 void FilmstripMovieFactory::createLeftLeftInMovie(FilmstripMovie* movie) |
392 void FilmstripMovieFactory::createLeftLeftInMovie(FilmstripMovie* movie) |
390 { |
393 { |
391 movie->m_movieClips.clear(); |
394 movie->m_movieClips.clear(); |
392 int cw = m_filmstripFlowData->m_centerWindowSize.width(); |
395 int cw = m_filmstripFlowData->m_centerWindowSize.width(); |
393 int sw = m_filmstripFlowData->m_sideWindowSize.width(); |
396 int sw = m_filmstripFlowData->m_sideWindowSize.width(); |
394 int sh = m_filmstripFlowData->m_sideWindowSize.height(); |
397 int sh = m_filmstripFlowData->m_sideWindowSize.height(); |
395 int w = m_filmstripFlowData->m_widgetSize.width(); |
398 int w = m_filmstripFlowData->m_widgetSize.width(); |
396 int h = m_filmstripFlowData->m_widgetSize.height(); |
399 int h = m_filmstripFlowData->m_widgetSize.height(); |
397 |
400 |
398 qreal cx = ((w - 4 * m_filmstripFlowData->m_space) - cw) / 2.0 - sw + m_filmstripFlowData->m_space; |
401 qreal cx = ((w - 4 * m_filmstripFlowData->m_space) - cw) / 2.0 - sw + m_filmstripFlowData->m_space; |
399 qreal sx = ((w - 4 * m_filmstripFlowData->m_space) - cw) / 2.0 - 2 * sw; |
402 qreal sx = ((w - 4 * m_filmstripFlowData->m_space) - cw) / 2.0 - 2 * sw; |
400 qreal sy = m_filmstripFlowData->m_sideTopSpace; |
403 qreal sy = m_filmstripFlowData->m_sideTopSpace; |
401 qreal stepx = (cx - sx) / ANIMATION_MAX_FRAME; |
404 qreal stepx = (cx - sx) / ANIMATION_MAX_FRAME; |
402 |
405 |
403 QRectF startRect = QRectF( 2 * sx - cx , sy, sw, sh); |
406 QRectF startRect = QRectF( 2 * sx - cx , sy, sw, sh); |
404 QRectF endRect = QRectF(sx, sy, sw, sh); |
407 QRectF endRect = QRectF(sx, sy, sw, sh); |
414 int sh = m_filmstripFlowData->m_sideWindowSize.height(); |
417 int sh = m_filmstripFlowData->m_sideWindowSize.height(); |
415 int w = m_filmstripFlowData->m_widgetSize.width(); |
418 int w = m_filmstripFlowData->m_widgetSize.width(); |
416 int h = m_filmstripFlowData->m_widgetSize.height(); |
419 int h = m_filmstripFlowData->m_widgetSize.height(); |
417 |
420 |
418 qreal cx = (w + 4 * m_filmstripFlowData->m_space + cw) / 2.0 - m_filmstripFlowData->m_space; |
421 qreal cx = (w + 4 * m_filmstripFlowData->m_space + cw) / 2.0 - m_filmstripFlowData->m_space; |
419 qreal sx = ((w + 4 * m_filmstripFlowData->m_space + cw) / 2.0) + sw ; |
422 qreal sx = ((w + 4 * m_filmstripFlowData->m_space + cw) / 2.0) + sw ; |
420 qreal sy = m_filmstripFlowData->m_sideTopSpace; |
423 qreal sy = m_filmstripFlowData->m_sideTopSpace; |
421 qreal stepx = (cx - sx) / ANIMATION_MAX_FRAME; |
424 qreal stepx = (cx - sx) / ANIMATION_MAX_FRAME; |
422 |
425 |
423 QRectF startRect = QRectF(2 * sx - cx, sy, sw, sh); |
426 QRectF startRect = QRectF(2 * sx - cx, sy, sw, sh); |
424 QRectF endRect = QRectF(sx , sy, sw, sh); |
427 QRectF endRect = QRectF(sx , sy, sw, sh); |
433 int sw = m_filmstripFlowData->m_sideWindowSize.width(); |
436 int sw = m_filmstripFlowData->m_sideWindowSize.width(); |
434 int sh = m_filmstripFlowData->m_sideWindowSize.height(); |
437 int sh = m_filmstripFlowData->m_sideWindowSize.height(); |
435 int w = m_filmstripFlowData->m_widgetSize.width(); |
438 int w = m_filmstripFlowData->m_widgetSize.width(); |
436 int h = m_filmstripFlowData->m_widgetSize.height(); |
439 int h = m_filmstripFlowData->m_widgetSize.height(); |
437 |
440 |
438 qreal cx = ((w - 4 * m_filmstripFlowData->m_space) - cw) / 2.0 - sw + m_filmstripFlowData->m_space; |
441 qreal cx = ((w - 4 * m_filmstripFlowData->m_space) - cw) / 2.0 - sw + m_filmstripFlowData->m_space; |
439 qreal sx = (((w - 4 * m_filmstripFlowData->m_space) - cw) / 2.0) - (2 *sw); |
442 qreal sx = (((w - 4 * m_filmstripFlowData->m_space) - cw) / 2.0) - (2 *sw); |
440 qreal sy = m_filmstripFlowData->m_sideTopSpace; |
443 qreal sy = m_filmstripFlowData->m_sideTopSpace; |
441 qreal stepx = (sx -cx) / ANIMATION_MAX_FRAME; |
444 qreal stepx = (sx -cx) / ANIMATION_MAX_FRAME; |
442 |
445 |
443 QRectF startRect = QRectF(sx, sy, sw, sh); |
446 QRectF startRect = QRectF(sx, sy, sw, sh); |
444 QRectF endRect = QRectF(2 * sx - cx , sy, sw, sh); |
447 QRectF endRect = QRectF(2 * sx - cx , sy, sw, sh); |
454 int sh = m_filmstripFlowData->m_sideWindowSize.height(); |
457 int sh = m_filmstripFlowData->m_sideWindowSize.height(); |
455 int w = m_filmstripFlowData->m_widgetSize.width(); |
458 int w = m_filmstripFlowData->m_widgetSize.width(); |
456 int h = m_filmstripFlowData->m_widgetSize.height(); |
459 int h = m_filmstripFlowData->m_widgetSize.height(); |
457 |
460 |
458 qreal cx = (w + 4 * m_filmstripFlowData->m_space + cw) / 2.0 - m_filmstripFlowData->m_space; |
461 qreal cx = (w + 4 * m_filmstripFlowData->m_space + cw) / 2.0 - m_filmstripFlowData->m_space; |
459 qreal sx = ((w + 4 * m_filmstripFlowData->m_space + cw) / 2.0) + sw ; |
462 qreal sx = ((w + 4 * m_filmstripFlowData->m_space + cw) / 2.0) + sw ; |
460 qreal sy = m_filmstripFlowData->m_sideTopSpace; |
463 qreal sy = m_filmstripFlowData->m_sideTopSpace; |
461 qreal stepx = (sx - cx) / ANIMATION_MAX_FRAME; |
464 qreal stepx = (sx - cx) / ANIMATION_MAX_FRAME; |
462 |
465 |
463 QRectF startRect = QRectF(sx, sy, sw, sh); |
466 QRectF startRect = QRectF(sx, sy, sw, sh); |
464 QRectF endRect = QRectF(2 * sx - cx, sy, sw, sh); |
467 QRectF endRect = QRectF(2 * sx - cx, sy, sw, sh); |
474 int sh = m_filmstripFlowData->m_sideWindowSize.height(); |
477 int sh = m_filmstripFlowData->m_sideWindowSize.height(); |
475 int w = m_filmstripFlowData->m_widgetSize.width(); |
478 int w = m_filmstripFlowData->m_widgetSize.width(); |
476 int h = m_filmstripFlowData->m_widgetSize.height(); |
479 int h = m_filmstripFlowData->m_widgetSize.height(); |
477 |
480 |
478 qreal step = ANIMATION_MAX_FRAME; |
481 qreal step = ANIMATION_MAX_FRAME; |
479 qreal cx = ((w - 4 * m_filmstripFlowData->m_space) - cw) / 2.0 - sw + m_filmstripFlowData->m_space; |
482 qreal cx = ((w - 4 * m_filmstripFlowData->m_space) - cw) / 2.0 - sw + m_filmstripFlowData->m_space; |
480 qreal cy = m_filmstripFlowData->m_centerTopSpace; |
483 qreal cy = m_filmstripFlowData->m_centerTopSpace; |
481 qreal sx = (((w - 4 * m_filmstripFlowData->m_space) - cw) / 2.0) - (2 *sw); |
484 qreal sx = (((w - 4 * m_filmstripFlowData->m_space) - cw) / 2.0) - (2 *sw); |
482 qreal sy = m_filmstripFlowData->m_sideTopSpace; |
485 qreal sy = m_filmstripFlowData->m_sideTopSpace; |
483 qreal stepx = (cx - sx) / step; |
486 qreal stepx = (cx - sx) / step; |
484 qreal stepy = (cy - sy) / step; |
487 qreal stepy = (cy - sy) / step; |
485 qreal stepx2 = stepx + (cw - sw) / step; |
488 qreal stepx2 = stepx + (cw - sw) / step; |
486 qreal stepy2 = stepy + (ch - sh) / step; |
489 qreal stepy2 = stepy + (ch - sh) / step; |
487 |
490 |
488 QRectF startRect = QRectF(sx, sy, sw, sh); |
491 QRectF startRect = QRectF(sx, sy, sw, sh); |
489 QRectF endRect = QRectF(cx, cy, cw, ch); |
492 QRectF endRect = QRectF(cx, cy, cw, ch); |
490 |
493 |
491 addRectByFrame(movie, startRect, endRect, stepx, stepy, stepx2, stepy2); |
494 addRectByFrame(movie, startRect, endRect, stepx, stepy, stepx2, stepy2); |
492 } |
495 } |
500 int sh = m_filmstripFlowData->m_sideWindowSize.height(); |
503 int sh = m_filmstripFlowData->m_sideWindowSize.height(); |
501 int w = m_filmstripFlowData->m_widgetSize.width(); |
504 int w = m_filmstripFlowData->m_widgetSize.width(); |
502 int h = m_filmstripFlowData->m_widgetSize.height(); |
505 int h = m_filmstripFlowData->m_widgetSize.height(); |
503 |
506 |
504 qreal step = ANIMATION_MAX_FRAME; |
507 qreal step = ANIMATION_MAX_FRAME; |
505 qreal cx = ((w - 4 * m_filmstripFlowData->m_space) - cw) / 2.0 - sw + m_filmstripFlowData->m_space; |
508 qreal cx = ((w - 4 * m_filmstripFlowData->m_space) - cw) / 2.0 - sw + m_filmstripFlowData->m_space; |
506 qreal cy = m_filmstripFlowData->m_centerTopSpace; |
509 qreal cy = m_filmstripFlowData->m_centerTopSpace; |
507 qreal sx = (((w - 4 * m_filmstripFlowData->m_space) - cw) / 2.0) - (2 *sw); |
510 qreal sx = (((w - 4 * m_filmstripFlowData->m_space) - cw) / 2.0) - (2 *sw); |
508 qreal sy = m_filmstripFlowData->m_sideTopSpace; |
511 qreal sy = m_filmstripFlowData->m_sideTopSpace; |
509 qreal stepx = (sx - cx) / step; |
512 qreal stepx = (sx - cx) / step; |
510 qreal stepy = (sy - cy) / step; |
513 qreal stepy = (sy - cy) / step; |
511 qreal stepx2 = stepx + (sw - cw) / step; |
514 qreal stepx2 = stepx + (sw - cw) / step; |
512 qreal stepy2 = stepy + (sh - ch) / step; |
515 qreal stepy2 = stepy + (sh - ch) / step; |
513 |
516 |
514 QRectF startRect = QRectF(cx, cy, cw, ch); |
517 QRectF startRect = QRectF(cx, cy, cw, ch); |
515 QRectF endRect = QRectF(sx, sy, sw, sh); |
518 QRectF endRect = QRectF(sx, sy, sw, sh); |
516 addRectByFrame(movie, startRect, endRect, stepx, stepy, stepx2, stepy2); |
519 addRectByFrame(movie, startRect, endRect, stepx, stepy, stepx2, stepy2); |
517 } |
520 } |
518 |
521 |
527 int h = m_filmstripFlowData->m_widgetSize.height(); |
530 int h = m_filmstripFlowData->m_widgetSize.height(); |
528 |
531 |
529 qreal step = ANIMATION_MAX_FRAME; |
532 qreal step = ANIMATION_MAX_FRAME; |
530 qreal cx = (w + 4 * m_filmstripFlowData->m_space + cw) / 2.0 - m_filmstripFlowData->m_space; |
533 qreal cx = (w + 4 * m_filmstripFlowData->m_space + cw) / 2.0 - m_filmstripFlowData->m_space; |
531 qreal cy = m_filmstripFlowData->m_centerTopSpace; |
534 qreal cy = m_filmstripFlowData->m_centerTopSpace; |
532 qreal sx = (((w + 4 * m_filmstripFlowData->m_space) + cw) / 2.0) + sw; |
535 qreal sx = (((w + 4 * m_filmstripFlowData->m_space) + cw) / 2.0) + sw; |
533 qreal sy = m_filmstripFlowData->m_sideTopSpace; |
536 qreal sy = m_filmstripFlowData->m_sideTopSpace; |
534 qreal stepx = (sx - cx) / step; |
537 qreal stepx = (sx - cx) / step; |
535 qreal stepy = (sy - cy) / step; |
538 qreal stepy = (sy - cy) / step; |
536 qreal stepx2 = stepx + (sw - cw) / step; |
539 qreal stepx2 = stepx + (sw - cw) / step; |
537 qreal stepy2 = stepy + (sh - ch) / step; |
540 qreal stepy2 = stepy + (sh - ch) / step; |
538 |
541 |
539 QRectF startRect = QRectF(cx, cy, cw, ch); |
542 QRectF startRect = QRectF(cx, cy, cw, ch); |
540 QRectF endRect = QRectF(sx, sy, sw, sh); |
543 QRectF endRect = QRectF(sx, sy, sw, sh); |
541 addRectByFrame(movie, startRect, endRect, stepx, stepy, stepx2, stepy2); |
544 addRectByFrame(movie, startRect, endRect, stepx, stepy, stepx2, stepy2); |
542 |
545 |
543 } |
546 } |
544 |
547 |
545 void FilmstripMovieFactory::createRightRightToRightMovie(FilmstripMovie* movie) |
548 void FilmstripMovieFactory::createRightRightToRightMovie(FilmstripMovie* movie) |
546 { |
549 { |
547 movie->m_movieClips.clear(); |
550 movie->m_movieClips.clear(); |
553 int h = m_filmstripFlowData->m_widgetSize.height(); |
556 int h = m_filmstripFlowData->m_widgetSize.height(); |
554 |
557 |
555 qreal step = ANIMATION_MAX_FRAME; |
558 qreal step = ANIMATION_MAX_FRAME; |
556 qreal cx = (w + 4 * m_filmstripFlowData->m_space + cw) / 2.0 - m_filmstripFlowData->m_space; |
559 qreal cx = (w + 4 * m_filmstripFlowData->m_space + cw) / 2.0 - m_filmstripFlowData->m_space; |
557 qreal cy = m_filmstripFlowData->m_centerTopSpace; |
560 qreal cy = m_filmstripFlowData->m_centerTopSpace; |
558 qreal sx = ((w + 4 * m_filmstripFlowData->m_space) + cw) / 2.0 + sw; |
561 qreal sx = ((w + 4 * m_filmstripFlowData->m_space) + cw) / 2.0 + sw; |
559 qreal sy = m_filmstripFlowData->m_sideTopSpace; |
562 qreal sy = m_filmstripFlowData->m_sideTopSpace; |
560 qreal stepx = (cx - sx) / step; |
563 qreal stepx = (cx - sx) / step; |
561 qreal stepy = (cy - sy) / step; |
564 qreal stepy = (cy - sy) / step; |
562 qreal stepx2 = stepx + (cw - sw) / step; |
565 qreal stepx2 = stepx + (cw - sw) / step; |
563 qreal stepy2 = stepy + (ch - sh) / step; |
566 qreal stepy2 = stepy + (ch - sh) / step; |
564 |
567 |
565 QRectF startRect = QRectF(sx, sy, sw, sh); |
568 QRectF startRect = QRectF(sx, sy, sw, sh); |
566 QRectF endRect = QRectF(cx, cy, cw, ch); |
569 QRectF endRect = QRectF(cx, cy, cw, ch); |
567 |
570 |
568 addRectByFrame(movie, startRect, endRect, stepx, stepy, stepx2, stepy2); |
571 addRectByFrame(movie, startRect, endRect, stepx, stepy, stepx2, stepy2); |
569 } |
572 } |
570 |
573 |
571 |
574 |
572 void FilmstripMovieFactory::addRectByFrame(FilmstripMovie* movie, QRectF& startRect, QRectF& endRect, qreal x1, qreal y1, qreal x2, qreal y2, bool debug) |
575 void FilmstripMovieFactory::addRectByFrame(FilmstripMovie* movie, QRectF& startRect, QRectF& endRect, qreal x1, qreal y1, qreal x2, qreal y2, bool debug) |
573 { |
576 { |
574 movie->m_movieClips.append(startRect); |
577 movie->m_movieClips.append(startRect); |
575 if (debug) |
|
576 qDebug() << "0:" << startRect; |
|
577 for (int i = 1; i < ANIMATION_MAX_FRAME; i++) { |
578 for (int i = 1; i < ANIMATION_MAX_FRAME; i++) { |
578 if (debug) |
|
579 qDebug() << i << ":" << movie->m_movieClips[i - 1].adjusted(x1, y1, x2, y2); |
|
580 movie->m_movieClips.append(movie->m_movieClips[i - 1].adjusted(x1, y1, x2, y2)); |
579 movie->m_movieClips.append(movie->m_movieClips[i - 1].adjusted(x1, y1, x2, y2)); |
581 } |
580 } |
582 movie->m_movieClips.append(endRect); |
581 movie->m_movieClips.append(endRect); |
583 if (debug) |
|
584 qDebug() << movie->m_movieClips.size() - 1 << ":" << endRect; |
|
585 } |
582 } |
586 |
583 |
587 void FilmstripMovieFactory::createLeftToCenterMovie(FilmstripMovie* movie) |
584 void FilmstripMovieFactory::createLeftToCenterMovie(FilmstripMovie* movie) |
588 { |
585 { |
589 movie->m_movieClips.clear(); |
586 movie->m_movieClips.clear(); |
621 int h = m_filmstripFlowData->m_widgetSize.height(); |
618 int h = m_filmstripFlowData->m_widgetSize.height(); |
622 |
619 |
623 qreal step = ANIMATION_MAX_FRAME; |
620 qreal step = ANIMATION_MAX_FRAME; |
624 qreal cx = (w - cw) / 2.0; |
621 qreal cx = (w - cw) / 2.0; |
625 qreal cy = m_filmstripFlowData->m_centerTopSpace; |
622 qreal cy = m_filmstripFlowData->m_centerTopSpace; |
626 qreal sx = ((w + 4 * m_filmstripFlowData->m_space) + cw) / 2.0 - m_filmstripFlowData->m_space; |
623 qreal sx = ((w + 4 * m_filmstripFlowData->m_space) + cw) / 2.0 - m_filmstripFlowData->m_space; |
627 qreal sy = m_filmstripFlowData->m_sideTopSpace; |
624 qreal sy = m_filmstripFlowData->m_sideTopSpace; |
628 qreal stepx = (cx - sx) / step; |
625 qreal stepx = (cx - sx) / step; |
629 qreal stepy = (cy - sy) / step; |
626 qreal stepy = (cy - sy) / step; |
630 qreal stepx2 = stepx + (cw - sw) / step; |
627 qreal stepx2 = stepx + (cw - sw) / step; |
631 qreal stepy2 = stepy + (ch - sh) / step; |
628 qreal stepy2 = stepy + (ch - sh) / step; |
647 int h = m_filmstripFlowData->m_widgetSize.height(); |
644 int h = m_filmstripFlowData->m_widgetSize.height(); |
648 |
645 |
649 qreal step = ANIMATION_MAX_FRAME; |
646 qreal step = ANIMATION_MAX_FRAME; |
650 qreal cx = (w - cw) / 2.0; |
647 qreal cx = (w - cw) / 2.0; |
651 qreal cy = m_filmstripFlowData->m_centerTopSpace; |
648 qreal cy = m_filmstripFlowData->m_centerTopSpace; |
652 qreal sx = (((w - 4 * m_filmstripFlowData->m_space) - cw) / 2.0) - sw + m_filmstripFlowData->m_space; |
649 qreal sx = (((w - 4 * m_filmstripFlowData->m_space) - cw) / 2.0) - sw + m_filmstripFlowData->m_space; |
653 qreal sy = m_filmstripFlowData->m_sideTopSpace; |
650 qreal sy = m_filmstripFlowData->m_sideTopSpace; |
654 qreal stepx = (sx - cx) / step; |
651 qreal stepx = (sx - cx) / step; |
655 qreal stepy = (sy - cy) / step; |
652 qreal stepy = (sy - cy) / step; |
656 qreal stepx2 = stepx + (sw - cw) / step; |
653 qreal stepx2 = stepx + (sw - cw) / step; |
657 qreal stepy2 = stepy + (sh - ch) / step; |
654 qreal stepy2 = stepy + (sh - ch) / step; |
697 |
694 |
698 qreal cx = (w - cw) / 2.0; |
695 qreal cx = (w - cw) / 2.0; |
699 qreal sx = (w * (1 - 2 * m_filmstripFlowData->m_space) - cw) / 2.0 - sw; |
696 qreal sx = (w * (1 - 2 * m_filmstripFlowData->m_space) - cw) / 2.0 - sw; |
700 qreal sy = m_filmstripFlowData->m_sideTopSpace; |
697 qreal sy = m_filmstripFlowData->m_sideTopSpace; |
701 qreal stepx = (sx -cx) / ANIMATION_MAX_FRAME; |
698 qreal stepx = (sx -cx) / ANIMATION_MAX_FRAME; |
702 |
699 |
703 QRectF startRect = QRectF(sx, sy, sw, sh); |
700 QRectF startRect = QRectF(sx, sy, sw, sh); |
704 QRectF endRect = QRectF(2 * sx - cx , sy, sw, sh); |
701 QRectF endRect = QRectF(2 * sx - cx , sy, sw, sh); |
705 |
702 |
706 addRectByFrame(movie, startRect, endRect, stepx, 0, stepx, 0); |
703 addRectByFrame(movie, startRect, endRect, stepx, 0, stepx, 0); |
707 } |
704 } |
714 int sh = m_filmstripFlowData->m_sideWindowSize.height(); |
711 int sh = m_filmstripFlowData->m_sideWindowSize.height(); |
715 int w = m_filmstripFlowData->m_widgetSize.width(); |
712 int w = m_filmstripFlowData->m_widgetSize.width(); |
716 int h = m_filmstripFlowData->m_widgetSize.height(); |
713 int h = m_filmstripFlowData->m_widgetSize.height(); |
717 |
714 |
718 qreal cx = (w - cw) / 2.0; |
715 qreal cx = (w - cw) / 2.0; |
719 qreal sx = (w * (1 - 2 * m_filmstripFlowData->m_space) - cw) / 2.0 - sw; |
716 qreal sx = (w * (1 - 2 * m_filmstripFlowData->m_space) - cw) / 2.0 - sw; |
720 qreal sy = m_filmstripFlowData->m_sideTopSpace; |
717 qreal sy = m_filmstripFlowData->m_sideTopSpace; |
721 qreal stepx = (cx - sx) / ANIMATION_MAX_FRAME; |
718 qreal stepx = (cx - sx) / ANIMATION_MAX_FRAME; |
722 |
719 |
723 QRectF startRect = QRectF(2 * sx - cx , sy, sw, sh); |
720 QRectF startRect = QRectF(2 * sx - cx , sy, sw, sh); |
724 QRectF endRect = QRectF(sx, sy, sw, sh); |
721 QRectF endRect = QRectF(sx, sy, sw, sh); |
725 |
722 |
726 addRectByFrame(movie, startRect, endRect, stepx, 0, stepx, 0); |
723 addRectByFrame(movie, startRect, endRect, stepx, 0, stepx, 0); |
727 } |
724 } |
734 int sh = m_filmstripFlowData->m_sideWindowSize.height(); |
731 int sh = m_filmstripFlowData->m_sideWindowSize.height(); |
735 int w = m_filmstripFlowData->m_widgetSize.width(); |
732 int w = m_filmstripFlowData->m_widgetSize.width(); |
736 int h = m_filmstripFlowData->m_widgetSize.height(); |
733 int h = m_filmstripFlowData->m_widgetSize.height(); |
737 |
734 |
738 qreal cx = (w - cw) / 2.0; |
735 qreal cx = (w - cw) / 2.0; |
739 qreal sx = (w * (1 + 2 * m_filmstripFlowData->m_space) + cw) / 2.0; |
736 qreal sx = (w * (1 + 2 * m_filmstripFlowData->m_space) + cw) / 2.0; |
740 qreal sy = m_filmstripFlowData->m_sideTopSpace; |
737 qreal sy = m_filmstripFlowData->m_sideTopSpace; |
741 qreal stepx = (sx - cx) / ANIMATION_MAX_FRAME; |
738 qreal stepx = (sx - cx) / ANIMATION_MAX_FRAME; |
742 |
739 |
743 QRectF startRect = QRectF(sx, sy, sw, sh); |
740 QRectF startRect = QRectF(sx, sy, sw, sh); |
744 QRectF endRect = QRectF(sx + sx -cx, sy, sw, sh); |
741 QRectF endRect = QRectF(sx + sx -cx, sy, sw, sh); |
753 int sh = m_filmstripFlowData->m_sideWindowSize.height(); |
750 int sh = m_filmstripFlowData->m_sideWindowSize.height(); |
754 int w = m_filmstripFlowData->m_widgetSize.width(); |
751 int w = m_filmstripFlowData->m_widgetSize.width(); |
755 int h = m_filmstripFlowData->m_widgetSize.height(); |
752 int h = m_filmstripFlowData->m_widgetSize.height(); |
756 |
753 |
757 qreal cx = (w - cw) / 2.0; |
754 qreal cx = (w - cw) / 2.0; |
758 qreal sx = (w * (1 + 2 * m_filmstripFlowData->m_space) + cw) / 2.0; |
755 qreal sx = (w * (1 + 2 * m_filmstripFlowData->m_space) + cw) / 2.0; |
759 qreal sy = m_filmstripFlowData->m_sideTopSpace; |
756 qreal sy = m_filmstripFlowData->m_sideTopSpace; |
760 qreal stepx = (cx - sx) / ANIMATION_MAX_FRAME; |
757 qreal stepx = (cx - sx) / ANIMATION_MAX_FRAME; |
761 |
758 |
762 QRectF startRect = QRectF(sx + sx -cx, sy, sw, sh); |
759 QRectF startRect = QRectF(sx + sx -cx, sy, sw, sh); |
763 QRectF endRect = QRectF(sx, sy, sw, sh); |
760 QRectF endRect = QRectF(sx, sy, sw, sh); |
795 |
792 |
796 qreal stepx = - cx / step; |
793 qreal stepx = - cx / step; |
797 qreal stepy = - cy / step; |
794 qreal stepy = - cy / step; |
798 qreal stepx2 = - stepx; |
795 qreal stepx2 = - stepx; |
799 qreal stepy2 = (h - cy - ch) / step; |
796 qreal stepy2 = (h - cy - ch) / step; |
800 |
797 |
801 QRectF startRect = QRectF(cx, cy, cw, ch); |
798 QRectF startRect = QRectF(cx, cy, cw, ch); |
802 QRectF endRect = QRectF(0, 0, w, h); |
799 QRectF endRect = QRectF(0, 0, w, h); |
803 |
800 |
804 addRectByFrame(movie, startRect, endRect, stepx, stepy, stepx2, stepy2); |
801 addRectByFrame(movie, startRect, endRect, stepx, stepy, stepx2, stepy2); |
805 } |
802 } |
882 if (i != m_moviesCache.end()) { |
879 if (i != m_moviesCache.end()) { |
883 FilmstripMovie* movie = m_moviesCache.value(BreakinLeftLeft); |
880 FilmstripMovie* movie = m_moviesCache.value(BreakinLeftLeft); |
884 createLeftLeftInMovie(movie); |
881 createLeftLeftInMovie(movie); |
885 } |
882 } |
886 |
883 |
887 |
884 |
888 i = m_moviesCache.find(BreakinRightRight); |
885 i = m_moviesCache.find(BreakinRightRight); |
889 if (i != m_moviesCache.end()) { |
886 if (i != m_moviesCache.end()) { |
890 FilmstripMovie* movie = m_moviesCache.value(BreakinRightRight); |
887 FilmstripMovie* movie = m_moviesCache.value(BreakinRightRight); |
891 createRightRightInMovie(movie); |
888 createRightRightInMovie(movie); |
892 } |
889 } |
893 |
890 |
894 i = m_moviesCache.find(BreakoutLeftLeft); |
891 i = m_moviesCache.find(BreakoutLeftLeft); |
895 if (i != m_moviesCache.end()) { |
892 if (i != m_moviesCache.end()) { |
896 FilmstripMovie* movie = m_moviesCache.value(BreakoutLeftLeft); |
893 FilmstripMovie* movie = m_moviesCache.value(BreakoutLeftLeft); |
897 createLeftLeftOutMovie(movie); |
894 createLeftLeftOutMovie(movie); |
898 } |
895 } |
899 |
896 |
900 i = m_moviesCache.find(BreakoutRightRight); |
897 i = m_moviesCache.find(BreakoutRightRight); |
901 if (i != m_moviesCache.end()) { |
898 if (i != m_moviesCache.end()) { |
902 FilmstripMovie* movie = m_moviesCache.value(BreakoutRightRight); |
899 FilmstripMovie* movie = m_moviesCache.value(BreakoutRightRight); |
903 createRightRightOutMovie(movie); |
900 createRightRightOutMovie(movie); |
904 } |
901 } |
905 |
902 |
906 i = m_moviesCache.find(LeftLeftToLeft); |
903 i = m_moviesCache.find(LeftLeftToLeft); |
907 if (i != m_moviesCache.end()) { |
904 if (i != m_moviesCache.end()) { |
908 FilmstripMovie* movie = m_moviesCache.value(LeftLeftToLeft); |
905 FilmstripMovie* movie = m_moviesCache.value(LeftLeftToLeft); |
909 createLeftLeftToLeftMovie(movie); |
906 createLeftLeftToLeftMovie(movie); |
910 } |
907 } |
911 |
908 |
912 i = m_moviesCache.find(LeftToLeftLeft); |
909 i = m_moviesCache.find(LeftToLeftLeft); |
913 if (i != m_moviesCache.end()) { |
910 if (i != m_moviesCache.end()) { |
914 FilmstripMovie* movie = m_moviesCache.value(LeftToLeftLeft); |
911 FilmstripMovie* movie = m_moviesCache.value(LeftToLeftLeft); |
915 createLeftToLeftLeftMovie(movie); |
912 createLeftToLeftLeftMovie(movie); |
916 } |
913 } |
917 |
914 |
918 i = m_moviesCache.find(RightToRightRight); |
915 i = m_moviesCache.find(RightToRightRight); |
919 if (i != m_moviesCache.end()) { |
916 if (i != m_moviesCache.end()) { |
920 FilmstripMovie* movie = m_moviesCache.value(RightToRightRight); |
917 FilmstripMovie* movie = m_moviesCache.value(RightToRightRight); |
921 createRightToRightRightMovie(movie); |
918 createRightToRightRightMovie(movie); |
922 } |
919 } |
923 |
920 |
924 i = m_moviesCache.find(RightRightToRight); |
921 i = m_moviesCache.find(RightRightToRight); |
925 if (i != m_moviesCache.end()) { |
922 if (i != m_moviesCache.end()) { |
926 FilmstripMovie* movie = m_moviesCache.value(RightRightToRight); |
923 FilmstripMovie* movie = m_moviesCache.value(RightRightToRight); |
927 createRightRightToRightMovie(movie); |
924 createRightRightToRightMovie(movie); |
928 } |
925 } |
985 } |
982 } |
986 |
983 |
987 /*! |
984 /*! |
988 Set center index |
985 Set center index |
989 */ |
986 */ |
990 void LinearFlowSnippet::setCenterIndex(int i) |
987 void LinearFlowSnippet::setCenterIndex(int i) |
991 { |
988 { |
992 Q_ASSERT(d); |
989 Q_ASSERT(d); |
993 if (!d->m_films.size()) |
990 if (!d->m_films.size()) |
994 return; |
991 return; |
995 |
992 |
996 if(d->m_centerIndex == i) |
993 if (d->m_centerIndex == i) |
997 return; |
994 return; |
998 |
995 |
999 if(i < 0) |
996 if (i < 0) |
1000 i = (d->m_films.size() + i); |
997 i = (d->m_films.size() + i); |
1001 else if(d->m_centerIndex >= d->m_films.size() - 1) |
998 else if (d->m_centerIndex >= d->m_films.size() - 1) |
1002 i = i % d->m_films.size(); |
999 i = i % d->m_films.size(); |
1003 |
1000 |
1004 d->m_centerIndex = i; |
1001 d->m_centerIndex = i; |
1005 |
1002 |
1006 CALL_ON_PREV_PREV_PREV_FILM_STRIP(updateMovie(NULL)); |
1003 CALL_ON_PREV_PREV_PREV_FILM_STRIP(updateMovie(NULL)); |
1007 CALL_ON_NEXT_NEXT_NEXT_FILM_STRIP(updateMovie(NULL)); |
1004 CALL_ON_NEXT_NEXT_NEXT_FILM_STRIP(updateMovie(NULL)); |
1008 d->m_films[d->m_centerIndex]->updateMovie(d->m_movieFactory.createMovie(CenterToRight)); |
1005 d->m_films[d->m_centerIndex]->updateMovie(d->m_movieFactory.createMovie(CenterToRight)); |
1009 CALL_ON_PREV_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(LeftToCenter))); |
1006 CALL_ON_PREV_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(LeftToCenter))); |
1010 CALL_ON_PREV_PREV_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(LeftLeftToLeft))); |
1007 CALL_ON_PREV_PREV_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(LeftLeftToLeft))); |
1011 CALL_ON_NEXT_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(RightToRightRight))); |
1008 CALL_ON_NEXT_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(RightToRightRight))); |
1012 CALL_ON_NEXT_NEXT_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(BreakoutRightRight))); |
1009 CALL_ON_NEXT_NEXT_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(BreakoutRightRight))); |
1013 |
1010 |
1014 emit centerIndexChanged(i); |
1011 emit centerIndexChanged(i); |
1015 } |
1012 } |
1016 |
1013 |
1017 /*! |
1014 /*! |
1035 d->m_films.append(filmstrip); |
1032 d->m_films.append(filmstrip); |
1036 } |
1033 } |
1037 |
1034 |
1038 /*! |
1035 /*! |
1039 Inserts filmstrip at index position i. |
1036 Inserts filmstrip at index position i. |
1040 If i is 0, the filmstrip is prepended to the film list. |
1037 If i is 0, the filmstrip is prepended to the film list. |
1041 If i is size(), the value is appended to the film list. |
1038 If i is size(), the value is appended to the film list. |
1042 */ |
1039 */ |
1043 void LinearFlowSnippet::insert(int i, const QImage& image, const QString& title) |
1040 void LinearFlowSnippet::insert(int i, const QImage& image, const QString& title) |
1044 { |
1041 { |
1045 Q_ASSERT(d); |
1042 Q_ASSERT(d); |
1046 Q_ASSERT(i >= 0 && i <= d->m_films.size()); |
1043 Q_ASSERT(i >= 0 && i <= d->m_films.size()); |
1047 |
1044 |
1048 Filmstrip* filmstrip = new Filmstrip(image, d); |
1045 Filmstrip* filmstrip = new Filmstrip(image, d); |
1049 filmstrip->setName(title); |
1046 filmstrip->setName(title); |
1050 d->m_films.insert(i, filmstrip); |
1047 d->m_films.insert(i, filmstrip); |
1051 |
1048 |
1052 if (isVisible()) { |
1049 if (isVisible()) { |
1053 Q_ASSERT(d->m_movieTimer.state() != QTimeLine::Running); |
1050 Q_ASSERT(d->m_movieTimer.state() != QTimeLine::Running); |
1054 if (i == d->m_centerIndex + 1) // insert on right |
1051 if (i == d->m_centerIndex + 1) // insert on right |
1055 showInsertOnRight(); |
1052 showInsertOnRight(); |
1056 else if (i == d->m_centerIndex) // insert on left |
1053 else if (i == d->m_centerIndex) // insert on left |
1070 if (isVisible()) { |
1067 if (isVisible()) { |
1071 // Not use Q_ASSERT here because the deletion-op is UI buildin -- tap the close button |
1068 // Not use Q_ASSERT here because the deletion-op is UI buildin -- tap the close button |
1072 if (d->m_movieTimer.state() == QTimeLine::Running) |
1069 if (d->m_movieTimer.state() == QTimeLine::Running) |
1073 return; |
1070 return; |
1074 |
1071 |
1075 d->m_films[d->m_centerIndex]->updateMovie(d->m_movieFactory.createMovie(FadeOut)); // move center slide to left |
1072 d->m_films[d->m_centerIndex]->updateMovie(d->m_movieFactory.createMovie(FadeOut)); // move center slide to left |
1076 CALL_ON_PREV_FILM_STRIP(freeze()); // no movement for left slide |
1073 CALL_ON_PREV_FILM_STRIP(freeze()); // no movement for left slide |
1077 CALL_ON_NEXT_FILM_STRIP(freeze()); // no movement for right slide |
1074 CALL_ON_NEXT_FILM_STRIP(freeze()); // no movement for right slide |
1078 |
1075 |
1079 QObject::disconnect(&d->m_movieTimer, SIGNAL(finished()), this, SLOT(stopMovie())); |
1076 QObject::disconnect(&d->m_movieTimer, SIGNAL(finished()), this, SLOT(stopMovie())); |
1080 QObject::connect(&d->m_movieTimer, SIGNAL(finished()), this, SLOT(closeAnimation())); |
1077 QObject::connect(&d->m_movieTimer, SIGNAL(finished()), this, SLOT(closeAnimation())); |
1123 Q_ASSERT( i >=0 && i < d->m_films.size()); |
1120 Q_ASSERT( i >=0 && i < d->m_films.size()); |
1124 return d->m_films.at(i)->image(); |
1121 return d->m_films.at(i)->image(); |
1125 } |
1122 } |
1126 |
1123 |
1127 //! return true if slide animation is ongoing |
1124 //! return true if slide animation is ongoing |
1128 bool LinearFlowSnippet::slideAnimationOngoing() const |
1125 bool LinearFlowSnippet::slideAnimationOngoing() const |
1129 { |
1126 { |
1130 Q_ASSERT(d); |
1127 Q_ASSERT(d); |
1131 return d->m_movieTimer.state() == QTimeLine::Running; |
1128 return d->m_movieTimer.state() == QTimeLine::Running; |
1132 } |
1129 } |
1133 |
1130 |
1134 //! return center slide's rect |
1131 //! return center slide's rect |
1135 QRect LinearFlowSnippet::centralRect() const |
1132 QRect LinearFlowSnippet::centralRect() const |
1136 { |
1133 { |
1137 Q_ASSERT(d); |
1134 Q_ASSERT(d); |
1138 int cw = d->m_centerWindowSize.width(); |
1135 int cw = d->m_centerWindowSize.width(); |
1139 int ch = d->m_centerWindowSize.height(); |
1136 int ch = d->m_centerWindowSize.height(); |
1140 int w = size().width(); |
1137 int w = size().width(); |
1146 } |
1143 } |
1147 |
1144 |
1148 //! prepare start-animation |
1145 //! prepare start-animation |
1149 void LinearFlowSnippet::prepareStartAnimation() |
1146 void LinearFlowSnippet::prepareStartAnimation() |
1150 { |
1147 { |
1151 CALL_ON_PREV_PREV_PREV_FILM_STRIP(updateMovie(NULL)); |
1148 CALL_ON_PREV_PREV_PREV_FILM_STRIP(updateMovie(NULL)); |
1152 CALL_ON_NEXT_NEXT_NEXT_FILM_STRIP(updateMovie(NULL)); |
1149 CALL_ON_NEXT_NEXT_NEXT_FILM_STRIP(updateMovie(NULL)); |
1153 CALL_ON_PREV_PREV_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(BreakinLeftLeft))); |
1150 CALL_ON_PREV_PREV_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(BreakinLeftLeft))); |
1154 CALL_ON_CENTER_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(LeftToCenter))); |
1151 CALL_ON_CENTER_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(LeftToCenter))); |
1155 CALL_ON_NEXT_NEXT_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(BreakinRightRight))); |
1152 CALL_ON_NEXT_NEXT_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(BreakinRightRight))); |
1156 CALL_ON_PREV_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(LeftLeftToLeft))); |
1153 CALL_ON_PREV_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(LeftLeftToLeft))); |
1157 CALL_ON_NEXT_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(RightRightToRight))); |
1154 CALL_ON_NEXT_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(RightRightToRight))); |
1158 } |
1155 } |
1170 void LinearFlowSnippet::runEndAnimation() |
1167 void LinearFlowSnippet::runEndAnimation() |
1171 { |
1168 { |
1172 Q_ASSERT(d); |
1169 Q_ASSERT(d); |
1173 if (d->m_movieTimer.state() == QTimeLine::Running) |
1170 if (d->m_movieTimer.state() == QTimeLine::Running) |
1174 return; |
1171 return; |
1175 |
1172 |
1176 CALL_ON_PREV_PREV_PREV_FILM_STRIP(freeze()); |
1173 CALL_ON_PREV_PREV_PREV_FILM_STRIP(freeze()); |
1177 CALL_ON_NEXT_NEXT_NEXT_FILM_STRIP(freeze()); |
1174 CALL_ON_NEXT_NEXT_NEXT_FILM_STRIP(freeze()); |
1178 CALL_ON_PREV_PREV_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(BreakoutLeftLeft))); |
1175 CALL_ON_PREV_PREV_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(BreakoutLeftLeft))); |
1179 CALL_ON_PREV_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(LeftToLeftLeft))); |
1176 CALL_ON_PREV_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(LeftToLeftLeft))); |
1180 CALL_ON_CENTER_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(CenterToLeft))); |
1177 CALL_ON_CENTER_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(CenterToLeft))); |
1181 CALL_ON_NEXT_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(RightToRightRight))); |
1178 CALL_ON_NEXT_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(RightToRightRight))); |
1182 CALL_ON_NEXT_NEXT_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(BreakoutRightRight))); |
1179 CALL_ON_NEXT_NEXT_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(BreakoutRightRight))); |
1183 |
1180 |
1184 QObject::disconnect(&d->m_movieTimer, SIGNAL(finished()), this, SLOT(stopMovie())); |
1181 QObject::disconnect(&d->m_movieTimer, SIGNAL(finished()), this, SLOT(stopMovie())); |
1185 QObject::connect(&d->m_movieTimer, SIGNAL(finished()), this, SIGNAL(endAnimationCplt())); |
1182 QObject::connect(&d->m_movieTimer, SIGNAL(finished()), this, SIGNAL(endAnimationCplt())); |
1186 d->m_movieTimer.start(); |
1183 d->m_movieTimer.start(); |
1217 QPainter painter(d->m_titleBuffer); |
1214 QPainter painter(d->m_titleBuffer); |
1218 painter.fillRect(0,0,d->m_titleBuffer->width(),d->m_titleBuffer->height(),d->m_bgColor); |
1215 painter.fillRect(0,0,d->m_titleBuffer->width(),d->m_titleBuffer->height(),d->m_bgColor); |
1219 |
1216 |
1220 QFont font; |
1217 QFont font; |
1221 font.setBold(true); |
1218 font.setBold(true); |
1222 font.setPixelSize(13); |
1219 font.setPixelSize(20); |
1223 font.setWeight(QFont::Bold); |
1220 font.setWeight(QFont::Bold); |
1224 painter.setPen(QColor(169,169,169)); |
1221 painter.setPen(QColor(255,255,255)); |
1225 painter.setFont(font); |
1222 painter.setFont(font); |
1226 painter.drawText(QPointF(0,s.height() * TITLE_HEIGHT - 3),m_titleName); |
1223 painter.drawText(QPointF(3,s.height() * TITLE_HEIGHT),m_titleName); |
1227 |
1224 |
1228 d->m_sideWindowSize = QSize(WIDTH * L_SIDE_WIDTH_P_C, h * L_SIDE_HEIGHT_P_C); |
1225 d->m_sideWindowSize = QSize(WIDTH * L_SIDE_WIDTH_P_C, h * L_SIDE_HEIGHT_P_C); |
1229 d->m_centerWindowSize = QSize(WIDTH * L_CENTER_WIDTH_P_C, h * L_CENTER_HEIGHT_P_C); |
1226 d->m_centerWindowSize = QSize(WIDTH * L_CENTER_WIDTH_P_C, h * L_CENTER_HEIGHT_P_C); |
1230 d->m_centerTopSpace = h * L_CENTER_TOP_SPACE_P_C; |
1227 d->m_centerTopSpace = h * L_CENTER_TOP_SPACE_P_C; |
1231 d->m_sideTopSpace = h * L_SIDE_TOP_SPACE_P_C ; |
1228 d->m_sideTopSpace = h * L_SIDE_TOP_SPACE_P_C ; |
1232 |
1229 |
1233 if( m_displayMode == "Portrait") { |
1230 if ( m_displayMode == "Portrait") { |
1234 d->m_space = ((qreal)w - ( P_MAX_SLIDE - 1) * (qreal)d->m_sideWindowSize.width() - (qreal)d->m_centerWindowSize.width())/(P_MAX_SLIDE + 1); |
1231 d->m_space = ((qreal)w - ( P_MAX_SLIDE - 1) * (qreal)d->m_sideWindowSize.width() - (qreal)d->m_centerWindowSize.width())/(P_MAX_SLIDE + 1); |
1235 } |
1232 } |
1236 else { |
1233 else { |
1237 d->m_space = ((qreal)w - ( L_MAX_SLIDE - 1) * (qreal)d->m_sideWindowSize.width() - (qreal)d->m_centerWindowSize.width())/(L_MAX_SLIDE + 1); |
1234 d->m_space = ((qreal)w - ( L_MAX_SLIDE - 1) * (qreal)d->m_sideWindowSize.width() - (qreal)d->m_centerWindowSize.width())/(L_MAX_SLIDE + 1); |
1238 } |
1235 } |
1243 qreal iy = d->m_centerTopSpace - d->m_closeIcon->size().height()/2.0; |
1240 qreal iy = d->m_centerTopSpace - d->m_closeIcon->size().height()/2.0; |
1244 d->m_closeIconPos = QPoint(ix, iy); |
1241 d->m_closeIconPos = QPoint(ix, iy); |
1245 } |
1242 } |
1246 d->m_movieFactory.updateAllMovie(); |
1243 d->m_movieFactory.updateAllMovie(); |
1247 |
1244 |
1248 if(d->m_centerIndex != -1) { |
1245 if (d->m_centerIndex != -1) { |
1249 if(m_displayMode == "Portrait") |
1246 if (m_displayMode == "Portrait") |
1250 setCenterIndex(d->m_centerIndex - 1); |
1247 setCenterIndex(d->m_centerIndex - 1); |
1251 else |
1248 else |
1252 setCenterIndex(d->m_centerIndex + 1); |
1249 setCenterIndex(d->m_centerIndex + 1); |
1253 } |
1250 } |
1254 } |
1251 } |
1255 |
1252 |
1256 //! insert a new filmstrip on current's right |
1253 //! insert a new filmstrip on current's right |
1257 void LinearFlowSnippet::showInsertOnRight() |
1254 void LinearFlowSnippet::showInsertOnRight() |
1258 { |
1255 { |
1259 Q_ASSERT(d); |
1256 Q_ASSERT(d); |
1260 d->m_incIndex = 1; |
1257 d->m_incIndex = 1; |
1261 d->m_films[d->m_centerIndex]->updateMovie(d->m_movieFactory.createMovie(CenterToLeft)); // move center slide to left |
1258 d->m_films[d->m_centerIndex]->updateMovie(d->m_movieFactory.createMovie(CenterToLeft)); // move center slide to left |
1262 |
1259 |
1263 CALL_ON_PREV_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(BreakoutLeft))); // move left slide out |
1260 CALL_ON_PREV_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(BreakoutLeft))); // move left slide out |
1264 CALL_ON_NEXT_NEXT_FILM_STRIP(freeze());// no movement for right slide |
1261 CALL_ON_NEXT_NEXT_FILM_STRIP(freeze());// no movement for right slide |
1265 d->m_movieTimer.start(); |
1262 d->m_movieTimer.start(); |
1266 } |
1263 } |
1267 |
1264 |
1268 //! insert a new filmstrip on current's right |
1265 //! insert a new filmstrip on current's right |
1269 void LinearFlowSnippet::showInsertOnLeft() |
1266 void LinearFlowSnippet::showInsertOnLeft() |
1270 { |
1267 { |
1271 //FIXME |
1268 //FIXME |
1272 Q_ASSERT(d); |
1269 Q_ASSERT(d); |
1273 qDebug() << "showInsertOnLeft is not implemented."; |
1270 } |
1274 } |
1271 |
1275 |
1272 //! Show the previous item |
1276 //! Show the previous item |
|
1277 void LinearFlowSnippet::showPrevious() |
1273 void LinearFlowSnippet::showPrevious() |
1278 { |
1274 { |
1279 Q_ASSERT(d); |
1275 Q_ASSERT(d); |
1280 |
1276 |
1281 d->m_incIndex = -1; |
1277 d->m_incIndex = -1; |
1282 CALL_ON_CENTER_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(CenterToRight))); |
1278 CALL_ON_CENTER_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(CenterToRight))); |
1283 CALL_ON_PREV_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(LeftToCenter))); |
1279 CALL_ON_PREV_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(LeftToCenter))); |
1284 |
1280 |
1285 CALL_ON_PREV_PREV_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(LeftLeftToLeft))); |
1281 CALL_ON_PREV_PREV_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(LeftLeftToLeft))); |
1286 CALL_ON_NEXT_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(RightToRightRight))); |
1282 CALL_ON_NEXT_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(RightToRightRight))); |
1287 |
1283 |
1288 CALL_ON_NEXT_NEXT_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(BreakoutRightRight))); |
1284 CALL_ON_NEXT_NEXT_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(BreakoutRightRight))); |
1289 CALL_ON_PREV_PREV_PREV_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(BreakinLeftLeft))); |
1285 CALL_ON_PREV_PREV_PREV_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(BreakinLeftLeft))); |
1290 |
1286 |
1291 d->m_movieTimer.start(); |
1287 d->m_movieTimer.start(); |
1292 } |
1288 } |
1293 |
1289 |
1294 //! Show the next item |
1290 //! Show the next item |
1295 void LinearFlowSnippet::showNext() |
1291 void LinearFlowSnippet::showNext() |
1296 { |
1292 { |
1297 Q_ASSERT(d); |
1293 Q_ASSERT(d); |
1298 |
1294 |
1299 d->m_incIndex = 1; |
1295 d->m_incIndex = 1; |
1300 CALL_ON_CENTER_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(CenterToLeft))); |
1296 CALL_ON_CENTER_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(CenterToLeft))); |
1301 CALL_ON_PREV_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(LeftToLeftLeft))); |
1297 CALL_ON_PREV_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(LeftToLeftLeft))); |
1302 CALL_ON_NEXT_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(RightToCenter))); |
1298 CALL_ON_NEXT_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(RightToCenter))); |
1303 CALL_ON_NEXT_NEXT_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(RightRightToRight))); |
1299 CALL_ON_NEXT_NEXT_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(RightRightToRight))); |
1346 else if (newIndex >= d->m_films.size()) |
1342 else if (newIndex >= d->m_films.size()) |
1347 newIndex = newIndex % d->m_films.size(); |
1343 newIndex = newIndex % d->m_films.size(); |
1348 |
1344 |
1349 if (newIndex >= 0 && newIndex < d->m_films.size()) |
1345 if (newIndex >= 0 && newIndex < d->m_films.size()) |
1350 setCenterIndex(newIndex); |
1346 setCenterIndex(newIndex); |
1351 |
1347 |
1352 update(); |
1348 update(); |
1353 |
1349 |
1354 if(m_countFlicks) { |
1350 if (m_countFlicks) { |
1355 startFlickScroll(); |
1351 startFlickScroll(); |
1356 } |
1352 } |
1357 } |
1353 } |
1358 |
1354 |
1359 void LinearFlowSnippet::closeAnimation() |
1355 void LinearFlowSnippet::closeAnimation() |
1360 { |
1356 { |
1361 Filmstrip* f = d->m_films.at(d->m_centerIndex); |
1357 Filmstrip* f = d->m_films.at(d->m_centerIndex); |
1362 |
1358 |
1363 if (d->m_centerIndex == 0) { |
1359 if (d->m_centerIndex == 0) { |
1364 d->m_incIndex = 0; |
1360 d->m_incIndex = 0; |
1365 CALL_ON_NEXT_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(RightToCenter))); |
1361 CALL_ON_NEXT_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(RightToCenter))); |
1366 CALL_ON_NEXT_NEXT_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(BreakinRight))); |
1362 CALL_ON_NEXT_NEXT_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(BreakinRight))); |
1367 d->m_films.removeAt(d->m_centerIndex); |
1363 d->m_films.removeAt(d->m_centerIndex); |
1368 } else { |
1364 } else { |
1369 d->m_incIndex = -1; |
1365 d->m_incIndex = -1; |
1405 // not adjust filmstrip size here because the event->size() is whole application's size |
1401 // not adjust filmstrip size here because the event->size() is whole application's size |
1406 } |
1402 } |
1407 |
1403 |
1408 void LinearFlowSnippet::mouseMoveEvent(QGraphicsSceneMouseEvent* event) |
1404 void LinearFlowSnippet::mouseMoveEvent(QGraphicsSceneMouseEvent* event) |
1409 { |
1405 { |
1410 //qDebug() << "!!!!!!!!!!!!!!!!move event" << this->size(); |
1406 //qDebug() << "!!!!!!!!!!!!!!!!move event" << this->size(); |
1411 if( qAbs(qAbs(event->pos().toPoint().x()) - qAbs(d->m_lastMoveEventPos.x())) > 20) |
1407 if ( qAbs(qAbs(event->pos().toPoint().x()) - qAbs(d->m_lastMoveEventPos.x())) > 20) |
1412 { |
1408 { |
1413 if( event->pos().toPoint().x() < event->lastPos().toPoint().x()) |
1409 if ( event->pos().toPoint().x() < event->lastPos().toPoint().x()) |
1414 showNext(); |
1410 showNext(); |
1415 else |
1411 else |
1416 showPrevious(); |
1412 showPrevious(); |
1417 d->m_lastMoveEventPos = event->pos().toPoint(); |
1413 d->m_lastMoveEventPos = event->pos().toPoint(); |
1418 |
1414 |
1419 QTime now(QTime::currentTime()); |
1415 QTime now(QTime::currentTime()); |
1420 m_lastMoveEventTime.setHMS(now.hour(),now.minute(), now.second(), now.msec()); |
1416 m_lastMoveEventTime.setHMS(now.hour(),now.minute(), now.second(), now.msec()); |
1421 |
1417 |
1422 DragPoint dragPoint; |
1418 DragPoint dragPoint; |
1423 dragPoint.iPoint = d->m_lastMoveEventPos; |
1419 dragPoint.iPoint = d->m_lastMoveEventPos; |
1424 dragPoint.iTime = QTime::currentTime(); |
1420 dragPoint.iTime = QTime::currentTime(); |
1425 m_dragPoints.append(dragPoint); |
1421 m_dragPoints.append(dragPoint); |
1426 |
1422 |
1427 while (m_dragPoints.size() > 4) |
1423 while (m_dragPoints.size() > 4) |
1428 m_dragPoints.removeFirst(); |
1424 m_dragPoints.removeFirst(); |
1429 |
1425 |
1430 m_scrolled= true; |
1426 m_scrolled= true; |
1431 } |
1427 } |
1432 } |
1428 } |
1433 |
1429 |
1434 bool LinearFlowSnippet::isFlick() |
1430 bool LinearFlowSnippet::isFlick() |
1435 { |
1431 { |
1436 bool flick = false; |
1432 bool flick = false; |
1437 QPoint moveSpeed = speed(); |
1433 QPoint moveSpeed = speed(); |
1438 int xSpeed = moveSpeed.x(); |
1434 int xSpeed = moveSpeed.x(); |
1439 int ySpeed = moveSpeed.y(); |
1435 int ySpeed = moveSpeed.y(); |
1440 |
1436 |
1441 flick = (qAbs(xSpeed) > THRESHOLD_FLICK_SPEED || |
1437 flick = (qAbs(xSpeed) > THRESHOLD_FLICK_SPEED || |
1442 qAbs(ySpeed) > THRESHOLD_FLICK_SPEED); |
1438 qAbs(ySpeed) > THRESHOLD_FLICK_SPEED); |
1443 |
1439 |
1444 return flick; |
1440 return flick; |
1445 } |
1441 } |
1446 |
1442 |
1447 QPoint LinearFlowSnippet::speed() |
1443 QPoint LinearFlowSnippet::speed() |
1448 { |
1444 { |
1449 // Speed is only evaluated at the end of the swipe |
1445 // Speed is only evaluated at the end of the swipe |
1450 QPoint dragSpeed(0,0); |
1446 QPoint dragSpeed(0,0); |
1451 qreal time = dragTime() / 1000; |
1447 qreal time = dragTime() / 1000; |
1452 if (time > 0) { |
1448 if (time > 0) { |
1490 } |
1486 } |
1491 |
1487 |
1492 void LinearFlowSnippet::mousePressEvent(QGraphicsSceneMouseEvent* event) |
1488 void LinearFlowSnippet::mousePressEvent(QGraphicsSceneMouseEvent* event) |
1493 { |
1489 { |
1494 emit mouseEvent( event->type()); |
1490 emit mouseEvent( event->type()); |
1495 if(m_countFlicks) |
1491 if (m_countFlicks) |
1496 m_countFlicks = 0; |
1492 m_countFlicks = 0; |
1497 d->m_movieTimer.setDuration(ANIMATION_DURATION); |
1493 d->m_movieTimer.setDuration(ANIMATION_DURATION); |
1498 m_dragPoints.clear(); |
1494 m_dragPoints.clear(); |
1499 DragPoint dragPoint; |
1495 DragPoint dragPoint; |
1500 dragPoint.iPoint = event->pos().toPoint(); |
1496 dragPoint.iPoint = event->pos().toPoint(); |
1501 dragPoint.iTime = QTime::currentTime(); |
1497 dragPoint.iTime = QTime::currentTime(); |
1502 m_dragPoints.append(dragPoint); |
1498 m_dragPoints.append(dragPoint); |
1503 m_scrolled = false; |
1499 m_scrolled = false; |
1504 m_lastMoveEventTime.setHMS(0,0,0,0); |
1500 m_lastMoveEventTime.setHMS(0,0,0,0); |
1505 d->m_lastMoveEventPos = event->pos().toPoint(); |
1501 d->m_lastMoveEventPos = event->pos().toPoint(); |
1506 } |
1502 } |
1507 |
1503 |
1508 void LinearFlowSnippet::mouseReleaseEvent(QGraphicsSceneMouseEvent* event) |
1504 void LinearFlowSnippet::mouseReleaseEvent(QGraphicsSceneMouseEvent* event) |
1509 { |
1505 { |
1510 emit mouseEvent( event->type()); |
1506 emit mouseEvent( event->type()); |
1511 //check whether strip is scrolled |
1507 //check whether strip is scrolled |
1512 if(!m_scrolled) { |
1508 if (!m_scrolled) { |
1513 QPoint releasePoint = event->pos().toPoint(); |
1509 QPoint releasePoint = event->pos().toPoint(); |
1514 |
1510 |
1515 int cw = d->m_centerWindowSize.width(); |
1511 int cw = d->m_centerWindowSize.width(); |
1516 int ch = d->m_centerWindowSize.height(); |
1512 int ch = d->m_centerWindowSize.height(); |
1517 int sw = d->m_sideWindowSize.width(); |
1513 int sw = d->m_sideWindowSize.width(); |
1525 qreal centerPageX = (w - cw)/2.0; |
1521 qreal centerPageX = (w - cw)/2.0; |
1526 qreal rightPageX = (w + 4 * d->m_space + cw) / 2.0 - d->m_space; |
1522 qreal rightPageX = (w + 4 * d->m_space + cw) / 2.0 - d->m_space; |
1527 int pageIndex; |
1523 int pageIndex; |
1528 |
1524 |
1529 //check for leftleft film |
1525 //check for leftleft film |
1530 if((releasePoint.x() >= leftLeftPageX) && (releasePoint.x() <= (leftLeftPageX + sw)) && |
1526 if ((releasePoint.x() >= leftLeftPageX) && (releasePoint.x() <= (leftLeftPageX + sw)) && |
1531 (releasePoint.y() >= (d->m_sideTopSpace+ d->m_widgetSize.height() * TITLE_HEIGHT)) && (releasePoint.y() <= (d->m_sideTopSpace + sh + d->m_widgetSize.height() * TITLE_HEIGHT))) { |
1527 (releasePoint.y() >= (d->m_sideTopSpace+ d->m_widgetSize.height() * TITLE_HEIGHT)) && (releasePoint.y() <= (d->m_sideTopSpace + sh + d->m_widgetSize.height() * TITLE_HEIGHT))) { |
1532 |
1528 |
1533 pageIndex = d->m_centerIndex - 2; |
1529 pageIndex = d->m_centerIndex - 2; |
1534 |
1530 |
1535 } |
1531 } |
1536 |
1532 |
1537 //check for left film |
1533 //check for left film |
1538 else if((releasePoint.x() >= leftPageX) && (releasePoint.x() <= (leftPageX + sw)) && |
1534 else if ((releasePoint.x() >= leftPageX) && (releasePoint.x() <= (leftPageX + sw)) && |
1539 (releasePoint.y() >= (d->m_sideTopSpace+ d->m_widgetSize.height() * TITLE_HEIGHT)) && (releasePoint.y() <= (d->m_sideTopSpace + sh + d->m_widgetSize.height() * TITLE_HEIGHT))) { |
1535 (releasePoint.y() >= (d->m_sideTopSpace+ d->m_widgetSize.height() * TITLE_HEIGHT)) && (releasePoint.y() <= (d->m_sideTopSpace + sh + d->m_widgetSize.height() * TITLE_HEIGHT))) { |
1540 |
1536 |
1541 pageIndex = d->m_centerIndex - 1; |
1537 pageIndex = d->m_centerIndex - 1; |
1542 |
1538 |
1543 } |
1539 } |
1544 |
1540 |
1545 //check for center film |
1541 //check for center film |
1546 else if((releasePoint.x() >= centerPageX) && (releasePoint.x() <= (centerPageX + cw)) && |
1542 else if ((releasePoint.x() >= centerPageX) && (releasePoint.x() <= (centerPageX + cw)) && |
1547 (releasePoint.y() >= (d->m_centerTopSpace+ d->m_widgetSize.height() * TITLE_HEIGHT)) && (releasePoint.y() <= (d->m_centerTopSpace + ch + d->m_widgetSize.height() * TITLE_HEIGHT))) { |
1543 (releasePoint.y() >= (d->m_centerTopSpace+ d->m_widgetSize.height() * TITLE_HEIGHT)) && (releasePoint.y() <= (d->m_centerTopSpace + ch + d->m_widgetSize.height() * TITLE_HEIGHT))) { |
1548 pageIndex = d->m_centerIndex; |
1544 pageIndex = d->m_centerIndex; |
1549 } |
1545 } |
1550 |
1546 |
1551 //check for right film |
1547 //check for right film |
1552 else if((releasePoint.x() >= rightPageX) && (releasePoint.x() <= (rightPageX + sw)) && |
1548 else if ((releasePoint.x() >= rightPageX) && (releasePoint.x() <= (rightPageX + sw)) && |
1553 (releasePoint.y() >= (d->m_sideTopSpace+ d->m_widgetSize.height() * TITLE_HEIGHT)) && (releasePoint.y() <= (d->m_sideTopSpace + sh + d->m_widgetSize.height() * TITLE_HEIGHT))) { |
1549 (releasePoint.y() >= (d->m_sideTopSpace+ d->m_widgetSize.height() * TITLE_HEIGHT)) && (releasePoint.y() <= (d->m_sideTopSpace + sh + d->m_widgetSize.height() * TITLE_HEIGHT))) { |
1554 pageIndex = d->m_centerIndex + 1; |
1550 pageIndex = d->m_centerIndex + 1; |
1555 } |
1551 } |
1556 |
1552 |
1557 //check for right right film |
1553 //check for right right film |
1558 else if((releasePoint.x() >= rightRightPageX) && (releasePoint.x() <= (rightRightPageX + sw)) && |
1554 else if ((releasePoint.x() >= rightRightPageX) && (releasePoint.x() <= (rightRightPageX + sw)) && |
1559 (releasePoint.y() >= (d->m_sideTopSpace+ d->m_widgetSize.height() * TITLE_HEIGHT)) && (releasePoint.y() <= (d->m_sideTopSpace + sh + d->m_widgetSize.height() * TITLE_HEIGHT))) { |
1555 (releasePoint.y() >= (d->m_sideTopSpace+ d->m_widgetSize.height() * TITLE_HEIGHT)) && (releasePoint.y() <= (d->m_sideTopSpace + sh + d->m_widgetSize.height() * TITLE_HEIGHT))) { |
1560 pageIndex = d->m_centerIndex + 2; |
1556 pageIndex = d->m_centerIndex + 2; |
1561 } |
1557 } |
1562 |
1558 |
1563 //click else where ignore |
1559 //click else where ignore |
1564 else { |
1560 else { |
1565 return; |
1561 return; |
1566 } |
1562 } |
1567 if( pageIndex < 0) |
1563 if ( pageIndex < 0) |
1568 pageIndex = d->m_films.size() + pageIndex; |
1564 pageIndex = d->m_films.size() + pageIndex; |
1569 else if (pageIndex >= d->m_films.size()) |
1565 else if (pageIndex >= d->m_films.size()) |
1570 pageIndex = (pageIndex) % d->m_films.size(); |
1566 pageIndex = (pageIndex) % d->m_films.size(); |
1571 |
1567 |
1572 emit ok(pageIndex); |
1568 emit ok(pageIndex); |
1573 } |
1569 } |
1574 |
1570 |
1575 else { |
1571 else { |
1576 int msecs = 0; |
1572 int msecs = 0; |
1577 if (!m_lastMoveEventTime.isNull()) { |
1573 if (!m_lastMoveEventTime.isNull()) { |
1578 //Start deceleration only if the delta since last drag event is less than threshold |
1574 //Start deceleration only if the delta since last drag event is less than threshold |
1579 QTime now(QTime::currentTime()); |
1575 QTime now(QTime::currentTime()); |
1580 msecs = m_lastMoveEventTime.msecsTo(now); |
1576 msecs = m_lastMoveEventTime.msecsTo(now); |
1581 m_lastMoveEventTime.setHMS(0,0,0,0); |
1577 m_lastMoveEventTime.setHMS(0,0,0,0); |
1582 } |
1578 } |
1583 if((msecs>0) && (msecs < THRESHOLD_FLICK_TIME)) { |
1579 if ((msecs>0) && (msecs < THRESHOLD_FLICK_TIME)) { |
1584 if( isFlick()) { |
1580 if ( isFlick()) { |
1585 m_countFlicks = qBound (-MAX_FLICK_SPEED,speed().x(),+MAX_FLICK_SPEED)/((m_displayMode == "portrait") ? 200 : 100); |
1581 m_countFlicks = qBound (-MAX_FLICK_SPEED,speed().x(),+MAX_FLICK_SPEED)/((m_displayMode == "portrait") ? 200 : 100); |
1586 startFlickScroll(); |
1582 startFlickScroll(); |
1587 } |
1583 } |
1588 } |
1584 } |
1589 } |
1585 } |
1590 } |
1586 } |
1591 |
1587 |
1592 void LinearFlowSnippet::startFlickScroll() |
1588 void LinearFlowSnippet::startFlickScroll() |
1593 { |
1589 { |
1594 d->m_movieTimer.setDuration(qAbs(ANIMATION_DURATION / m_countFlicks)); |
1590 d->m_movieTimer.setDuration(qAbs(ANIMATION_DURATION / m_countFlicks)); |
1595 if(m_countFlicks < 0) { |
1591 if (m_countFlicks < 0) { |
1596 showNext(); |
1592 showNext(); |
1597 m_countFlicks++; |
1593 m_countFlicks++; |
1598 } |
1594 } |
1599 else { |
1595 else { |
1600 showPrevious(); |
1596 showPrevious(); |
1630 // draw right film strip |
1626 // draw right film strip |
1631 CALL_ON_NEXT_FILM_STRIP(paint(&bufPaint)); |
1627 CALL_ON_NEXT_FILM_STRIP(paint(&bufPaint)); |
1632 |
1628 |
1633 // draw right right film strip |
1629 // draw right right film strip |
1634 CALL_ON_NEXT_NEXT_FILM_STRIP(paint(&bufPaint)); |
1630 CALL_ON_NEXT_NEXT_FILM_STRIP(paint(&bufPaint)); |
1635 |
1631 |
1636 // draw right right film strip |
1632 // draw right right film strip |
1637 CALL_ON_NEXT_NEXT_NEXT_FILM_STRIP(paint(&bufPaint)); |
1633 CALL_ON_NEXT_NEXT_NEXT_FILM_STRIP(paint(&bufPaint)); |
1638 |
1634 |
1639 // 1. draw image from the buffer |
1635 // 1. draw image from the buffer |
1640 painter->drawImage(QPoint(0,d->m_widgetSize.height() * TITLE_HEIGHT), *(d->m_buffer)); |
1636 painter->drawImage(QPoint(0,d->m_widgetSize.height() * TITLE_HEIGHT), *(d->m_buffer)); |