LunaSysMgr
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CardTransition.h
Go to the documentation of this file.
1 /* @@@LICENSE
2 *
3 * Copyright (c) 2009-2012 Hewlett-Packard Development Company, L.P.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 * LICENSE@@@ */
18 
19 
20 
21 
22 #ifndef CARDTRANSITION_H
23 #define CARDTRANSITION_H
24 
25 #include "Common.h"
26 
27 #include <string>
28 #include <stdint.h>
29 
30 #include <QPainter>
31 #include <QPixmap>
32 
33 #include "AnimationEquations.h"
34 
35 class CardWindow;
36 
38 {
39 public:
40 
42  QPixmap* fromPixmap,
43  const std::string& transitionName);
45 
46  bool finished();
47 
48  void markCompleted(bool val) { m_completed = val; }
49  bool completed() const { return m_completed; }
50 
51  // Returns true if transition is done
52  void draw(QPainter* painter, const QPainterPath &path, bool maximized);
53 
54 private:
55 
56  enum TransitionType {
57  Transition_Invalid,
58  Transition_ZoomAndCrossFade,
59  Transition_CrossFade
60  };
61 
62  struct AnimObject {
63  PValue startScale;
64  PValue targetScale;
65  int startAlpha;
66  int targetAlpha;
67  };
68 
69 private:
70 
71  void zoomAndCrossFadeTick(QPainter* painter, const QPainterPath &path, bool maximized);
72  void crossFadeTick(QPainter* painter, const QPainterPath &path, bool maximized);
73 
74 private:
75 
76  CardWindow* m_win;
77 
78  QPixmap* m_fromScenePixmap;
79 
80  AnimObject m_fromSceneAnimObject;
81  AnimObject m_toSceneAnimObject;
82 
83  TransitionType m_transitionType;
84  bool m_transitionIsPop;
85 
86  uint32_t m_startTime;
87  bool m_completed;
88 
89  AnimationEquation m_equation;
90 };
91 
92 #endif /* CARDTRANSITION_H */