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