|
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: Wrapper class to communicate physics related data. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CMIDPHYSICSWRAPPER_H |
|
20 #define CMIDPHYSICSWRAPPER_H |
|
21 |
|
22 #include <e32base.h> |
|
23 #include <aknphysicsobserveriface.h> |
|
24 |
|
25 #include "MMIDLcduiPhysicsInterface.h" |
|
26 #include "MMIDLcduiPhysicsObserver.h" |
|
27 |
|
28 class CAknPhysics; |
|
29 |
|
30 NONSHARABLE_CLASS(CMIDPhysicsWrapper) : public CBase, |
|
31 public MMIDLcduiPhysicsInterface, |
|
32 public MAknPhysicsObserver |
|
33 { |
|
34 public: |
|
35 |
|
36 /** |
|
37 * Two-phased constructor. |
|
38 */ |
|
39 static CMIDPhysicsWrapper* NewL(CCoeControl* aParent, MMIDLcduiPhysicsObserver* aObserver); |
|
40 |
|
41 /** |
|
42 * Destructor. |
|
43 */ |
|
44 virtual ~CMIDPhysicsWrapper(); |
|
45 |
|
46 |
|
47 // From base class MMIDLcduiPhysicsInterface |
|
48 |
|
49 /** |
|
50 * checks whether physics is enabled |
|
51 * |
|
52 * @return ETrue if physics is enabled |
|
53 */ |
|
54 TBool FeatureEnabled(); |
|
55 |
|
56 /** |
|
57 * Initializes physics engine. |
|
58 * |
|
59 * @since S60 v5.0 |
|
60 * @param aWorldSize Collected size of all form items. |
|
61 * @param aViewSize View's size i.e. size of form's rect. |
|
62 * @param aDirection scrolling direction EFalse = vertical, ETrue = horizontal. |
|
63 */ |
|
64 void InitPhysicsL(const TSize& aWorldSize, const TSize& aViewSize, const TBool aDirection); |
|
65 |
|
66 /** |
|
67 * Registers panning position to physics. |
|
68 * |
|
69 * @since S60 v5.0 |
|
70 * @aPosition New panning position |
|
71 */ |
|
72 void RegisterPanningPosition(const TPoint& aPosition); |
|
73 |
|
74 /** |
|
75 * Starts the physics engine. |
|
76 * |
|
77 * @since S60 v5.0 |
|
78 * @param aLength Length of the flick on display (in pixels). |
|
79 * @param aDuration Flick's duration. |
|
80 * @return ETrue if flicking was started. |
|
81 */ |
|
82 TBool StartFlick(const TPoint& aLength, TTime aDuration); |
|
83 |
|
84 /** |
|
85 * Checks whether the physics engine can be stopped. |
|
86 * |
|
87 * @since S60 v5.0 |
|
88 * @return ETrue if the physics engine can be stopped. |
|
89 */ |
|
90 TBool CanBeStopped() const; |
|
91 |
|
92 /** |
|
93 * Stops the physics engine. |
|
94 * |
|
95 * @since S60 v5.0 |
|
96 */ |
|
97 void StopPhysics(); |
|
98 |
|
99 |
|
100 void ResetFriction(); |
|
101 /** |
|
102 * Returns highlight timeout. Tapped item should be activated only after a small delay. |
|
103 * |
|
104 * @since S60 v5.0 |
|
105 * @return Highlight timeout. |
|
106 */ |
|
107 TInt HighlightTimeout() const; |
|
108 |
|
109 |
|
110 /** |
|
111 * Return drag event's treshold. |
|
112 * |
|
113 * @since S60 v5.0 |
|
114 * @return Drag treshold in pixels. |
|
115 */ |
|
116 TInt DragThreshold() const; |
|
117 |
|
118 // from base class MAknPhysicsObserver |
|
119 |
|
120 /** |
|
121 * From MAknPhysicsObserver |
|
122 * Physics emulation has moved the view. |
|
123 * |
|
124 * @since S60 v5.0 |
|
125 * @param aNewPosition The new position of the view. |
|
126 * @param aDrawNow ETrue if client should redraw the screen, otherwise EFalse. |
|
127 * @param aFlags Additional flags, not used currently. |
|
128 */ |
|
129 void ViewPositionChanged(const TPoint& aNewPosition, TBool aDrawNow, TUint aFlags); |
|
130 |
|
131 |
|
132 void ViewPositionChanged(const TPoint& aNewPosition); |
|
133 |
|
134 /** |
|
135 * From MAknPhysicsObserver |
|
136 * Physics emulation has stopped moving the view. |
|
137 * |
|
138 * @since S60 v5.0 |
|
139 */ |
|
140 void PhysicEmulationEnded(); |
|
141 |
|
142 /** |
|
143 * Returns the observer view position. |
|
144 * |
|
145 * @since S60 v5.0 |
|
146 * @return Physics observer view position. |
|
147 */ |
|
148 TPoint ViewPosition() const; |
|
149 |
|
150 private: |
|
151 |
|
152 /** |
|
153 * Constructor. |
|
154 */ |
|
155 CMIDPhysicsWrapper(); |
|
156 |
|
157 /** |
|
158 * Second stage constructor. |
|
159 */ |
|
160 void ConstructL(CCoeControl* aParent, MMIDLcduiPhysicsObserver* aObserver); |
|
161 |
|
162 /** |
|
163 * Checks whether panning and flicking are allowed with current world and |
|
164 * view sizes. |
|
165 * |
|
166 * @since S60 v5.0 |
|
167 * @return ETrue if allowed. |
|
168 */ |
|
169 TBool PhysicsAllowed() const; |
|
170 |
|
171 private: // data |
|
172 |
|
173 /** |
|
174 * Interface to the physics engine. |
|
175 * Own. |
|
176 */ |
|
177 CAknPhysics* iPhysics; |
|
178 |
|
179 /** |
|
180 * Form whose scrolling is controlled by this class. |
|
181 */ |
|
182 CCoeControl* iParent; |
|
183 |
|
184 MMIDLcduiPhysicsObserver* iObserver; |
|
185 }; |
|
186 |
|
187 /** |
|
188 * Factory function |
|
189 * |
|
190 * @since S60 v5.0 |
|
191 * @return pointer to MMIDLcduiPhysicsInterface object |
|
192 */ |
|
193 IMPORT_C MMIDLcduiPhysicsInterface* GetInstanceImpl(CCoeControl* aParent, MMIDLcduiPhysicsObserver* aObserver); |
|
194 |
|
195 #endif // CMIDPHYSICSWRAPPER_H |