|
1 /* |
|
2 * Copyright (c) 2006-2007 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: Definition of CHuiRosterImpl. CHuiRosterImpl implements the interface |
|
15 * defined by CHuiRoster. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 #ifndef __HUIROSTERIMPL_H__ |
|
22 #define __HUIROSTERIMPL_H__ |
|
23 |
|
24 |
|
25 #include "uiacceltk/HuiRoster.h" |
|
26 #include "uiacceltk/huieventhandler.h" |
|
27 #include "uiacceltk/HuiEvent.h" |
|
28 #include "uiacceltk/HuiRealPoint.h" |
|
29 #include "uiacceltk/HuiRealPoint.h" |
|
30 #include "uiacceltk/HuiGc.h" |
|
31 #include "huieffectable.h" |
|
32 |
|
33 /* Forward declarations. */ |
|
34 class CHuiDisplay; |
|
35 class CHuiLongTapDetector; |
|
36 class CHuiLayout; |
|
37 struct THuiPointerEventDetails; |
|
38 |
|
39 class CHuiFxEngine; |
|
40 class CHuiFxEffect; |
|
41 |
|
42 class CHuiCanvasGc; |
|
43 class CHuiCanvasRenderBuffer; |
|
44 |
|
45 const TReal32 KDefaultDragTresholdInPixelsX = 4.0; |
|
46 const TReal32 KDefaultDragTresholdInPixelsY = 4.0; |
|
47 |
|
48 /** |
|
49 * Roster defines a priority order of control groups shown an a display. |
|
50 * The roster also offers input events to the groups, and handles the |
|
51 * drawing of the groups' root visuals. |
|
52 * Implements the CHuiRoster abstract base class. |
|
53 * |
|
54 * @see CHuiRoster |
|
55 */ |
|
56 NONSHARABLE_CLASS(CHuiRosterImpl) : public CHuiRoster, MHuiEffectable |
|
57 { |
|
58 public: |
|
59 |
|
60 /* Constructors and destructor. */ |
|
61 |
|
62 /** |
|
63 * Constructor. |
|
64 * |
|
65 * @param aDisplay Initial display associated with the roster. |
|
66 */ |
|
67 CHuiRosterImpl(CHuiDisplay* aDisplay); |
|
68 |
|
69 /** |
|
70 * Second-phase constructor. |
|
71 */ |
|
72 void ConstructL(); |
|
73 |
|
74 /** |
|
75 * Destructor. |
|
76 */ |
|
77 virtual ~CHuiRosterImpl(); |
|
78 |
|
79 |
|
80 /* Methods. */ |
|
81 |
|
82 /** |
|
83 * Sets the current display that is using the roster. Multiple displays |
|
84 * may share a roster, but only one of the them uses it at a time. |
|
85 * |
|
86 * @param aDisplay Display. Can be <code>NULL</code>. |
|
87 */ |
|
88 void SetDisplay(CHuiDisplay* aDisplay); |
|
89 |
|
90 /** |
|
91 * Recalculates layout starting from root visuals. |
|
92 */ |
|
93 void SetRect(const TRect& aRect); |
|
94 |
|
95 TRect Rect() const; |
|
96 |
|
97 void ShowL(CHuiControlGroup& aGroup, TInt aWhere = KHuiRosterShowAtTop); |
|
98 |
|
99 void Hide(CHuiControlGroup& aGroup); |
|
100 |
|
101 TInt Find(CHuiControlGroup* aGroup) const; |
|
102 |
|
103 /** |
|
104 * Returns the number of control groups. |
|
105 */ |
|
106 TInt Count() const; |
|
107 |
|
108 /** |
|
109 * Returns a control group. |
|
110 */ |
|
111 CHuiControlGroup& ControlGroup(TInt aIndex) const; |
|
112 |
|
113 /** |
|
114 * Finds a control inside the roster. |
|
115 * |
|
116 * @param aControlId Identifier of the control to find. |
|
117 * |
|
118 * @return Pointer to the control. <code>NULL</code>, if not found. |
|
119 */ |
|
120 CHuiControl* FindControl(TInt aControlId) const; |
|
121 |
|
122 /** |
|
123 * Prepares the visuals for drawing. All visuals |
|
124 * are prepared before the actual drawing begins. |
|
125 * |
|
126 * The visuals are prepared in the same |
|
127 * order than they get drawn. |
|
128 * |
|
129 * @see Draw() |
|
130 * |
|
131 * This default implementation is not |
|
132 * leaving, since it traps the prepare errors |
|
133 * inside and handles the errors by calling |
|
134 * the visual owner prepare draw failed callback. |
|
135 * |
|
136 * @see MHuiVisualOwner::VisualPrepareDrawFailed() |
|
137 * |
|
138 * @return ETrue if the prepare succeeded, or EFail if |
|
139 * the prepare failed. Failing to prepare a draw |
|
140 * terminates the screen refresh and drawing |
|
141 * for the current frame. |
|
142 * |
|
143 */ |
|
144 TBool PrepareDraw() const; |
|
145 |
|
146 /** |
|
147 * Draw the visuals tree. This is done by |
|
148 * recursively drawing the root visuals |
|
149 * in the order they have been added. |
|
150 * |
|
151 * Note that you can affect the drawing order |
|
152 * by calling the MoveVisualToFront - methods. |
|
153 * |
|
154 * @param aGc Graphics context to draw into. |
|
155 */ |
|
156 void Draw(CHuiGc& aGc) const; |
|
157 |
|
158 /** |
|
159 * Draw the visuals tree. This is done by |
|
160 * recursively drawing the root visuals |
|
161 * in the order they have been added. |
|
162 * |
|
163 * Note that you can affect the drawing order |
|
164 * by calling the MoveVisualToFront - methods. |
|
165 * |
|
166 * @param aGc Graphics context to draw into. |
|
167 * @param aDisplay Alterative display where visual tree |
|
168 * is to be drawn. |
|
169 */ |
|
170 void Draw(CHuiGc& aGc, CHuiDisplay* aDisplay) const; |
|
171 void DrawSelf(CHuiGc& aGc, CHuiDisplay* aDisplay) const; |
|
172 void DrawSelfFrozen(CHuiGc& aGc, CHuiDisplay* aDisplay) const; |
|
173 |
|
174 /** |
|
175 * Assigns the visual as a root visual and makes |
|
176 * the area of the visual to cover the entire |
|
177 * display. |
|
178 * |
|
179 * Also, associates Rosters display with the visual. |
|
180 * @see HideVisual() |
|
181 * @see SetVisualToFullArea() |
|
182 */ |
|
183 void ShowVisualL(CHuiVisual* aVisual); |
|
184 |
|
185 /** |
|
186 * Adds the visual to the list of root visuals. Also |
|
187 * also sets the visual to the full area. |
|
188 * |
|
189 * @see ShowVisualL() |
|
190 */ |
|
191 void HideVisual(CHuiVisual* aVisual); |
|
192 |
|
193 /** |
|
194 * Gives input focus to a control. |
|
195 */ |
|
196 void SetFocus(CHuiControl& aControl); |
|
197 |
|
198 /** |
|
199 * Clears the input focus so that no control has focus. |
|
200 */ |
|
201 void ClearFocus(); |
|
202 |
|
203 /** |
|
204 * Called when a key event occurs. The input event is offered to the |
|
205 * controls in the order defined by the groups. |
|
206 */ |
|
207 TBool HandleEventL(const THuiEvent& aEvent); |
|
208 |
|
209 /** |
|
210 * Tell all visuals to post their change notifications. |
|
211 */ |
|
212 void ScanDirty(); |
|
213 |
|
214 /** |
|
215 * Tell all visuals to post their change notifications. |
|
216 */ |
|
217 void ScanTransformedDirty(CHuiGc& aGc, CHuiDisplay* aDisplay); |
|
218 |
|
219 /** |
|
220 * Moves a root visual to the front inside its roster entry. |
|
221 * |
|
222 * @param aRootVisual Visual to move. |
|
223 */ |
|
224 void MoveVisualToFront(CHuiVisual* aRootVisual); |
|
225 |
|
226 /** |
|
227 * Moves a root visual to the front inside its roster entry. |
|
228 * |
|
229 * @param aRootVisual Visual to move. |
|
230 */ |
|
231 void MoveVisualToFront(const CHuiVisual& aRootVisual); |
|
232 |
|
233 /** |
|
234 * Moves a root visual to the given position. |
|
235 * |
|
236 * @param aRootVisual Visual to move. |
|
237 */ |
|
238 void Move(CHuiVisual* aVisual, TInt aPos); |
|
239 |
|
240 /** |
|
241 * Updates the layout positions of all the root visuals in this roster. |
|
242 * Typically called on a resolution change. |
|
243 */ |
|
244 void UpdateLayout(); |
|
245 |
|
246 /** |
|
247 * Notifies all visuals of a change in the environment's skin. |
|
248 */ |
|
249 void NotifySkinChangedL(); |
|
250 |
|
251 /** |
|
252 * Debug help for dumping the visual trees to the console. |
|
253 */ |
|
254 void DumpRootLevelTrees() const; |
|
255 /** |
|
256 * Clear change flags of the visuals in the roster. This is called by the |
|
257 * refresh loop after the frame has been fully drawn. |
|
258 */ |
|
259 void ClearChanged(); |
|
260 |
|
261 RHuiObserverArray<MHuiEventHandler>& Observers(THuiInputType aInputType); |
|
262 |
|
263 /** |
|
264 * Sets treshold which pointer needs to be moved before starting to send |
|
265 * drag events.Default treshold is zero pixels, so any movement will |
|
266 * trigger drag events. |
|
267 * |
|
268 * NOTE: Not every unit type is feasible. Use only types like: |
|
269 * EHuiUnitPixel, EHuiUnitRelativeToDisplay, EHuiUnitS60 |
|
270 * |
|
271 * @param aEventHandler Event handler to which treshold affects. |
|
272 * @param aXYMetric Treshold in metric units. |
|
273 */ |
|
274 void SetPointerDragThresholdL(const MHuiEventHandler& aEventHandler, const THuiXYMetric& aXYMetric); |
|
275 |
|
276 /** |
|
277 * Disables long tap events when dragging is going on. Default |
|
278 * functionality is that long tap event will be delivered simultaneously |
|
279 * with drag events. |
|
280 * |
|
281 * @param aEventHandler Event handler to which disabling goes. |
|
282 * @param aDisable Boolean to indicate whether feature is disabled or not. |
|
283 */ |
|
284 void DisableLongTapEventsWhenDraggingL(const MHuiEventHandler& aEventHandler, TBool aDisable = ETrue); |
|
285 |
|
286 /** |
|
287 * Tells if this roster has control groups which have transformations to be applied. |
|
288 * @return ETrue if transformations exist for any control group, otherwise EFalse |
|
289 */ |
|
290 TBool HasTransformedControlGroups() const; |
|
291 |
|
292 /** |
|
293 * Enables or disbles drawing external content to canvas visuals. This can be set during drawing the visual hierarchy. |
|
294 * |
|
295 * @param aEnable Enable or disable external content. |
|
296 */ |
|
297 void SetDrawingExternalContent(TBool aEnable); |
|
298 |
|
299 /** |
|
300 * Returns whether external content can be drawn to canvas visuals. |
|
301 * |
|
302 * @return Content drawing state. |
|
303 */ |
|
304 TBool IsDrawingExternalContent() const; |
|
305 |
|
306 /** |
|
307 * Removes the external content visual from canvas visuals. |
|
308 * |
|
309 * @param aExternalContentVisual External content visual. |
|
310 */ |
|
311 void RemoveExternalContentVisualFromParentL(CHuiVisual* aExternalContentVisual); |
|
312 |
|
313 /** |
|
314 * Removes the external content visual from canvas visuals. Recursive method. |
|
315 * |
|
316 * @param aExternalContentVisual External content visual. |
|
317 */ |
|
318 void RemoveExternalContentVisualFromParentL(CHuiVisual* aExternalContentVisual, CHuiLayout* aLayout); |
|
319 |
|
320 void FreezeVisibleContentL(TBool aFreeze = ETrue); |
|
321 |
|
322 TBool IsVisibleContentFrozen() const; |
|
323 |
|
324 // From MHuiEffectable |
|
325 void EffectSetEffect(CHuiFxEffect* aEffect); |
|
326 TReal32 EffectOpacityTarget() const; |
|
327 void EffectSetOpacity(TReal32 aOpacity); |
|
328 void EffectDrawSelf( CHuiGc &aGc, const TRect & aDisplayRect) const; |
|
329 THuiRealRect EffectDisplayRect() const __SOFTFP; |
|
330 void SetLoadingEffect(TBool aLoading); |
|
331 void EffectSetSource( TBool aIsInput1 ); |
|
332 TBool EffectGetSource() const; |
|
333 protected: |
|
334 |
|
335 /* Methods. */ |
|
336 |
|
337 /** |
|
338 * Appends a new control group on top of the roster. |
|
339 * |
|
340 * @param aGroup Control group to add. |
|
341 */ |
|
342 void AppendL(CHuiControlGroup* aGroup); |
|
343 |
|
344 /** |
|
345 * Inserts a control group into a specific position in the roster. |
|
346 * |
|
347 * @param aGroup Control group. |
|
348 * @param aPos Position to insert into. |
|
349 * |
|
350 * @leave KErrAlreadyExists The control group is already in the roster. |
|
351 */ |
|
352 void InsertL(CHuiControlGroup* aGroup, TInt aPos); |
|
353 |
|
354 /** |
|
355 * Moves an existing control group into a new position in the roster. |
|
356 * |
|
357 * @param aPos Position to move into. |
|
358 */ |
|
359 void Move(CHuiControlGroup* aGroup, TInt aPos); |
|
360 |
|
361 /** |
|
362 * Removes a control group from the roster. |
|
363 * |
|
364 * @param aGroup Control group to remove. |
|
365 */ |
|
366 void Remove(CHuiControlGroup* aGroup); |
|
367 |
|
368 /** |
|
369 * Update positions of root visuals to fit the entire display area. |
|
370 */ |
|
371 void SetVisualToFullArea(CHuiVisual* aVisual); |
|
372 |
|
373 TBool OfferPointerEventWithinTreeL(CHuiVisual& aVisual, const THuiEvent& aEvent, TBool aUseDispRect = EFalse); |
|
374 |
|
375 MHuiEffectable* Effectable(); |
|
376 |
|
377 private: |
|
378 |
|
379 /* Private data structures. */ |
|
380 |
|
381 |
|
382 private: |
|
383 |
|
384 /* Private methods. */ |
|
385 |
|
386 /** |
|
387 * Finds the entry for the visual's control group. |
|
388 * |
|
389 * @return Reference to roster entry. |
|
390 * |
|
391 * @panic |
|
392 */ |
|
393 CHuiRosterEntry* EntryForVisual(const CHuiVisual* aVisual); |
|
394 |
|
395 /** |
|
396 * Changes the control that has input focus. |
|
397 */ |
|
398 void ChangeInputFocus(CHuiControl* aControl); |
|
399 |
|
400 /** |
|
401 * Determines if the roster has changed so much that everything needs to |
|
402 * be redrawn when the next refresh occurs. |
|
403 */ |
|
404 TBool Changed() const; |
|
405 |
|
406 /** |
|
407 * Flags the roster as changed or not changed. |
|
408 * |
|
409 * @param aIsChanged ETrue, if the roster should be marked as changed. |
|
410 */ |
|
411 void SetChanged(TBool aIsChanged = ETrue); |
|
412 |
|
413 /** |
|
414 * Utilizes tactile feedbacks. Called on the pointer event. |
|
415 * |
|
416 * @param aEvent Pointer event. |
|
417 */ |
|
418 void HandleTactileFeedback( const THuiEvent& aEvent ); |
|
419 |
|
420 |
|
421 |
|
422 /** |
|
423 * Adds new event detail struct to the iPointerEventDetails |
|
424 */ |
|
425 void AddEventDetailsL(MHuiEventHandler* aEventHandler, const THuiXYMetric& aXYMetric, TBool aDisable); |
|
426 |
|
427 /** |
|
428 * Cleans iPointerEventDetails from details that are not used by |
|
429 * any observer |
|
430 */ |
|
431 void CleanEventDetails(); |
|
432 |
|
433 /** |
|
434 * Checks if event handler is within threshold range. |
|
435 */ |
|
436 TBool DragEventOutOfRangeL(MHuiEventHandler* aEventHandler, const THuiEvent& aEvent); |
|
437 |
|
438 /** |
|
439 * Checks if long tap event allowed in current state. Checks if there is already |
|
440 * drag events sent and if long tap event are disabled during dragging. |
|
441 */ |
|
442 TBool IsLongTapEventAllowed(MHuiEventHandler* aEventHandler); |
|
443 |
|
444 /** |
|
445 * Cleans dragging flags from iPointerEventDetails |
|
446 */ |
|
447 void CleanDraggingFlags(); |
|
448 |
|
449 /** |
|
450 * Traverses through visual tree and draws outline for visual |
|
451 */ |
|
452 void DrawBoundaries( CHuiGc& aGc, CHuiVisual* aVisual, TBool aDrawOutline ) const; |
|
453 |
|
454 private: |
|
455 |
|
456 /** Area occupied by the roster. */ |
|
457 TRect iRect; |
|
458 |
|
459 CHuiDisplay* iDisplay; |
|
460 |
|
461 /** List of control groups. None of the groups is owned by the roster. */ |
|
462 //RPointerArray<CHuiControlGroup> iGroups; |
|
463 |
|
464 RPointerArray<CHuiRosterEntry> iEntries; |
|
465 |
|
466 /** One of the controls in the roster may have input focus. */ |
|
467 CHuiControl* iInputFocus; |
|
468 |
|
469 /** Array of root visuals. All the visuals of the visible controls |
|
470 are added here (as direct children or indirect descendants). */ |
|
471 //RPointerArray<CHuiVisual> iRootVisuals; |
|
472 |
|
473 /** Changed flag for the roster itself. */ |
|
474 TBool iChanged; |
|
475 |
|
476 RHuiObserverArray<MHuiEventHandler> iPointerDragObservers; |
|
477 RHuiObserverArray<MHuiEventHandler> iUnhandledPointerObservers; |
|
478 RHuiObserverArray<MHuiEventHandler> iLongTapObservers; |
|
479 |
|
480 /** For detecting long pointer events. */ |
|
481 CHuiLongTapDetector* iLongTapDetector; |
|
482 |
|
483 TBool iTactileFeedbackHandled; |
|
484 |
|
485 /** List of event details how to handle events */ |
|
486 RPointerArray<THuiPointerEventDetails> iPointerEventDetails; |
|
487 /** Initial event when starting dragging */ |
|
488 THuiEvent iInitialDownEvent; |
|
489 |
|
490 TBool iDrawEvenIfDisabledDrawInRoster; |
|
491 |
|
492 /** Effect */ |
|
493 CHuiFxEffect* iEffect; |
|
494 TReal32 iEffectOpacity; |
|
495 TBool iIsInput1; |
|
496 |
|
497 /** Render buffer */ |
|
498 CHuiCanvasGc* iCanvasGc; |
|
499 CHuiCanvasRenderBuffer* iCanvasRenderBuffer; |
|
500 CHuiGc::TOrientation iCanvasRenderBufferOrientation; |
|
501 }; |
|
502 |
|
503 #endif // __HUIROSTERIMPL_H__ |