29 class HgAnimatedQuad; |
30 class HgAnimatedQuad; |
30 class HgQuad; |
31 class HgQuad; |
31 class HgImageFader; |
32 class HgImageFader; |
32 class HgImage; |
33 class HgImage; |
33 class QPolygonF; |
34 class QPolygonF; |
|
35 class HgAnimatedQuadFactory; |
34 |
36 |
35 /** |
37 /** |
36 * MediaWall rendering engine class. |
38 * MediaWall rendering engine class. |
37 */ |
39 */ |
38 class HgMediaWallRenderer : public QObject |
40 class HgMediaWallRenderer : public QObject |
39 { |
41 { |
40 Q_OBJECT |
42 Q_OBJECT |
41 Q_PROPERTY(qreal animationAlpha READ animationAlpha WRITE setAnimationAlpha) |
43 Q_PROPERTY(qreal animationAlpha READ animationAlpha WRITE setAnimationAlpha) |
42 Q_PROPERTY(qreal stateAnimationAlpha READ stateAnimationAlpha WRITE setStateAnimationAlpha) |
44 Q_PROPERTY(qreal stateAnimationAlpha READ stateAnimationAlpha WRITE setStateAnimationAlpha) |
43 public: |
45 public: |
44 |
|
45 enum OpeningAnimationType |
|
46 { |
|
47 OpeningAnimationFlip, |
|
48 OpeningAnimationZoomIn, |
|
49 OpeningAnimationZoomOver |
|
50 }; |
|
51 |
46 |
52 explicit HgMediaWallRenderer(HgMediaWallDataProvider* provider, |
47 explicit HgMediaWallRenderer(HgMediaWallDataProvider* provider, |
53 Qt::Orientation orientation, bool coverflowMode); |
48 Qt::Orientation orientation, Qt::Orientation scrollDirection, bool coverflowMode); |
54 |
49 |
55 virtual ~HgMediaWallRenderer(); |
50 virtual ~HgMediaWallRenderer(); |
56 |
51 |
57 void setCameraDistance(qreal distance); |
52 void setCameraDistance(qreal distance); |
58 qreal getCameraDistance() const; |
53 qreal getCameraDistance() const; |
|
54 |
59 void setCameraRotationY(qreal angle); |
55 void setCameraRotationY(qreal angle); |
60 qreal getCameraRotationY() const; |
56 qreal getCameraRotationY() const; |
|
57 |
61 void setCameraRotationZ(qreal angle); |
58 void setCameraRotationZ(qreal angle); |
62 qreal getCameraRotationZ() const; |
59 qreal getCameraRotationZ() const; |
63 |
60 |
64 void draw( |
61 void draw( |
65 const QPointF& startPosition, |
62 const QPointF& startPosition, |
66 const QPointF& position, |
63 const QPointF& position, |
67 const QPointF& targetPosition, |
64 const QPointF& targetPosition, |
68 qreal springVelocity, |
65 qreal springVelocity, |
69 QPainter* painter); |
66 QPainter* painter, |
70 |
67 const QTransform& sceneTransform, |
71 void setFlipAnimationAngle(qreal angleInDegrees); |
68 const QRectF& rect); |
72 |
69 |
73 void setOpeningAnimationType(OpeningAnimationType type); |
70 void setScrollDirection(Qt::Orientation scrollDirection, bool animate=false); |
74 |
71 Qt::Orientation getScrollDirection() const; |
75 void setOpeningAnimationDuration(int msecs); |
72 |
76 |
73 void setOrientation(Qt::Orientation orientation); |
77 void setOrientation(Qt::Orientation orientation, bool animate=false); |
|
78 Qt::Orientation getOrientation() const; |
|
79 |
74 |
80 void enableCoverflowMode(bool enabled); |
75 void enableCoverflowMode(bool enabled); |
81 bool coverflowModeEnabled() const; |
76 bool coverflowModeEnabled() const; |
82 |
77 |
83 void setRowCount(int rowCount, const QSizeF& newImageSize, bool animate=false); |
78 void setRowCount(int rowCount, const QSizeF& newImageSize, bool animate=false); |
84 int getRowCount() const; |
79 int getRowCount() const; |
85 |
80 |
86 HgQuad* getQuadAt(const QPointF& position) const; |
81 HgQuad* getQuadAt(const QPointF& position) const; |
87 |
82 |
88 void setRect(const QRectF& windowRect); |
|
89 const QRectF& getRect() const; |
|
90 void setSpacing(const QSizeF& spacing); |
83 void setSpacing(const QSizeF& spacing); |
91 const QSizeF& getSpacing() const; |
84 const QSizeF& getSpacing() const; |
92 void setImageSize(const QSizeF& imageSize); |
85 void setImageSize(const QSizeF& imageSize); |
93 const QSizeF& getImageSize() const; |
86 const QSizeF& getImageSize() const; |
94 |
87 |
95 void setFrontCoverElevationFactor(qreal elevation); |
88 void setFrontCoverElevationFactor(qreal elevation); |
96 qreal getFrontCoverElevationFactor() const; |
89 qreal getFrontCoverElevationFactor() const; |
97 |
|
98 void openItem(int index, bool animate); |
|
99 void closeItem(bool animate); |
|
100 bool isItemOpen() const; |
|
101 |
90 |
102 void enableReflections(bool enabled); |
91 void enableReflections(bool enabled); |
103 bool reflectionsEnabled() const; |
92 bool reflectionsEnabled() const; |
104 |
93 |
105 qreal getWorldWidth() const; |
94 qreal getWorldWidth() const; |
106 |
95 |
107 void beginRemoveRows(int start, int end); |
96 void beginRemoveRows(int start, int end); |
108 void endRemoveRows(); |
97 void endRemoveRows(); |
109 |
98 |
110 int getSelectedItem() const; |
99 int getSelectedItem() const; |
111 |
100 |
112 void initialize(QPainter* painter); |
|
113 bool initialized() const; |
|
114 |
|
115 HgQuadRenderer* getRenderer(); |
101 HgQuadRenderer* getRenderer(); |
116 |
102 |
117 bool getItemPoints(int index, QPolygonF& points) const; |
103 bool getItemPoints(int index, QPolygonF& points) const; |
118 |
104 |
119 QList<HgQuad*> getVisibleQuads() const; |
105 QList<HgQuad*> getVisibleQuads() const; |
120 |
106 |
121 void setFrontItemPosition(const QPointF& position); |
107 void setFrontItemPosition(const QPointF& position); |
122 QPointF frontItemPosition() const; |
108 QPointF frontItemPosition() const; |
123 |
109 |
124 signals: |
110 signals: |
125 void renderingNeeded(); |
111 void renderingNeeded(); |
126 void itemOpened(int index); |
|
127 void itemClosed(int index); |
|
128 void itemMarked(int index); |
|
129 void toggleItem(); |
|
130 void toggleState(); |
112 void toggleState(); |
131 void itemsRemoved(int start, int end); |
|
132 private slots: |
|
133 void onIdleState(); |
|
134 void onOpenedState(); |
|
135 void emitUpdate(); |
|
136 protected: |
113 protected: |
137 |
114 |
138 struct State |
115 struct State |
139 { |
116 { |
140 QList<HgQuad*> mQuads; |
117 QMap<int, HgQuad*> mQuads; |
141 }; |
118 }; |
142 |
119 |
143 void setAnimationAlpha(qreal alpha); |
120 void setAnimationAlpha(qreal alpha); |
144 qreal animationAlpha() const; |
121 qreal animationAlpha() const; |
145 |
122 |
156 const QPointF& position, |
133 const QPointF& position, |
157 const QPointF& targetPosition, |
134 const QPointF& targetPosition, |
158 qreal springVelocity, |
135 qreal springVelocity, |
159 QPainter* painter); |
136 QPainter* painter); |
160 |
137 |
161 void drawQuads(QPainter* painter); |
138 void startScrollDirectionChangeAnimation ( |
|
139 const QPointF& startPosition, |
|
140 const QPointF& position, |
|
141 const QPointF& targetPosition, |
|
142 qreal springVelocity, |
|
143 QPainter* painter, |
|
144 const QTransform& sceneTransform, |
|
145 const QRectF& rect); |
|
146 |
|
147 void startRowCountChangeAnimation ( |
|
148 const QPointF& startPosition, |
|
149 const QPointF& position, |
|
150 const QPointF& targetPosition, |
|
151 qreal springVelocity, |
|
152 QPainter* painter, |
|
153 const QTransform& sceneTransform, |
|
154 const QRectF& rect); |
|
155 |
|
156 void createAnimatedQuads(const HgAnimatedQuadFactory& factory); |
|
157 |
|
158 void drawQuads(QPainter* painter, const QTransform& sceneTransform); |
162 void resetQuads(); |
159 void resetQuads(); |
163 void updateCameraMatrices(); |
160 void updateCameraMatrices(); |
164 void updateSpacingAndImageSize(); |
161 void updateSpacingAndImageSize(); |
165 qreal getRowPosY(int row); |
162 qreal getRowPosY(int row); |
166 qreal getColumnPosX(int column); |
163 qreal getColumnPosX(int column); |
167 QPointF mapFromWindow(const QPointF& point) const; |
164 |
168 void applyOpeningAnimation(HgQuad* quad); |
|
169 void startStateAnimation(QPainter* painter); |
|
170 |
165 |
171 |
166 |
172 void setupCoverflow(const QPointF& startPosition, |
167 void setupCoverflow(const QPointF& startPosition, |
173 const QPointF& position, |
168 const QPointF& position, |
174 const QPointF& targetPosition, |
169 const QPointF& targetPosition, |
185 const QPointF& position, |
180 const QPointF& position, |
186 const QPointF& targetPosition, |
181 const QPointF& targetPosition, |
187 qreal springVelocity, |
182 qreal springVelocity, |
188 QPainter* painter); |
183 QPainter* painter); |
189 |
184 |
190 void setupGridRow(qreal posY, int itemIndex, int& quadIndex); |
185 void setupGridRow(qreal posY, int& itemIndex, int& quadIndex); |
191 void setupGridColumn(qreal posX, int itemIndex, int& quadIndex); |
186 void setupGridColumn(qreal posX, int& itemIndex, int& quadIndex); |
192 void setupDefaultQuad(const QVector3D& pos, int itemIndex, bool reflectionsEnabled, int& quadIndex); |
187 void setupDefaultQuad(const QVector3D& pos, int itemIndex, bool reflectionsEnabled, int& quadIndex); |
193 void setupIndicator(HgQuad* parent, |
188 void setupIndicator(HgQuad* parent, |
194 HgQuad* indicator, const HgImage* indicatorImage, int itemIndex); |
189 HgQuad* indicator, const HgImage* indicatorImage, int itemIndex); |
195 bool initializeRenderer(QPainter* painter); |
190 |
196 |
|
197 |
|
198 protected: |
191 protected: |
199 |
192 |
200 enum ItemState |
|
201 { |
|
202 ItemClosed, |
|
203 ItemOpening, |
|
204 ItemOpened, |
|
205 ItemClosing |
|
206 }; |
|
207 |
|
208 HgMediaWallDataProvider* mDataProvider; |
193 HgMediaWallDataProvider* mDataProvider; |
209 HgQuadRenderer* mRenderer; |
194 HgQuadRenderer* mRenderer; |
210 HgQuadRenderer* mIndicatorRenderer; |
195 HgQuadRenderer* mIndicatorRenderer; |
211 bool mRendererInitialized; |
196 bool mRendererInitialized; |
212 |
197 |
|
198 Qt::Orientation mScrollDirection; |
|
199 Qt::Orientation mNextScrollDirection; |
213 Qt::Orientation mOrientation; |
200 Qt::Orientation mOrientation; |
214 Qt::Orientation mNextOrientation; |
|
215 |
201 |
216 qreal mStateAnimationAlpha; |
202 qreal mStateAnimationAlpha; |
217 bool mStateAnimationOnGoing; |
203 bool mStateAnimationOnGoing; |
218 |
204 |
219 qreal mAnimationAlpha; |
205 qreal mAnimationAlpha; |
220 |
206 |
221 OpeningAnimationType mOpeningAnimationType; |
|
222 int mOpeningAnimationDuration; |
|
223 int mOpenedItem; |
|
224 int mSelectedItem; |
|
225 qreal mFlipAngle; |
|
226 QTimer* mAnimationTimer; |
|
227 QMatrix4x4 mViewMatrix; |
207 QMatrix4x4 mViewMatrix; |
228 QMatrix4x4 mProjMatrix; |
208 QMatrix4x4 mProjMatrix; |
229 QStateMachine* mStateMachine; |
209 QStateMachine* mStateMachine; |
230 qreal mZoomAmount; |
|
231 bool mCoverflowMode; |
210 bool mCoverflowMode; |
232 int mRowCount; |
211 int mRowCount; |
233 int mNextRowCount; |
212 int mNextRowCount; |
234 |
213 |
235 QList<HgAnimatedQuad*> mAnimatedQuads; |
214 QList<HgAnimatedQuad*> mAnimatedQuads; |