|
1 /* |
|
2 * Copyright (c) 2009 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: glxzoomwidget.h |
|
15 * definition of the class glxzoomwidget which controls the Zoom behavior of coverflow. |
|
16 * |
|
17 */ |
|
18 #ifndef GLXZOOMWIDGET_H |
|
19 #define GLXZOOMWIDGET_H |
|
20 |
|
21 #include <QObject> |
|
22 #include <QGraphicsWidget> |
|
23 #include <QPixmap> |
|
24 #include <hbscrollarea.h> |
|
25 |
|
26 #include <glxzoomwidget_global.h> |
|
27 |
|
28 class QGestureEvent; |
|
29 class QPinchGesture; |
|
30 class HbIconItem; |
|
31 class GlxImageDecoderWrapper; |
|
32 class QTimeLine; |
|
33 |
|
34 const int MAXZVALUE = 100; |
|
35 const int MINZVALUE = 0; |
|
36 |
|
37 class GLXZOOMWIDGETSHARED_EXPORT GlxZoomWidget : public HbScrollArea |
|
38 { |
|
39 Q_OBJECT |
|
40 |
|
41 public: |
|
42 GlxZoomWidget (QGraphicsItem *parent = NULL); |
|
43 ~GlxZoomWidget (); |
|
44 void setModel (QAbstractItemModel *model) ; |
|
45 void indexChanged(int index); |
|
46 void setWindowSize(QSize windowSize); |
|
47 void cleanUp(); |
|
48 void activate(); |
|
49 void setMinMaxZValue(int minZvalue, int maxZvalue); |
|
50 void connectDecodeRequestToPinchEvent(); |
|
51 |
|
52 signals: |
|
53 void pinchGestureReceived(int index); |
|
54 void zoomWidgetMovedBackground(int index); |
|
55 |
|
56 public slots: |
|
57 //for Decoder support |
|
58 void decodedImageAvailable(); |
|
59 void sendDecodeRequest(int index); |
|
60 |
|
61 //for animation effects |
|
62 void animateZoomIn(QPointF animRefPoint); |
|
63 void animateZoomOut(QPointF animRefPoint); |
|
64 void animationFrameChanged(int frameNumber); |
|
65 void animationTimeLineFinished(); |
|
66 |
|
67 protected: |
|
68 bool sceneEvent(QEvent *event); |
|
69 bool sceneEventFilter(QGraphicsItem *watched,QEvent *event); |
|
70 protected slots: |
|
71 void dataChanged(QModelIndex startIndex, QModelIndex endIndex); |
|
72 |
|
73 |
|
74 private: |
|
75 bool executeGestureEvent(QGraphicsItem *source,QGestureEvent *event); |
|
76 //Responsible for changing the transforms of the widget wrt the ZF and center |
|
77 //Also adjusts the ZF, center and final size so as to respect the boundaries |
|
78 void zoomImage(qreal zoomFactor, QPointF center); |
|
79 //This API will adjust the gesture center to maintain boundaries |
|
80 //called from GlxZoomWidget::zoomImage |
|
81 void adjustGestureCenter(QPointF & gestureCenter, qreal& zoomFactor); |
|
82 //this API will limit the max/min Zoom Size possible |
|
83 //called from GlxZoomWidget::zoomImage |
|
84 void limitRequiredSize(QSizeF &requiredSize); |
|
85 //gets the latest focussed image from the model |
|
86 void retreiveFocusedImage(); |
|
87 //finalize the transform and update the sizehint of mZoomWidget |
|
88 void finalizeWidgetTransform(); |
|
89 //get the focused image from the model |
|
90 QPixmap getFocusedImage(); |
|
91 |
|
92 //data members |
|
93 private: |
|
94 //view widgets |
|
95 QGraphicsPixmapItem *mZoomItem; //Item containing the pixmap |
|
96 QGraphicsWidget *mZoomWidget; //container :all scaling and transforms would be done on this widget |
|
97 HbIconItem* mBlackBackgroundItem; //for setting black background |
|
98 |
|
99 //view Z values |
|
100 //might push to layouts later |
|
101 |
|
102 int mMinZValue ; |
|
103 int mMaxZValue ; |
|
104 |
|
105 |
|
106 //to be in sync with the model |
|
107 QAbstractItemModel *mModel; |
|
108 int mFocusIndex; |
|
109 |
|
110 //size parameter |
|
111 QSizeF mItemSize; // the actual pixmap size. Keep it updated with latest pixmap size |
|
112 QSizeF mStepCurrentSize; //to save the size before gesture started |
|
113 QSizeF mCurrentSize; //save sizes scaled by gesture |
|
114 QSize mWindowSize; //the window size |
|
115 QSizeF mMinScaleSize; //minimum posible size |
|
116 QSizeF mMinDecScaleSize; //the Minimum scale limit after which the image scaling down should be decelerated |
|
117 QSizeF mMaxScaleSize; // the maximum scale limit |
|
118 QSizeF mMaxScaleDecSize; // the Maximum scale limit after which the image scaling should be decelerated |
|
119 //for animation effect |
|
120 qreal m_FinalAnimatedScaleFactor; |
|
121 QPointF m_AnimRefPoint; |
|
122 QTimeLine *m_AnimTimeLine; |
|
123 //for Decoder support |
|
124 GlxImageDecoderWrapper* mImageDecoder; |
|
125 |
|
126 //status flags |
|
127 //To check if the decode request has already been send or not |
|
128 bool mImageDecodeRequestSend; |
|
129 //To check if the pinch gesture is in progress to block any events to HbScrollArea |
|
130 bool mPinchGestureOngoing; |
|
131 //to check if decoded image is available |
|
132 bool mDecodedImageAvailable; |
|
133 |
|
134 }; |
|
135 #endif //GLXZOOMWIDGET_H |