|
1 /* |
|
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
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 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "SlideAnimator.h" |
|
20 #include "../ChromeSnippet.h" |
|
21 #include <QList> |
|
22 #include <QDebug> |
|
23 |
|
24 namespace GVA { |
|
25 |
|
26 SlideAnimator::SlideAnimator(ChromeSnippet* m_snippet) |
|
27 : VisibilityAnimator(m_snippet) |
|
28 { |
|
29 // m_visiblePosition = m_snippet->widget()->pos(); |
|
30 setDirection("up"); |
|
31 m_originalTransform = m_snippet->widget()->transform(); |
|
32 } |
|
33 |
|
34 SlideAnimator::~SlideAnimator() |
|
35 { |
|
36 } |
|
37 |
|
38 void SlideAnimator::setDirection(const QString & direction) |
|
39 { |
|
40 m_direction = direction; |
|
41 |
|
42 if(m_direction == "up"){ |
|
43 m_xRange = 0; |
|
44 m_yRange = -m_snippet->widget()->size().height(); |
|
45 } |
|
46 else if(m_direction == "down"){ |
|
47 m_xRange = 0; |
|
48 m_yRange = m_snippet->widget()->size().height(); |
|
49 } |
|
50 else if(m_direction == "left"){ |
|
51 m_xRange = -m_snippet->widget()->size().width(); |
|
52 m_yRange = 0; |
|
53 } |
|
54 else if(m_direction == "right"){ |
|
55 m_xRange = m_snippet->widget()->size().width(); |
|
56 m_yRange = 0; |
|
57 } |
|
58 } |
|
59 |
|
60 void SlideAnimator::updateVisibility(qreal step) |
|
61 { |
|
62 qDebug() << step; |
|
63 QTransform transform = m_originalTransform; |
|
64 transform.translate(step*m_xRange, step*m_yRange); |
|
65 m_snippet->widget()->setTransform(transform); |
|
66 emit moving(step); |
|
67 } |
|
68 |
|
69 } |