|
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: Restrictor of AknPhysics |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_AKNPHYSICSRESTRICTOR_H |
|
20 #define C_AKNPHYSICSRESTRICTOR_H |
|
21 |
|
22 |
|
23 #include <e32base.h> |
|
24 |
|
25 class CAknPhysicsParameterProvider; |
|
26 |
|
27 /** |
|
28 * Physics restrictor |
|
29 * |
|
30 * @lib aknphysics |
|
31 * @since S60 v5.0 |
|
32 */ |
|
33 NONSHARABLE_CLASS( CAknPhysicsRestrictor ) : public CBase |
|
34 { |
|
35 |
|
36 public: |
|
37 |
|
38 /** |
|
39 * Two-phased constructor. |
|
40 */ |
|
41 static CAknPhysicsRestrictor* NewL( |
|
42 CAknPhysicsParameterProvider* aProvider ); |
|
43 |
|
44 /** |
|
45 * Two-phased constructor. |
|
46 */ |
|
47 static CAknPhysicsRestrictor* NewLC( |
|
48 CAknPhysicsParameterProvider* aProvider ); |
|
49 |
|
50 /** |
|
51 * Destructor. |
|
52 */ |
|
53 virtual ~CAknPhysicsRestrictor(); |
|
54 |
|
55 /** |
|
56 * Updates physics environment. |
|
57 * |
|
58 * @param aWorldSize World size. |
|
59 * @param aViewSize View size. |
|
60 * @param aLandscape ETrue if physics is in landscape mode. |
|
61 */ |
|
62 void UpdatePhysicsEnvironment( const TSize& aWorldSize, |
|
63 const TSize& aViewSize, |
|
64 const TBool& aLandscape ); |
|
65 |
|
66 /** |
|
67 * Returns view top position. |
|
68 * |
|
69 * @return Top position. |
|
70 */ |
|
71 TInt ViewTopPosition() const; |
|
72 |
|
73 /** |
|
74 * Returns view bottom position. |
|
75 * |
|
76 * @return Bottom position. |
|
77 */ |
|
78 TInt ViewBottomPosition() const; |
|
79 |
|
80 /** |
|
81 * Returns ETrue if view position is such that there is |
|
82 * additional empty space visible. |
|
83 * |
|
84 * @param aPosition View position to be tested. If there is empty space, |
|
85 * to this variable is stored the view position with empty space hidden. |
|
86 * @return ETrue if additional empty space is visible with |
|
87 * this view position. |
|
88 */ |
|
89 TBool PositionRevealsEmptySpace( TPoint& aPosition ); |
|
90 |
|
91 /** |
|
92 * Returns ETrue if |
|
93 * 1) View position is allowed and it should be |
|
94 * notified to physics observer or |
|
95 * 2) If position has reached the view limit and the limit position |
|
96 * should be notified to observer. If this is the case, |
|
97 * the new modified (limit) position is saved to aPosition. |
|
98 * |
|
99 * @param aPosition View position. |
|
100 * @return ETrue if position is allowed and it should be notified to |
|
101 * physics observer. |
|
102 */ |
|
103 TBool AllowedViewPosition( TPoint& aPosition ); |
|
104 |
|
105 /** |
|
106 * Adjusts drag point if view position has reached the limit position. |
|
107 * |
|
108 * @param aDragPoint Drag point. |
|
109 */ |
|
110 void AdjustDragPoint( TPoint& aDragPoint ); |
|
111 |
|
112 /** |
|
113 * Returns world size. |
|
114 * |
|
115 * @return World size. |
|
116 */ |
|
117 TSize WorldSize() const; |
|
118 |
|
119 /** |
|
120 * Returns ETrue if physics is in landscape. |
|
121 * |
|
122 * @return Landscape value. |
|
123 */ |
|
124 TBool WorldInLandscape() const; |
|
125 |
|
126 /** |
|
127 * Returns physics parameter provider. |
|
128 * |
|
129 * @return Physics parameter provider. |
|
130 */ |
|
131 CAknPhysicsParameterProvider* ParameterProvider() const; |
|
132 |
|
133 /** |
|
134 * Modifies aPosition to view top position. |
|
135 */ |
|
136 void PositionToViewTop( TPoint& aPosition ) const; |
|
137 |
|
138 /** |
|
139 * Modifies aPosition to view bottom position. |
|
140 */ |
|
141 void PositionToViewBottom( TPoint& aPosition ) const; |
|
142 |
|
143 /** |
|
144 * Returns ETrue if view position is out of world boundaries |
|
145 * when colliding. |
|
146 * |
|
147 * @param aPosition View position. |
|
148 * @param aTopCollision ETrue if collision type is top collision, |
|
149 * EFalse if bottom. |
|
150 * @return ETrue if position is out of boundaries. |
|
151 */ |
|
152 TBool PositionIsOutOfBoundaries( const TPoint& aPosition, |
|
153 const TBool& aTopCollision ) const; |
|
154 |
|
155 private: |
|
156 |
|
157 /** |
|
158 * C++ constructor. |
|
159 */ |
|
160 CAknPhysicsRestrictor( CAknPhysicsParameterProvider* aProvider ); |
|
161 |
|
162 /** |
|
163 * Symbian second-phase constructor. |
|
164 */ |
|
165 void ConstructL(); |
|
166 |
|
167 /** |
|
168 * Calculates view limit values. |
|
169 */ |
|
170 void CalculateViewLimits(); |
|
171 |
|
172 /** |
|
173 * Returns ETrue if world fits to view. |
|
174 * |
|
175 * @return ETrue if world fits to view. |
|
176 */ |
|
177 TBool WorldFitsToView(); |
|
178 |
|
179 private: // data |
|
180 |
|
181 /** |
|
182 * World size. |
|
183 */ |
|
184 TSize iWorldSize; |
|
185 |
|
186 /** |
|
187 * View size. |
|
188 */ |
|
189 TSize iViewSize; |
|
190 |
|
191 /** |
|
192 * ETrue if physics is in landscape. |
|
193 */ |
|
194 TBool iLandscape; |
|
195 |
|
196 /** |
|
197 * Physics view position top limit (empty space visible). |
|
198 */ |
|
199 TInt iPositionTopLimit; |
|
200 |
|
201 /** |
|
202 * Physics view position bottom limit (empty space visible). |
|
203 */ |
|
204 TInt iPositionBottomLimit; |
|
205 |
|
206 /** |
|
207 * Physics empty space area (height/width). |
|
208 */ |
|
209 TInt iEmptySpaceArea; |
|
210 |
|
211 /** |
|
212 * Physics parameter provider. |
|
213 * Not own. |
|
214 */ |
|
215 CAknPhysicsParameterProvider* iProvider; |
|
216 |
|
217 /** |
|
218 * ETrue if view position has reached limit. |
|
219 */ |
|
220 TBool iViewReachedLimit; |
|
221 |
|
222 /** |
|
223 * ETrue if there are restrictions to empty space. |
|
224 */ |
|
225 TBool iEmptySpaceRestricted; |
|
226 |
|
227 }; |
|
228 |
|
229 |
|
230 #endif // C_AKNPHYSICSRESTRICTOR_H |