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 |
|
|
101 |
//data members
|
|
102 |
private:
|
|
103 |
//view widgets
|
|
104 |
QGraphicsPixmapItem *mZoomItem; //Item containing the pixmap
|
|
105 |
QGraphicsWidget *mZoomWidget; //container :all scaling and transforms would be done on this widget
|
|
106 |
HbIconItem* mBlackBackgroundItem; //for setting black background
|
|
107 |
|
|
108 |
//view Z values
|
|
109 |
//might push to layouts later
|
|
110 |
|
|
111 |
int mMinZValue ;
|
|
112 |
int mMaxZValue ;
|
|
113 |
|
|
114 |
|
|
115 |
//to be in sync with the model
|
|
116 |
QAbstractItemModel *mModel;
|
|
117 |
int mFocusIndex;
|
|
118 |
|
|
119 |
//size parameter
|
|
120 |
QSizeF mItemSize; // the actual pixmap size. Keep it updated with latest pixmap size
|
|
121 |
QSizeF mStepCurrentSize; //to save the size before gesture started
|
|
122 |
QSizeF mCurrentSize; //save sizes scaled by gesture
|
|
123 |
QSize mWindowSize; //the window size
|
|
124 |
QSizeF mMinScaleSize; //minimum posible size
|
|
125 |
QSizeF mMinDecScaleSize; //the Minimum scale limit after which the image scaling down should be decelerated
|
|
126 |
QSizeF mMaxScaleSize; // the maximum scale limit
|
|
127 |
QSizeF mMaxScaleDecSize; // the Maximum scale limit after which the image scaling should be decelerated
|
|
128 |
//for animation effect
|
|
129 |
qreal m_FinalAnimatedScaleFactor;
|
|
130 |
QPointF m_AnimRefPoint;
|
|
131 |
QTimeLine *m_AnimTimeLine;
|
|
132 |
//for Decoder support
|
|
133 |
GlxImageDecoderWrapper* mImageDecoder;
|
|
134 |
|
|
135 |
//status flags
|
|
136 |
//To check if the decode request has already been send or not
|
|
137 |
bool mImageDecodeRequestSend;
|
|
138 |
//To check if the pinch gesture is in progress to block any events to HbScrollArea
|
|
139 |
bool mPinchGestureOngoing;
|
|
140 |
//to check if decoded image is available
|
|
141 |
bool mDecodedImageAvailable;
|
50
|
142 |
//to check if the widget is actually in Foreground
|
|
143 |
bool mZoomOngoing;
|
44
|
144 |
int mTimerId;
|
43
|
145 |
|
|
146 |
};
|
|
147 |
#endif //GLXZOOMWIDGET_H
|