43
|
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();
|
45
|
51 |
|
|
52 |
/*
|
|
53 |
* This is an overloaded function when an index is changes due to deletion
|
|
54 |
*/
|
|
55 |
void indexChanged();
|
50
|
56 |
void forceZoomToBackground();
|
45
|
57 |
|
43
|
58 |
signals:
|
|
59 |
void pinchGestureReceived(int index);
|
|
60 |
void zoomWidgetMovedBackground(int index);
|
|
61 |
|
|
62 |
public slots:
|
|
63 |
//for Decoder support
|
|
64 |
void decodedImageAvailable();
|
|
65 |
void sendDecodeRequest(int index);
|
|
66 |
|
|
67 |
//for animation effects
|
|
68 |
void animateZoomIn(QPointF animRefPoint);
|
|
69 |
void animateZoomOut(QPointF animRefPoint);
|
|
70 |
void animationFrameChanged(int frameNumber);
|
|
71 |
void animationTimeLineFinished();
|
|
72 |
|
|
73 |
protected:
|
|
74 |
bool sceneEvent(QEvent *event);
|
|
75 |
bool sceneEventFilter(QGraphicsItem *watched,QEvent *event);
|
44
|
76 |
void timerEvent(QTimerEvent *event);
|
43
|
77 |
protected slots:
|
|
78 |
void dataChanged(QModelIndex startIndex, QModelIndex endIndex);
|
45
|
79 |
void modelDestroyed();
|
43
|
80 |
|
|
81 |
private:
|
|
82 |
bool executeGestureEvent(QGraphicsItem *source,QGestureEvent *event);
|
|
83 |
//Responsible for changing the transforms of the widget wrt the ZF and center
|
|
84 |
//Also adjusts the ZF, center and final size so as to respect the boundaries
|
|
85 |
void zoomImage(qreal zoomFactor, QPointF center);
|
|
86 |
//This API will adjust the gesture center to maintain boundaries
|
|
87 |
//called from GlxZoomWidget::zoomImage
|
|
88 |
void adjustGestureCenter(QPointF & gestureCenter, qreal& zoomFactor);
|
|
89 |
//this API will limit the max/min Zoom Size possible
|
|
90 |
//called from GlxZoomWidget::zoomImage
|
|
91 |
void limitRequiredSize(QSizeF &requiredSize);
|
|
92 |
//gets the latest focussed image from the model
|
|
93 |
void retreiveFocusedImage();
|
|
94 |
//finalize the transform and update the sizehint of mZoomWidget
|
|
95 |
void finalizeWidgetTransform();
|
|
96 |
//get the focused image from the model
|
|
97 |
QPixmap getFocusedImage();
|
50
|
98 |
//set all the zoom parameters as per the circumstances
|
|
99 |
void setZoomParams();
|
43
|
100 |
|
52
|
101 |
bool isFocussedItemCorrupt();
|
43
|
102 |
//data members
|
52
|
103 |
private:
|
|
104 |
//to be in sync with the model
|
|
105 |
QAbstractItemModel *mModel;
|
|
106 |
|
|
107 |
//view Z values
|
|
108 |
//might push to layouts later
|
|
109 |
int mMinZValue ;
|
|
110 |
int mMaxZValue ;
|
|
111 |
int mTimerId;
|
|
112 |
|
|
113 |
//status flags
|
|
114 |
//To check if the decode request has already been send or not
|
|
115 |
bool mImageDecodeRequestSend;
|
|
116 |
//To check if the pinch gesture is in progress to block any events to HbScrollArea
|
|
117 |
bool mPinchGestureOngoing;
|
|
118 |
//to check if decoded image is available
|
|
119 |
bool mDecodedImageAvailable;
|
|
120 |
//to check if the widget is actually in Foreground
|
|
121 |
bool mZoomOngoing;
|
|
122 |
|
43
|
123 |
//view widgets
|
|
124 |
QGraphicsPixmapItem *mZoomItem; //Item containing the pixmap
|
|
125 |
QGraphicsWidget *mZoomWidget; //container :all scaling and transforms would be done on this widget
|
|
126 |
HbIconItem* mBlackBackgroundItem; //for setting black background
|
|
127 |
|
|
128 |
int mFocusIndex;
|
|
129 |
|
|
130 |
//size parameter
|
|
131 |
QSizeF mItemSize; // the actual pixmap size. Keep it updated with latest pixmap size
|
|
132 |
QSizeF mStepCurrentSize; //to save the size before gesture started
|
|
133 |
QSizeF mCurrentSize; //save sizes scaled by gesture
|
|
134 |
QSize mWindowSize; //the window size
|
|
135 |
QSizeF mMinScaleSize; //minimum posible size
|
|
136 |
QSizeF mMinDecScaleSize; //the Minimum scale limit after which the image scaling down should be decelerated
|
|
137 |
QSizeF mMaxScaleSize; // the maximum scale limit
|
|
138 |
QSizeF mMaxScaleDecSize; // the Maximum scale limit after which the image scaling should be decelerated
|
|
139 |
//for animation effect
|
|
140 |
qreal m_FinalAnimatedScaleFactor;
|
|
141 |
QPointF m_AnimRefPoint;
|
|
142 |
QTimeLine *m_AnimTimeLine;
|
|
143 |
//for Decoder support
|
|
144 |
GlxImageDecoderWrapper* mImageDecoder;
|
|
145 |
|
|
146 |
};
|
|
147 |
#endif //GLXZOOMWIDGET_H
|