27 //User Includes |
27 //User Includes |
28 #include <glxmodelparm.h> |
28 #include <glxmodelparm.h> |
29 #include <glxcoverflow.h> |
29 #include <glxcoverflow.h> |
30 #include "glxviewids.h" |
30 #include "glxviewids.h" |
31 |
31 |
32 #define GLX_COVERFLOW_SPEED 60 |
32 #define GLX_COVERFLOW_SPEED 32 |
33 #define GLX_BOUNCEBACK_SPEED 15 |
33 #define GLX_BOUNCEBACK_SPEED 16 |
|
34 #define GLX_BOUNCEBACK_DELTA 8 |
34 |
35 |
35 GlxCoverFlow::GlxCoverFlow(QGraphicsItem *parent ) |
36 GlxCoverFlow::GlxCoverFlow(QGraphicsItem *parent ) |
36 : HbWidget(parent), |
37 : HbWidget(parent), |
37 mSelItemIndex (0), |
38 mSelItemIndex (0), |
38 mRows(0), |
39 mRows(0), |
67 mIconItem[i]->installSceneEventFilter(mMultitouchFilter); |
68 mIconItem[i]->installSceneEventFilter(mMultitouchFilter); |
68 mIconItem[i]->setBrush(QBrush(Qt::black)); |
69 mIconItem[i]->setBrush(QBrush(Qt::black)); |
69 mIconItem[i]->setSize(QSize(0,0)); |
70 mIconItem[i]->setSize(QSize(0,0)); |
70 } |
71 } |
71 mUiOn = FALSE; |
72 mUiOn = FALSE; |
72 mBounceBackDeltaX = 10; |
73 mBounceBackDeltaX = GLX_BOUNCEBACK_DELTA; |
73 } |
74 } |
74 |
75 |
75 void GlxCoverFlow::setItemSize(QSize &size) |
76 void GlxCoverFlow::setItemSize(QSize &size) |
76 { |
77 { |
77 qDebug("GlxCoverFlow::setSize width = %d",size.width() ); |
78 qDebug("GlxCoverFlow::setSize width = %d",size.width() ); |
103 } |
104 } |
104 } |
105 } |
105 |
106 |
106 void GlxCoverFlow::gestureEvent(QGestureEvent *event) |
107 void GlxCoverFlow::gestureEvent(QGestureEvent *event) |
107 { |
108 { |
108 if(QTapGesture *gesture = static_cast<QTapGesture *>(event->gesture(Qt::TapGesture))) { |
109 if(QTapGesture *gesture = static_cast<QTapGesture *>(event->gesture(Qt::TapGesture))) { |
109 if (gesture->state() == Qt::GestureFinished) { |
110 if (gesture->state() == Qt::GestureFinished) { |
110 emit coverFlowEvent( TAP_EVENT ); |
111 emit coverFlowEvent( TAP_EVENT ); |
111 event->accept(gesture); |
112 event->accept(gesture); |
|
113 } |
|
114 } |
|
115 |
|
116 if (QPanGesture *panningGesture = qobject_cast<QPanGesture*>(event->gesture(Qt::PanGesture))) { |
|
117 HbPanGesture *hbPanGesture = qobject_cast<HbPanGesture *>(panningGesture); |
|
118 if (hbPanGesture) { |
|
119 if(hbPanGesture->state() == Qt::GestureUpdated) { |
|
120 QPointF delta(hbPanGesture->sceneDelta()); |
|
121 panGesture(delta); |
|
122 event->accept(panningGesture); |
112 } |
123 } |
113 } |
124 |
114 |
125 if(hbPanGesture->state() == Qt::GestureFinished) { |
115 if (QPanGesture *panningGesture = qobject_cast<QPanGesture*>(event->gesture(Qt::PanGesture))) { |
126 switch( mMoveDir ) { |
116 HbPanGesture *hbPanGesture = qobject_cast<HbPanGesture *>(panningGesture); |
127 case LEFT_MOVE : |
117 if (hbPanGesture) { |
128 mMoveDir = NO_MOVE; |
118 if(hbPanGesture->state() == Qt::GestureUpdated) { |
129 mBounceBackDeltaX = ( mItemSize.width() >> 2 ) + ( mItemSize.width() >> 3 ); |
119 QPointF delta(hbPanGesture->sceneDelta()); |
130 emit autoLeftMoveSignal(); |
120 panGesture(delta); |
131 break ; |
121 event->accept(panningGesture); |
132 |
122 |
133 case RIGHT_MOVE : |
|
134 mMoveDir = NO_MOVE; |
|
135 mBounceBackDeltaX = ( mItemSize.width() >> 2 ) + ( mItemSize.width() >> 3 ); |
|
136 emit autoRightMoveSignal(); |
|
137 break; |
|
138 |
|
139 default: |
|
140 break; |
|
141 } |
|
142 event->accept(panningGesture); |
123 } |
143 } |
124 if(hbPanGesture->state() == Qt::GestureFinished) { |
144 } |
125 switch( mMoveDir ) { |
145 } |
126 |
|
127 case LEFT_MOVE: |
|
128 mMoveDir = NO_MOVE; |
|
129 emit autoLeftMoveSignal(); |
|
130 break ; |
|
131 |
|
132 case RIGHT_MOVE : |
|
133 mMoveDir = NO_MOVE; |
|
134 emit autoRightMoveSignal(); |
|
135 break; |
|
136 |
|
137 default: |
|
138 break; |
|
139 } |
|
140 event->accept(panningGesture); |
|
141 |
|
142 } |
|
143 } |
|
144 } |
|
145 |
|
146 } |
146 } |
147 |
147 |
148 void GlxCoverFlow::panGesture ( const QPointF & delta ) |
148 void GlxCoverFlow::panGesture ( const QPointF & delta ) |
149 { |
149 { |
150 qDebug("GlxCoverFlow::panGesture deltaX= %d", (int)delta.x()); |
150 qDebug("GlxCoverFlow::panGesture deltaX= %d", (int)delta.x()); |
161 |
161 |
162 if ( mUiOn == TRUE ) { |
162 if ( mUiOn == TRUE ) { |
163 emit coverFlowEvent( PANNING_START_EVENT ); |
163 emit coverFlowEvent( PANNING_START_EVENT ); |
164 mUiOn = FALSE; |
164 mUiOn = FALSE; |
165 } |
165 } |
166 } |
|
167 |
|
168 void GlxCoverFlow::leftGesture(int value) |
|
169 { |
|
170 Q_UNUSED(value); |
|
171 qDebug("GlxCoverFlow::leftGesture CurrentPos= %d value %d", mCurrentPos, value); |
|
172 if(getSubState() == IMAGEVIEWER_S || getSubState() == FETCHER_S ) { |
|
173 return; |
|
174 } |
|
175 mMoveDir = NO_MOVE; |
|
176 mBounceBackDeltaX = ( mItemSize.width() >> 2 ) + ( mItemSize.width() >> 3 ); |
|
177 emit autoLeftMoveSignal(); |
|
178 if ( mUiOn == TRUE ) { |
|
179 mUiOn = FALSE; |
|
180 emit coverFlowEvent( PANNING_START_EVENT ); |
|
181 } |
|
182 } |
|
183 |
|
184 void GlxCoverFlow::rightGesture(int value) |
|
185 { |
|
186 Q_UNUSED(value); |
|
187 qDebug("GlxCoverFlow::rightGesture CurrentPos= %d value %d ", mCurrentPos, value); |
|
188 if(getSubState() == IMAGEVIEWER_S || getSubState() == FETCHER_S ) { |
|
189 return; |
|
190 } |
|
191 mMoveDir = NO_MOVE; |
|
192 mBounceBackDeltaX = ( mItemSize.width() >> 2 ) + ( mItemSize.width() >> 3 ); |
|
193 emit autoRightMoveSignal(); |
|
194 if ( mUiOn == TRUE ) { |
|
195 mUiOn = FALSE; |
|
196 emit coverFlowEvent( PANNING_START_EVENT ); |
|
197 } |
|
198 } |
166 } |
199 |
167 |
200 void GlxCoverFlow::longPressGesture(const QPointF &point) |
168 void GlxCoverFlow::longPressGesture(const QPointF &point) |
201 { |
169 { |
202 qDebug("GlxCoverFlow::longPressGesture x = %d y = %d", point.x(), point.y()); |
170 qDebug("GlxCoverFlow::longPressGesture x = %d y = %d", point.x(), point.y()); |
264 mSpeed = GLX_BOUNCEBACK_SPEED; |
232 mSpeed = GLX_BOUNCEBACK_SPEED; |
265 } |
233 } |
266 //for bounce back effect for last image ( it will do the back) |
234 //for bounce back effect for last image ( it will do the back) |
267 if ( ( mCurrentPos + width ) > ( mStripLen + mBounceBackDeltaX ) && mMoveDir == NO_MOVE ) { |
235 if ( ( mCurrentPos + width ) > ( mStripLen + mBounceBackDeltaX ) && mMoveDir == NO_MOVE ) { |
268 mMoveDir = LEFT_MOVE; |
236 mMoveDir = LEFT_MOVE; |
269 mBounceBackDeltaX = 10; |
237 mBounceBackDeltaX = GLX_BOUNCEBACK_DELTA; |
270 autoRightMoveSignal(); |
238 autoRightMoveSignal(); |
271 return ; |
239 return ; |
272 } |
240 } |
273 |
241 |
274 int deltaX = width - mCurrentPos % width ; |
242 int deltaX = width - mCurrentPos % width ; |
316 } |
284 } |
317 //for bounce back effect for back image ( it will do the back) |
285 //for bounce back effect for back image ( it will do the back) |
318 qDebug("GlxCoverFlow::autoRightMove diffX x = %d current pos = %d mBounceBackDeltaX x = %d", diffX, mCurrentPos, mBounceBackDeltaX); |
286 qDebug("GlxCoverFlow::autoRightMove diffX x = %d current pos = %d mBounceBackDeltaX x = %d", diffX, mCurrentPos, mBounceBackDeltaX); |
319 if ( diffX > mBounceBackDeltaX && diffX < width && mMoveDir == NO_MOVE ){ |
287 if ( diffX > mBounceBackDeltaX && diffX < width && mMoveDir == NO_MOVE ){ |
320 mMoveDir = RIGHT_MOVE; |
288 mMoveDir = RIGHT_MOVE; |
321 mBounceBackDeltaX = 10; |
289 mBounceBackDeltaX = GLX_BOUNCEBACK_DELTA; |
322 autoLeftMoveSignal(); |
290 autoLeftMoveSignal(); |
323 return ; |
291 return ; |
324 } |
292 } |
325 |
293 |
326 int deltaX = mCurrentPos % width ; |
294 int deltaX = mCurrentPos % width ; |