|
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: Implementation of CHuiLayout class. Layouts are visuals that |
|
15 * manage the placement of a set of child visuals. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 #include <AknUtils.h> |
|
22 |
|
23 #include "uiacceltk/HuiLayout.h" // Class definition |
|
24 #include "uiacceltk/HuiControl.h" |
|
25 #include "uiacceltk/HuiDrawing.h" |
|
26 #include "uiacceltk/HuiDisplay.h" |
|
27 #include "uiacceltk/HuiPanic.h" |
|
28 #include "uiacceltk/HuiUtil.h" |
|
29 #include "HuiRosterImpl.h" |
|
30 #include "huilayoutdata.h" |
|
31 |
|
32 #include "HuiFxEffect.h" |
|
33 #include "HuiRenderPlugin.h" |
|
34 #include "huicanvasgc.h" |
|
35 #include "Matrix.h" |
|
36 // |
|
37 // methods |
|
38 // |
|
39 |
|
40 EXPORT_C CHuiLayout* CHuiLayout::AddNewL(CHuiControl& aOwnerControl, |
|
41 CHuiLayout* aParentLayout) |
|
42 { |
|
43 CHuiLayout* layout = aOwnerControl.AppendLayoutL(EHuiLayoutTypeLayout, |
|
44 aParentLayout); |
|
45 return layout; |
|
46 } |
|
47 |
|
48 |
|
49 EXPORT_C CHuiLayout::CHuiLayout(MHuiVisualOwner& aOwner) |
|
50 : CHuiVisual(aOwner) |
|
51 { |
|
52 } |
|
53 |
|
54 |
|
55 EXPORT_C void CHuiLayout::ConstructL() |
|
56 { |
|
57 CHuiVisual::ConstructL(); |
|
58 iHuiLayoutPrivateData = new (ELeave) THuiLayoutPrivateData; |
|
59 CHuiRenderPlugin& renderplugin = CHuiStatic::Renderer(); |
|
60 iHuiLayoutPrivateData->iGc = renderplugin.CreateCanvasGcL(); |
|
61 } |
|
62 |
|
63 |
|
64 EXPORT_C CHuiLayout::~CHuiLayout() |
|
65 { |
|
66 if ( iHuiLayoutPrivateData ) // a Fix for OOM situations, tried to dereference NULL pointer |
|
67 { |
|
68 delete iHuiLayoutPrivateData->iScroll; |
|
69 |
|
70 // Remove children in reverse order. |
|
71 for(TInt i = Count() - 1; i >= 0; --i) |
|
72 { |
|
73 Remove(iHuiLayoutPrivateData->iChildren[i]); |
|
74 } |
|
75 iHuiLayoutPrivateData->iChildren.Reset(); |
|
76 delete iHuiLayoutPrivateData->iGc; |
|
77 delete iHuiLayoutPrivateData; |
|
78 } |
|
79 } |
|
80 |
|
81 |
|
82 EXPORT_C void CHuiLayout::RemoveAndDestroyAllD() |
|
83 { |
|
84 // Make sure we do not re-layout during destruction |
|
85 SetFlag( EHuiVisualFlagFreezeLayout ); |
|
86 |
|
87 for(TInt i = Count() - 1; i >= 0; --i) |
|
88 { |
|
89 iHuiLayoutPrivateData->iChildren[i]->RemoveAndDestroyAllD(); |
|
90 } |
|
91 iHuiLayoutPrivateData->iChildren.Reset(); |
|
92 |
|
93 CHuiVisual::RemoveAndDestroyAllD(); |
|
94 } |
|
95 |
|
96 |
|
97 EXPORT_C void CHuiLayout::AppendL(CHuiVisual* aVisual, TInt aLayoutTransitionTime) |
|
98 { |
|
99 ASSERT(aVisual != NULL); |
|
100 __ASSERT_ALWAYS( iHuiLayoutPrivateData->iChildren.Find(aVisual) == KErrNotFound, |
|
101 THuiPanic::Panic(THuiPanic::ELayoutDuplicateVisual) ); |
|
102 |
|
103 User::LeaveIfError( iHuiLayoutPrivateData->iChildren.Append(aVisual) ); |
|
104 |
|
105 CHuiLayout* oldLayout = aVisual->Layout(); |
|
106 if (oldLayout != NULL) |
|
107 { |
|
108 // If this visual is already a member of another layout, remove it from the old one first. |
|
109 oldLayout->Remove(aVisual); |
|
110 } |
|
111 else |
|
112 { |
|
113 // if the visual is a showing as root visual before, remove it from the roster |
|
114 if ( aVisual->Display() ) |
|
115 { |
|
116 aVisual->Display()->Roster().HideVisual( aVisual ); |
|
117 } |
|
118 } |
|
119 |
|
120 aVisual->SetLayout(this); |
|
121 |
|
122 // Update the visual's layout immediately. |
|
123 if(!(Flags() & EHuiVisualFlagFreezeLayout)) |
|
124 { |
|
125 UpdateChildrenLayout(aLayoutTransitionTime); |
|
126 } |
|
127 |
|
128 SetChanged(); |
|
129 } |
|
130 |
|
131 |
|
132 EXPORT_C void CHuiLayout::InsertL(CHuiVisual* aVisual, TInt aPosition, TInt aLayoutTransitionTime) |
|
133 { |
|
134 ASSERT(aVisual != NULL); |
|
135 __ASSERT_ALWAYS( iHuiLayoutPrivateData->iChildren.Find(aVisual) == KErrNotFound, |
|
136 THuiPanic::Panic(THuiPanic::ELayoutDuplicateVisual) ); |
|
137 ASSERT((aPosition >= 0) && aPosition <= Count()); |
|
138 |
|
139 iHuiLayoutPrivateData->iChildren.InsertL(aVisual, aPosition); |
|
140 |
|
141 CHuiLayout* oldLayout = aVisual->Layout(); |
|
142 if (oldLayout != NULL) |
|
143 { |
|
144 // If this visual is already a member of another layout, remove it from the old one first. |
|
145 oldLayout->Remove(aVisual); |
|
146 } |
|
147 else |
|
148 { |
|
149 // if the visual is a showing as root visual before, remove it from the roster |
|
150 if ( aVisual->Display() ) |
|
151 { |
|
152 aVisual->Display()->Roster().HideVisual( aVisual ); |
|
153 } |
|
154 } |
|
155 |
|
156 // Update the visual's layout immediately. |
|
157 aVisual->SetLayout(this); |
|
158 |
|
159 if(!(Flags() & EHuiVisualFlagFreezeLayout)) |
|
160 { |
|
161 UpdateChildrenLayout(aLayoutTransitionTime); |
|
162 } |
|
163 |
|
164 SetChanged(); |
|
165 } |
|
166 |
|
167 |
|
168 EXPORT_C void CHuiLayout::Remove(CHuiVisual* aVisual, TInt aLayoutTransitionTime) |
|
169 { |
|
170 TInt index = iHuiLayoutPrivateData->iChildren.Find(aVisual); |
|
171 /*__ASSERT_DEBUG(index != KErrNotFound, |
|
172 THuiPanic::Panic(THuiPanic::EInternal));*/ |
|
173 if(index != KErrNotFound) |
|
174 { |
|
175 iHuiLayoutPrivateData->iChildren.Remove(index); |
|
176 aVisual->SetLayout(NULL); // defect. this should check if there is a Host()->ContainerLayout() |
|
177 |
|
178 // If the control group of the aVisual is showing in a roster, |
|
179 // we need to add it as the root visual of that roster |
|
180 /* |
|
181 for ( TInt d = 0; d < Env().DisplayCount() ; d ++ ) |
|
182 { |
|
183 if ( (Env().Displays())[d]->Roster().Find( aVisual->Owner().ControlGroup() ) != KErrNotFound ) |
|
184 { |
|
185 TRAP_IGNORE( (Env().Displays())[d]->Roster().ShowVisualL( aVisual ) ); |
|
186 break; |
|
187 } |
|
188 }*/ |
|
189 |
|
190 // Update the layout of all the children immediately. |
|
191 if(!(Flags() & EHuiVisualFlagFreezeLayout)) |
|
192 { |
|
193 UpdateChildrenLayout(aLayoutTransitionTime); |
|
194 } |
|
195 |
|
196 SetChanged(); |
|
197 } |
|
198 } |
|
199 |
|
200 |
|
201 EXPORT_C TInt CHuiLayout::Count() const |
|
202 { |
|
203 return iHuiLayoutPrivateData->iChildren.Count(); |
|
204 } |
|
205 |
|
206 |
|
207 EXPORT_C CHuiVisual& CHuiLayout::Visual(TInt aIndex) const |
|
208 { |
|
209 return *(iHuiLayoutPrivateData->iChildren[aIndex]); |
|
210 } |
|
211 |
|
212 |
|
213 EXPORT_C TInt CHuiLayout::FindVisual(const CHuiVisual* aVisual) const |
|
214 { |
|
215 for(TInt i = 0; i < Count(); ++i) |
|
216 { |
|
217 if(&Visual(i) == aVisual) |
|
218 { |
|
219 return i; |
|
220 } |
|
221 } |
|
222 return KErrNotFound; |
|
223 } |
|
224 |
|
225 |
|
226 THuiRealRect CHuiLayout::BoundingRect() const |
|
227 { |
|
228 THuiRealPoint min; |
|
229 THuiRealPoint max; |
|
230 |
|
231 min.iX = 0; |
|
232 min.iY = 0; |
|
233 max.iX = 0; |
|
234 max.iY = 0; |
|
235 |
|
236 TInt count = Count(); |
|
237 if(count > 0) |
|
238 { |
|
239 min = Visual(0).Pos().Target(); |
|
240 max = min + Visual(0).Size().Target(); |
|
241 } |
|
242 |
|
243 for(TInt i = 1; i < count; ++i) |
|
244 { |
|
245 THuiRealPoint tl = Visual(i).Pos().Target(); |
|
246 THuiRealPoint br = tl + Visual(i).Size().Target(); |
|
247 |
|
248 min.iX = Min(min.iX, tl.iX); |
|
249 min.iY = Min(min.iY, tl.iY); |
|
250 max.iX = Max(max.iX, br.iX); |
|
251 max.iY = Max(max.iY, br.iY); |
|
252 } |
|
253 |
|
254 return THuiRealRect(min, max); |
|
255 } |
|
256 |
|
257 |
|
258 EXPORT_C THuiRealSize CHuiLayout::InnerSize() const __SOFTFP |
|
259 { |
|
260 // Determine the size of this layout in pixels. |
|
261 THuiRealSize innerSizeChild = Size().RealTarget().AsSize(); // not correct units, but will work as fallback value if base unit is in pixels |
|
262 THuiRealPoint innerSizePx = LocalPointInPixels(Size().RealTarget(), EHuiReferenceStateTarget); |
|
263 |
|
264 // Subtract outer paddings. |
|
265 THuiRealRect paddingInPixels = PaddingInPixels(EHuiReferenceStateTarget); |
|
266 innerSizePx.iX -= paddingInPixels.iTl.iX + paddingInPixels.iBr.iX; |
|
267 innerSizePx.iY -= paddingInPixels.iTl.iY + paddingInPixels.iBr.iY; |
|
268 |
|
269 // Convert the result into base units of *this* layout. |
|
270 CHuiVisual* child = 0; |
|
271 if (iHuiLayoutPrivateData->iChildren.Count()) |
|
272 { |
|
273 child = iHuiLayoutPrivateData->iChildren[0]; // get the first child, if there isn't one, then nothing to do anyway |
|
274 } |
|
275 if(child) |
|
276 { |
|
277 innerSizeChild = child->PixelPointInUnits(innerSizePx, BaseUnit().Abs(), EHuiReferenceStateTarget).AsSize(); |
|
278 } |
|
279 |
|
280 return innerSizeChild; |
|
281 } |
|
282 |
|
283 |
|
284 EXPORT_C THuiRealPoint CHuiLayout::InnerTopLeft() const __SOFTFP |
|
285 { |
|
286 THuiRealPoint topLeftChild(0, 0); |
|
287 CHuiVisual* child = 0; |
|
288 if (iHuiLayoutPrivateData->iChildren.Count()) |
|
289 { |
|
290 child = iHuiLayoutPrivateData->iChildren[0]; // get the first child, if there isn't one, then nothing to do anyway |
|
291 } |
|
292 if(child) |
|
293 { |
|
294 topLeftChild = child->PixelPointInUnits(PaddingInPixels().iTl, BaseUnit().Abs(), EHuiReferenceStateTarget); |
|
295 } |
|
296 return topLeftChild; |
|
297 } |
|
298 |
|
299 |
|
300 EXPORT_C void CHuiLayout::SetSize(const THuiRealSize& aSize, TInt aTransitionTime) |
|
301 { |
|
302 CHuiVisual::SetSize(aSize, aTransitionTime); |
|
303 |
|
304 // The default layout does not need to update its children. |
|
305 } |
|
306 |
|
307 |
|
308 EXPORT_C void CHuiLayout::UpdateChildrenLayout(TInt aTransitionTime) |
|
309 { |
|
310 // Update the layout of all children. |
|
311 TInt count = Count(); |
|
312 for(TInt i = 0; i < count; ++i) |
|
313 { |
|
314 //Ignore inactive child visuals |
|
315 if ( iHuiLayoutPrivateData->iChildren[i]->Flags() & EHuiVisualFlagInactive ) |
|
316 { |
|
317 continue; |
|
318 } |
|
319 UpdateChildLayout(i, aTransitionTime); |
|
320 } |
|
321 |
|
322 CHuiVisual::UpdateChildrenLayout(aTransitionTime); |
|
323 |
|
324 // Report that the layout of this layout visual has been fully updated. |
|
325 ReportLayoutUpdate(); |
|
326 } |
|
327 |
|
328 |
|
329 EXPORT_C void CHuiLayout::UpdateChildLayout(TInt aIndex, TInt aTransitionTime) |
|
330 { |
|
331 THuiRealRect rect; |
|
332 TSize size; |
|
333 TPoint pos; |
|
334 TInt ordinal = ChildOrdinal(aIndex); |
|
335 CHuiVisual* child = iHuiLayoutPrivateData->iChildren[aIndex]; |
|
336 TInt flags = child->Flags(); |
|
337 |
|
338 TInt transitionTime = aTransitionTime; |
|
339 |
|
340 if(flags & EHuiVisualFlagManualTransitionTime) |
|
341 { |
|
342 // override the parent's transition time with our local one. |
|
343 transitionTime = TransitionTime(); |
|
344 } |
|
345 |
|
346 // if either flag is missing, call child rect... |
|
347 TBool bothManual = (flags & EHuiVisualFlagManualPosition) && (flags & EHuiVisualFlagManualSize); |
|
348 if(!bothManual) |
|
349 { |
|
350 TInt childRectStatus = ChildRect(ordinal, rect); |
|
351 if(childRectStatus != THuiLayoutChildRectNotImplemented) |
|
352 { |
|
353 if(!(flags & EHuiVisualFlagManualPosition) && (childRectStatus & THuiLayoutChildRectPosUpdateNeeded)) |
|
354 { |
|
355 child->SetPos(rect.iTl, transitionTime); |
|
356 } |
|
357 if(!(flags & EHuiVisualFlagManualSize) && (childRectStatus & THuiLayoutChildRectSizeUpdateNeeded)) |
|
358 { |
|
359 child->SetSize(rect.Size(), transitionTime); |
|
360 } |
|
361 } |
|
362 else |
|
363 { |
|
364 if(!(flags & EHuiVisualFlagManualPosition) && ChildPos(ordinal, pos)) |
|
365 { |
|
366 child->SetPos(pos, transitionTime); |
|
367 } |
|
368 if(!(flags & EHuiVisualFlagManualSize) && ChildSize(ordinal, size)) |
|
369 { |
|
370 child->SetSize(size, transitionTime); |
|
371 } |
|
372 } |
|
373 } |
|
374 child->ReportLayoutUpdate(); |
|
375 } |
|
376 |
|
377 |
|
378 EXPORT_C TInt CHuiLayout::ChildOrdinal(TInt aIndex) |
|
379 { |
|
380 return aIndex; |
|
381 } |
|
382 |
|
383 |
|
384 EXPORT_C TBool CHuiLayout::ChildSize(TInt /*aOrdinal*/, TSize& /*aSize*/) |
|
385 { |
|
386 // The default layout doesn't constrain the sizes of the children. |
|
387 return EFalse; |
|
388 } |
|
389 |
|
390 EXPORT_C TBool CHuiLayout::ChildPos(TInt /*aOrdinal*/, TPoint& /*aPos*/) |
|
391 { |
|
392 // The default layout lets the children position themselves. |
|
393 return EFalse; |
|
394 } |
|
395 |
|
396 EXPORT_C TInt CHuiLayout::ChildRect(TInt /*aOrdinal*/, THuiRealRect& /*aPos*/) |
|
397 { |
|
398 // The default layout lets the children position themselves. |
|
399 return THuiLayoutChildRectNotImplemented; |
|
400 } |
|
401 |
|
402 |
|
403 EXPORT_C void CHuiLayout::SetInnerPadding(const TPoint& aInnerPadding) |
|
404 { |
|
405 iHuiLayoutPrivateData->iInnerPadding.iX = THuiMetric(aInnerPadding.iX, EHuiUnitPixel); |
|
406 iHuiLayoutPrivateData->iInnerPadding.iY = THuiMetric(aInnerPadding.iY, EHuiUnitPixel); |
|
407 SetChanged(); |
|
408 } |
|
409 |
|
410 |
|
411 EXPORT_C void CHuiLayout::SetInnerPadding(const THuiXYMetric& aInnerPadding) |
|
412 { |
|
413 iHuiLayoutPrivateData->iInnerPadding = aInnerPadding; |
|
414 SetChanged(); |
|
415 } |
|
416 |
|
417 |
|
418 EXPORT_C const THuiXYMetric& CHuiLayout::InnerPadding() const |
|
419 { |
|
420 return iHuiLayoutPrivateData->iInnerPadding; |
|
421 } |
|
422 |
|
423 |
|
424 EXPORT_C THuiRealPoint CHuiLayout::InnerPaddingInBaseUnits() const __SOFTFP |
|
425 { |
|
426 THuiRealPoint innerPaddingPx = MetricToPixels(iHuiLayoutPrivateData->iInnerPadding, EHuiReferenceStateTarget); |
|
427 return PixelPointInUnits(innerPaddingPx, BaseUnit().Abs(), EHuiReferenceStateTarget); |
|
428 } |
|
429 |
|
430 |
|
431 EXPORT_C TInt CHuiLayout::HorizontalInnerPadding() const |
|
432 { |
|
433 return 0; //iHuiLayoutPrivateData->iXPadding; |
|
434 } |
|
435 |
|
436 |
|
437 EXPORT_C TInt CHuiLayout::VerticalInnerPadding() const |
|
438 { |
|
439 return 0; //iHuiLayoutPrivateData->iYPadding; |
|
440 } |
|
441 |
|
442 |
|
443 EXPORT_C TBool CHuiLayout::PrepareDrawL() |
|
444 { |
|
445 if (Flags() & EHuiVisualFlagDrawOnlyAsExternalContent) |
|
446 { |
|
447 // This is used only as external content visual. Return now if we are not currently drawing |
|
448 // external content. |
|
449 if (!Display() || !Display()->RosterImpl().IsDrawingExternalContent()) |
|
450 { |
|
451 return ETrue; |
|
452 } |
|
453 } |
|
454 |
|
455 // The layout itself is invisible. Only its children can be seen. |
|
456 TInt count = Count(); |
|
457 for(TInt i = 0; i < count; ++i) |
|
458 { |
|
459 CHuiVisual* visual = iHuiLayoutPrivateData->iChildren[i]; |
|
460 //Ignore inactive child visuals |
|
461 if ( visual->Flags()& EHuiVisualFlagInactive ) |
|
462 { |
|
463 continue; |
|
464 } |
|
465 TBool successfullyPrepared = ETrue; |
|
466 TRAPD(err, successfullyPrepared = visual->PrepareDrawL()); |
|
467 if (err != KErrNone) |
|
468 { |
|
469 // Handle the error by calling the visual owner |
|
470 // errorhandling callback |
|
471 visual->Owner().VisualPrepareDrawFailed(*visual, err); |
|
472 return EFalse; |
|
473 } |
|
474 if (!successfullyPrepared) |
|
475 { |
|
476 // we can stop preparing the rest of the children |
|
477 // if one prepare failed (we won't be drawing anything |
|
478 // anyway) |
|
479 |
|
480 // also if the prepare failed but there was not a leave, |
|
481 // we assume it was already handled |
|
482 return EFalse; |
|
483 } |
|
484 } |
|
485 return ETrue; |
|
486 } |
|
487 |
|
488 |
|
489 EXPORT_C void CHuiLayout::Draw(CHuiGc& aGc) const |
|
490 { |
|
491 if (Flags() & EHuiVisualFlagDrawOnlyAsExternalContent) |
|
492 { |
|
493 // This is used only as external content visual. Return now if we are not currently drawing |
|
494 // external content. |
|
495 if (!Display() || !Display()->RosterImpl().IsDrawingExternalContent()) |
|
496 { |
|
497 return; |
|
498 } |
|
499 } |
|
500 |
|
501 if(iOpacity.Now() <= EPSILON && (Effect() && !Effect()->IsSemitransparent())) |
|
502 { |
|
503 // This will not be visible due to being completely transparent. |
|
504 return; |
|
505 } |
|
506 |
|
507 if (( IsDelayedEffectSource()||Freezed() ) && StoredRenderBuffer()) |
|
508 { |
|
509 DrawStoredBitmap(aGc); |
|
510 return; |
|
511 } |
|
512 if (!HasActiveChilderen() && !Brushes() && !Effect()) |
|
513 { |
|
514 // No children, no brushes just return. |
|
515 return; |
|
516 } |
|
517 |
|
518 |
|
519 /** @todo Wouldn't it be possible to just extend CHuiVisual::Draw() |
|
520 instead of redefining the entire method? */ |
|
521 |
|
522 THuiRealRect area = DisplayRect(); |
|
523 |
|
524 // Apply local transformation. |
|
525 EnterLocalProjection(aGc, ETrue, 0.f, &area); |
|
526 Transform(aGc, ETrue, &area); |
|
527 |
|
528 DrawBrushes(aGc, EHuiBrushLayerBackground); |
|
529 |
|
530 if(Clipping()) |
|
531 { |
|
532 // @todo Clipping not going to work if there is a transformation? |
|
533 // Layout clipping is not affected by transformation. |
|
534 aGc.Enable(CHuiGc::EFeatureClipping); |
|
535 aGc.PushClip(); |
|
536 aGc.Clip(area); |
|
537 } |
|
538 |
|
539 // Can we draw effect |
|
540 TBool canUseEffectDrawing = Effect() && !LoadingEffect(); |
|
541 |
|
542 // Flag to know what we did |
|
543 TBool didDrawEffect = EFalse; |
|
544 |
|
545 if (canUseEffectDrawing) |
|
546 { |
|
547 // Note that EHuiVisualFlagOpaqueHint improves performance a lot in cached effect drawing |
|
548 TBool transparent = !(Flags() & EHuiVisualFlagOpaqueHint) && iOpacity.Now() < 1.0f; |
|
549 TBool refreshCache = Changed(); |
|
550 didDrawEffect = Effect()->CachedDraw(aGc, area, refreshCache, !transparent); |
|
551 } |
|
552 |
|
553 if ( !didDrawEffect ) |
|
554 { |
|
555 // huilayout does not draw itself, only children. |
|
556 } |
|
557 else |
|
558 { |
|
559 // Effect was drawn, OpenGLES/OpenVG may be in different state than what Gc thinks so we restore it. |
|
560 aGc.RestoreState(); |
|
561 } |
|
562 |
|
563 if ( !didDrawEffect || (didDrawEffect && !EffectIsAppliedToChildren())) |
|
564 { |
|
565 // The layout itself is invisible. Only its children can be seen. |
|
566 TBool afterOthers = EFalse; |
|
567 const TInt count = Count(); |
|
568 for(TInt i = 0; i < count; ++i) |
|
569 { |
|
570 CHuiVisual* visual = iHuiLayoutPrivateData->iChildren[i]; |
|
571 //Ignore inactive child visuals |
|
572 if ( visual->Flags()& EHuiVisualFlagInactive ) |
|
573 { |
|
574 continue; |
|
575 } |
|
576 if(visual->Flags() & EHuiVisualFlagDrawAfterOthers) |
|
577 { |
|
578 afterOthers = ETrue; |
|
579 continue; |
|
580 } |
|
581 |
|
582 // @todo No need to draw children that won't be visible. |
|
583 visual->Draw(aGc); |
|
584 } |
|
585 if(afterOthers) |
|
586 { |
|
587 for(TInt i = 0; i < count; ++i) |
|
588 { |
|
589 if(iHuiLayoutPrivateData->iChildren[i]->Flags() & EHuiVisualFlagDrawAfterOthers) |
|
590 { |
|
591 iHuiLayoutPrivateData->iChildren[i]->Draw(aGc); |
|
592 } |
|
593 } |
|
594 } |
|
595 } |
|
596 |
|
597 |
|
598 if(Clipping()) |
|
599 { |
|
600 // Restore original clipping rectangle. |
|
601 aGc.PopClip(); |
|
602 } |
|
603 |
|
604 |
|
605 DrawBrushes(aGc, EHuiBrushLayerForeground); |
|
606 |
|
607 // Restore original transformation. |
|
608 Transform(aGc, EFalse); |
|
609 EnterLocalProjection(aGc, EFalse); |
|
610 } |
|
611 |
|
612 |
|
613 EXPORT_C void CHuiLayout::ReportChanged() |
|
614 { |
|
615 // Report changes in the layout itself. |
|
616 CHuiVisual::ReportChanged(); |
|
617 |
|
618 // Notify the display that the visual's area should be redrawn. |
|
619 CHuiDisplay* display = NULL; |
|
620 |
|
621 // Select active display, fallback to own display. |
|
622 // For scaled tv-out cloning the active display takes care of scaling direty areas too. |
|
623 if (iOwner && iOwner->Env().CurrentDisplay()) |
|
624 { |
|
625 display = iOwner->Env().CurrentDisplay(); |
|
626 } |
|
627 else |
|
628 { |
|
629 display = Display(); |
|
630 } |
|
631 |
|
632 if (display && !display->IsDirtyScanNeeded()) |
|
633 { |
|
634 return; |
|
635 } |
|
636 |
|
637 if (display && display->UseTransformedDirtyRegions()) |
|
638 { |
|
639 THuiRealRect displayRect = DisplayRect(); |
|
640 EnterLocalProjection(*display->Gc(), ETrue, 0.f, &displayRect); |
|
641 Transform(*display->Gc(), ETrue, &displayRect); |
|
642 } |
|
643 |
|
644 |
|
645 TInt count = Count(); |
|
646 for(TInt i = 0; i < count; ++i) |
|
647 { |
|
648 if (display && !display->IsDirtyScanNeeded()) |
|
649 { |
|
650 break; |
|
651 } |
|
652 //Ignore inactive child visuals |
|
653 if ( iHuiLayoutPrivateData->iChildren[i]->Flags()& EHuiVisualFlagInactive ) |
|
654 { |
|
655 continue; |
|
656 } |
|
657 iHuiLayoutPrivateData->iChildren[i]->ReportChanged(); |
|
658 } |
|
659 |
|
660 if (display && display->UseTransformedDirtyRegions()) |
|
661 { |
|
662 EnterLocalProjection(*display->Gc(), EFalse); |
|
663 Transform(*display->Gc(), EFalse); |
|
664 } |
|
665 } |
|
666 |
|
667 |
|
668 EXPORT_C TBool CHuiLayout::Changed() const |
|
669 { |
|
670 if(CHuiVisual::Changed()) |
|
671 { |
|
672 return ETrue; |
|
673 } |
|
674 if(iHuiLayoutPrivateData->iScroll) |
|
675 { |
|
676 return iHuiLayoutPrivateData->iScroll->iOffset.Changed(); |
|
677 } |
|
678 return EFalse; |
|
679 } |
|
680 |
|
681 |
|
682 EXPORT_C void CHuiLayout::ClearChanged() |
|
683 { |
|
684 CHuiVisual::ClearChanged(); |
|
685 |
|
686 // Clear the change flags of children as well. |
|
687 TInt count = Count(); |
|
688 for(TInt i = 0; i < count; ++i) |
|
689 { |
|
690 if (Flags() & EHuiVisualFlagInactive) |
|
691 { |
|
692 // No need to clear inactive children |
|
693 continue; |
|
694 } |
|
695 iHuiLayoutPrivateData->iChildren[i]->ClearChanged(); |
|
696 } |
|
697 |
|
698 if(iHuiLayoutPrivateData->iScroll) |
|
699 { |
|
700 iHuiLayoutPrivateData->iScroll->iOffset.ClearChanged(); |
|
701 } |
|
702 } |
|
703 |
|
704 EXPORT_C void CHuiLayout::SetBaseUnit(const THuiMetric& aBaseUnit) |
|
705 { |
|
706 iHuiLayoutPrivateData->iBaseUnit.iX = aBaseUnit; |
|
707 iHuiLayoutPrivateData->iBaseUnit.iY = aBaseUnit; |
|
708 SetChanged(); |
|
709 } |
|
710 |
|
711 EXPORT_C void CHuiLayout::SetBaseUnit(const THuiXYMetric& aBaseUnit) |
|
712 { |
|
713 iHuiLayoutPrivateData->iBaseUnit = aBaseUnit; |
|
714 SetChanged(); |
|
715 } |
|
716 |
|
717 |
|
718 EXPORT_C THuiXYMetric CHuiLayout::BaseUnit() const |
|
719 { |
|
720 THuiXYMetric metric(iHuiLayoutPrivateData->iBaseUnit); |
|
721 if((Flags() & EHuiVisualFlagAutomaticLocaleMirroringEnabled) && CHuiStatic::LayoutMirrored()) |
|
722 { |
|
723 metric.iX.iMagnitude = -metric.iX.iMagnitude; |
|
724 } |
|
725 return metric; |
|
726 } |
|
727 |
|
728 |
|
729 EXPORT_C void CHuiLayout::EnableScrollingL(TBool aScrolling) |
|
730 { |
|
731 if(iHuiLayoutPrivateData->iScroll && !aScrolling) |
|
732 { |
|
733 // Disable scrolling. |
|
734 delete iHuiLayoutPrivateData->iScroll; |
|
735 iHuiLayoutPrivateData->iScroll = NULL; |
|
736 } |
|
737 else if(!iHuiLayoutPrivateData->iScroll && aScrolling) |
|
738 { |
|
739 // Enable scrolling. |
|
740 iHuiLayoutPrivateData->iScroll = new (ELeave) TScrollState(); |
|
741 } |
|
742 else |
|
743 { |
|
744 // for PC lint |
|
745 } |
|
746 } |
|
747 |
|
748 |
|
749 EXPORT_C TBool CHuiLayout::Scrolling() const |
|
750 { |
|
751 return iHuiLayoutPrivateData->iScroll != 0; |
|
752 } |
|
753 |
|
754 |
|
755 EXPORT_C THuiTimedPoint& CHuiLayout::ScrollOffset() |
|
756 { |
|
757 __ASSERT_ALWAYS(iHuiLayoutPrivateData->iScroll, |
|
758 THuiPanic::Panic(THuiPanic::ELayoutNotScrolling)); |
|
759 return iHuiLayoutPrivateData->iScroll->iOffset; |
|
760 } |
|
761 |
|
762 |
|
763 EXPORT_C const THuiTimedPoint& CHuiLayout::ScrollOffset() const |
|
764 { |
|
765 __ASSERT_ALWAYS(iHuiLayoutPrivateData->iScroll, |
|
766 THuiPanic::Panic(THuiPanic::ELayoutNotScrolling)); |
|
767 return iHuiLayoutPrivateData->iScroll->iOffset; |
|
768 } |
|
769 |
|
770 |
|
771 EXPORT_C void CHuiLayout::SetScrollOffsetInBaseUnits(const THuiRealPoint& aOffset, TInt aTransitionTime) |
|
772 { |
|
773 // Pass information directly to the scroll offset |
|
774 ScrollOffset().Set(aOffset, aTransitionTime); |
|
775 } |
|
776 |
|
777 |
|
778 EXPORT_C TSize CHuiLayout::VirtualSize() const |
|
779 { |
|
780 __ASSERT_ALWAYS(iHuiLayoutPrivateData->iScroll, |
|
781 THuiPanic::Panic(THuiPanic::ELayoutNotScrolling)); |
|
782 return iHuiLayoutPrivateData->iScroll->iVirtualSize; |
|
783 } |
|
784 |
|
785 |
|
786 EXPORT_C TInt |
|
787 CHuiLayout::EffectiveLayoutOrdinal(const CHuiVisual& aVisual) const |
|
788 { |
|
789 TInt ordinal = 0; |
|
790 |
|
791 TInt count = Count(); |
|
792 for(TInt i = 0; i < count; ++i) |
|
793 { |
|
794 if(iHuiLayoutPrivateData->iChildren[i] == &aVisual) |
|
795 { |
|
796 return ordinal; |
|
797 } |
|
798 |
|
799 // The visuals that are laid out completely manually do not affect |
|
800 // the layout ordinal. |
|
801 if((iHuiLayoutPrivateData->iChildren[i]->Flags() & EHuiVisualFlagManualLayout) != |
|
802 EHuiVisualFlagManualLayout) |
|
803 { |
|
804 ++ordinal; |
|
805 } |
|
806 } |
|
807 |
|
808 THuiPanic::Panic(THuiPanic::ELayoutChildVisualNotFound); |
|
809 return 0; |
|
810 } |
|
811 |
|
812 |
|
813 EXPORT_C void CHuiLayout::Reorder(CHuiVisual& aVisual, TInt aPosition, TInt aLayoutTransitionTime) |
|
814 { |
|
815 TInt index = FindVisual(&aVisual); |
|
816 if(index != aPosition) |
|
817 { |
|
818 __ASSERT_ALWAYS( aPosition >= 0 && aPosition < Count(), |
|
819 THuiPanic::Panic(THuiPanic::ELayoutInvalidChildPosition) ); |
|
820 __ASSERT_ALWAYS( index != KErrNotFound, |
|
821 THuiPanic::Panic(THuiPanic::ELayoutChildVisualNotFound) ); |
|
822 |
|
823 // Move the children around in the array, so that aVisual ends up |
|
824 // at aPosition. |
|
825 TInt dir = (aPosition > index? +1 : -1); |
|
826 for(TInt i = index; i != aPosition; i += dir) |
|
827 { |
|
828 iHuiLayoutPrivateData->iChildren[i] = iHuiLayoutPrivateData->iChildren[i + dir]; |
|
829 } |
|
830 iHuiLayoutPrivateData->iChildren[aPosition] = &aVisual; |
|
831 SetChanged(); |
|
832 } |
|
833 |
|
834 if(!(Flags() & EHuiVisualFlagFreezeLayout)) |
|
835 { |
|
836 UpdateChildrenLayout(aLayoutTransitionTime); |
|
837 } |
|
838 } |
|
839 |
|
840 |
|
841 EXPORT_C void CHuiLayout::MoveVisualToFront(CHuiVisual& aVisual, TInt aLayoutTransitionTime) |
|
842 { |
|
843 Reorder(aVisual, Count() - 1, aLayoutTransitionTime); |
|
844 } |
|
845 |
|
846 |
|
847 EXPORT_C void CHuiLayout::MoveVisualToBack(CHuiVisual& aVisual, TInt aLayoutTransitionTime) |
|
848 { |
|
849 Reorder(aVisual, 0, aLayoutTransitionTime); |
|
850 } |
|
851 |
|
852 |
|
853 EXPORT_C void CHuiLayout::DumpTree() const |
|
854 { |
|
855 // Dump children. |
|
856 TBuf<100> myName; |
|
857 TBuf<100> childName; |
|
858 |
|
859 CHuiVisual::DumpTree(); |
|
860 |
|
861 GetInstanceName(myName); |
|
862 |
|
863 TInt count = Count(); |
|
864 for(TInt i = 0; i < count; ++i) |
|
865 { |
|
866 iHuiLayoutPrivateData->iChildren[i]->GetInstanceName(childName); |
|
867 CHuiStatic::Printf(_L("%S -> %S;"), &myName, &childName); |
|
868 |
|
869 iHuiLayoutPrivateData->iChildren[i]->DumpTree(); |
|
870 } |
|
871 } |
|
872 |
|
873 |
|
874 EXPORT_C void CHuiLayout::NotifySkinChangedL() |
|
875 { |
|
876 TInt count = Count(); |
|
877 for(TInt i = 0; i < count; ++i) |
|
878 { |
|
879 //Ignore inactive child visuals |
|
880 if ( iHuiLayoutPrivateData->iChildren[i]->Flags()& EHuiVisualFlagInactive ) |
|
881 { |
|
882 continue; |
|
883 } |
|
884 iHuiLayoutPrivateData->iChildren[i]->NotifySkinChangedL(); |
|
885 } |
|
886 } |
|
887 |
|
888 |
|
889 EXPORT_C CHuiVisual* CHuiLayout::FindTag(const TDesC8& aTag) |
|
890 { |
|
891 // Check self first. |
|
892 CHuiVisual* result = CHuiVisual::FindTag(aTag); |
|
893 if(result) |
|
894 { |
|
895 return result; |
|
896 } |
|
897 |
|
898 // Check children. |
|
899 TInt i; |
|
900 TInt count = Count(); |
|
901 for(i = 0; i < count; ++i) |
|
902 { |
|
903 result = iHuiLayoutPrivateData->iChildren[i]->FindTag(aTag); |
|
904 if(result) |
|
905 { |
|
906 return result; |
|
907 } |
|
908 } |
|
909 |
|
910 // Could not find it. |
|
911 return NULL; |
|
912 } |
|
913 |
|
914 |
|
915 EXPORT_C void CHuiLayout::SetTransitionTime(TInt aTransitionTime) |
|
916 { |
|
917 iHuiLayoutPrivateData->iTransitionTime = aTransitionTime; |
|
918 } |
|
919 |
|
920 |
|
921 EXPORT_C TInt CHuiLayout::TransitionTime() const |
|
922 { |
|
923 return iHuiLayoutPrivateData->iTransitionTime; |
|
924 } |
|
925 |
|
926 EXPORT_C THuiRealPoint CHuiLayout::MetricReferenceForLayoutInPixels(const CHuiLayout* /*aLayout*/, const THuiXYMetric& aMetric) const __SOFTFP |
|
927 { |
|
928 return MetricReferenceForLayoutInPixels(aMetric); |
|
929 } |
|
930 |
|
931 /* |
|
932 * can be used by a layout to convert a pixel value into |
|
933 * its own units as if from a child visual's frame of reference |
|
934 * |
|
935 * @todo this needs refactoring with CHuiVisual::MetricReferenceInPixels |
|
936 */ |
|
937 EXPORT_C THuiRealPoint CHuiLayout::MetricReferenceForLayoutInPixels(const THuiXYMetric& aMetric) const __SOFTFP |
|
938 { |
|
939 THuiRealPoint refSizePx(0.f, 0.f); |
|
940 |
|
941 // if weights are used in this context, treat them as normalized units |
|
942 TInt xUnit = (aMetric.iX.iUnit == EHuiUnitWeight) ? EHuiUnitNormalized : aMetric.iX.iUnit; |
|
943 TInt yUnit = (aMetric.iY.iUnit == EHuiUnitWeight) ? EHuiUnitNormalized : aMetric.iY.iUnit; |
|
944 |
|
945 // For normalized units, the reference is the parent size in pixels. |
|
946 if(xUnit == EHuiUnitNormalized || yUnit == EHuiUnitNormalized || |
|
947 xUnit == EHuiUnitParentWidth || yUnit == EHuiUnitParentWidth || |
|
948 xUnit == EHuiUnitParentHeight || yUnit == EHuiUnitParentHeight) |
|
949 { |
|
950 THuiRealPoint sizePx(0.f, 0.f); |
|
951 |
|
952 // Determine the size of this layout in pixels. |
|
953 if(Layout()) |
|
954 { |
|
955 // Recursive fun. We don't want to do this more than once. |
|
956 // (LocalPointInPixels => MetricsToPixels => MetricReferenceInPixels => LocalPointInPixels) |
|
957 sizePx = LocalPointInPixels(Size().RealTarget(), EHuiReferenceStateTarget); |
|
958 } |
|
959 else if(Display()) |
|
960 { |
|
961 // @todo Jaakko please code review this change! |
|
962 // sizePx = Display()->Size().AsPoint(); |
|
963 sizePx = Display()->VisibleArea().Size().AsPoint(); |
|
964 } |
|
965 else |
|
966 { |
|
967 // For PC-lint |
|
968 } |
|
969 |
|
970 if(xUnit == EHuiUnitNormalized || xUnit == EHuiUnitParentWidth) |
|
971 { |
|
972 refSizePx.iX = sizePx.iX; |
|
973 } |
|
974 else if(xUnit == EHuiUnitParentHeight) |
|
975 { |
|
976 refSizePx.iX = sizePx.iY; |
|
977 } |
|
978 else |
|
979 { |
|
980 // For PC-lint |
|
981 } |
|
982 |
|
983 if(yUnit == EHuiUnitNormalized || yUnit == EHuiUnitParentHeight) |
|
984 { |
|
985 refSizePx.iY = sizePx.iY; |
|
986 } |
|
987 else if(yUnit == EHuiUnitParentWidth) |
|
988 { |
|
989 refSizePx.iY = sizePx.iX; |
|
990 } |
|
991 else |
|
992 { |
|
993 // For PC-lint |
|
994 } |
|
995 } |
|
996 |
|
997 // Display-relative units are always relative to the display where the visual is on. |
|
998 if(xUnit == EHuiUnitRelativeToDisplay && Display()) |
|
999 { |
|
1000 refSizePx.iX = Display()->VisibleArea().Width(); |
|
1001 } |
|
1002 if(yUnit == EHuiUnitRelativeToDisplay && Display()) |
|
1003 { |
|
1004 refSizePx.iY = Display()->VisibleArea().Height(); |
|
1005 } |
|
1006 |
|
1007 // For relative to my size units, the reference is the size of this visual in pixels. |
|
1008 if(xUnit == EHuiUnitRelativeToMySize || yUnit == EHuiUnitRelativeToMySize || |
|
1009 xUnit == EHuiUnitMyWidth || yUnit == EHuiUnitMyWidth || |
|
1010 xUnit == EHuiUnitMyHeight || yUnit == EHuiUnitMyHeight || |
|
1011 xUnit == EHuiUnitMyDimensionAverage || yUnit == EHuiUnitMyDimensionAverage) |
|
1012 { |
|
1013 THuiRealPoint sizePx(0.f, 0.f); |
|
1014 if(Layout()) |
|
1015 { |
|
1016 // Recursive fun. We don't want to do this more than once. |
|
1017 // (MetricsToPixels => MetricReferenceInPixels) |
|
1018 sizePx = MetricToPixels(LocalBaseUnit().Abs() * Size().RealTarget(), EHuiReferenceStateTarget); |
|
1019 } |
|
1020 else if(Display()) |
|
1021 { |
|
1022 sizePx = Display()->VisibleArea().Size().AsPoint(); |
|
1023 } |
|
1024 else |
|
1025 { |
|
1026 // For PC-lint |
|
1027 } |
|
1028 |
|
1029 if(xUnit == EHuiUnitRelativeToMySize || xUnit == EHuiUnitMyWidth) |
|
1030 { |
|
1031 refSizePx.iX = sizePx.iX; |
|
1032 } |
|
1033 else if(xUnit == EHuiUnitMyHeight) |
|
1034 { |
|
1035 refSizePx.iX = sizePx.iY; |
|
1036 } |
|
1037 else |
|
1038 { |
|
1039 // For PC-lint |
|
1040 } |
|
1041 |
|
1042 if(yUnit == EHuiUnitRelativeToMySize || yUnit == EHuiUnitMyHeight) |
|
1043 { |
|
1044 refSizePx.iY = sizePx.iY; |
|
1045 } |
|
1046 else if(yUnit == EHuiUnitMyWidth) |
|
1047 { |
|
1048 refSizePx.iY = sizePx.iX; |
|
1049 } |
|
1050 else |
|
1051 { |
|
1052 // For PC-lint |
|
1053 } |
|
1054 |
|
1055 if( xUnit == EHuiUnitMyDimensionAverage || |
|
1056 yUnit == EHuiUnitMyDimensionAverage ) |
|
1057 { |
|
1058 TReal32 average = (sizePx.iX + sizePx.iY) / 2; |
|
1059 if(xUnit == EHuiUnitMyDimensionAverage) |
|
1060 { |
|
1061 refSizePx.iX = average; |
|
1062 } |
|
1063 if(yUnit == EHuiUnitMyDimensionAverage) |
|
1064 { |
|
1065 refSizePx.iY = average; |
|
1066 } |
|
1067 } |
|
1068 } |
|
1069 |
|
1070 // S60 platform units are specific to the display where the visual is on. |
|
1071 if(xUnit == EHuiUnitS60 && Display()) |
|
1072 { |
|
1073 refSizePx.iX = Display()->UnitValue(); |
|
1074 } |
|
1075 if(yUnit == EHuiUnitS60 && Display()) |
|
1076 { |
|
1077 refSizePx.iY = Display()->UnitValue(); |
|
1078 } |
|
1079 |
|
1080 return refSizePx; |
|
1081 } |
|
1082 |
|
1083 EXPORT_C void CHuiLayout::ExpandRectWithContent(TRect& aRect) const |
|
1084 { |
|
1085 // Expand with scroll offset |
|
1086 if ( iHuiLayoutPrivateData->iScroll ) |
|
1087 { |
|
1088 const TPoint scrollOffset = LocalPointInPixels(iHuiLayoutPrivateData->iScroll->iOffset.RealNow(), EHuiReferenceStateNow ); |
|
1089 if ( scrollOffset.iX > 0 ) |
|
1090 { |
|
1091 aRect.iTl.iX -= scrollOffset.iX; |
|
1092 } |
|
1093 if ( scrollOffset.iX < 0 ) |
|
1094 { |
|
1095 aRect.iBr.iX -= scrollOffset.iX; |
|
1096 } |
|
1097 if ( scrollOffset.iY > 0 ) |
|
1098 { |
|
1099 aRect.iTl.iY -= scrollOffset.iY; |
|
1100 } |
|
1101 if ( scrollOffset.iY < 0 ) |
|
1102 { |
|
1103 aRect.iBr.iY -= scrollOffset.iY; |
|
1104 } |
|
1105 } |
|
1106 |
|
1107 CHuiVisual::ExpandRectWithContent( aRect ); |
|
1108 } |
|
1109 |
|
1110 EXPORT_C void CHuiLayout::VisualExtension(const TUid& aExtensionUid, TAny** aExtensionParams) |
|
1111 { |
|
1112 CHuiVisual::VisualExtension(aExtensionUid, aExtensionParams); |
|
1113 } |
|
1114 |
|
1115 EXPORT_C void CHuiLayout::SetPos(const THuiRealPoint& aPos, TInt aTransitionTime) |
|
1116 { |
|
1117 CHuiVisual::SetPos(aPos,aTransitionTime); |
|
1118 } |
|
1119 |
|
1120 void CHuiLayout::DrawStoredBitmap(CHuiGc &aGc) const |
|
1121 { |
|
1122 if (!Display()) return; |
|
1123 CHuiCanvasGc& gc = *iHuiLayoutPrivateData->iGc; |
|
1124 gc.SetGc(aGc); |
|
1125 gc.SetDefaults(); |
|
1126 gc.PushTransformationMatrix(); |
|
1127 |
|
1128 //TInt w = displayArea.Width(); |
|
1129 TRect displayArea = Display()->VisibleArea(); |
|
1130 TInt h = displayArea.Height(); |
|
1131 |
|
1132 // Pixels are upside down in OpenVG canvas render buffer |
|
1133 if (CHuiStatic::Env().Renderer() == EHuiRendererVg10) |
|
1134 { |
|
1135 TInt height = h; |
|
1136 //if (relativeOrientation == CHuiGc::EOrientationCW90 || relativeOrientation == CHuiGc::EOrientationCCW90) |
|
1137 // { |
|
1138 // height = w; |
|
1139 // } |
|
1140 gc.Translate(0.0f, height, 0.0f); |
|
1141 gc.Scale(1.f, -1.f, 1.f); |
|
1142 } |
|
1143 |
|
1144 THuiRealPoint dest_point = DisplayRect().iTl; |
|
1145 CHuiCanvasRenderBuffer *stored = StoredRenderBuffer(); |
|
1146 gc.DrawImage(*stored, dest_point); |
|
1147 |
|
1148 gc.PopTransformationMatrix(); |
|
1149 |
|
1150 } |
|
1151 |
|
1152 EXPORT_C void CHuiLayout::DrawSelf(CHuiGc& aGc, const TRect& aDisplayRect) const |
|
1153 { |
|
1154 if (( IsDelayedEffectSource()||Freezed() ) && StoredRenderBuffer()) |
|
1155 { |
|
1156 DrawStoredBitmap(aGc); |
|
1157 return; |
|
1158 } |
|
1159 |
|
1160 if( Effect() && EffectIsAppliedToChildren() ) |
|
1161 { |
|
1162 // The layout itself is invisible. Only its children can be seen. |
|
1163 TBool afterOthers = EFalse; |
|
1164 const TInt count = Count(); |
|
1165 for(TInt i = 0; i < count; ++i) |
|
1166 { |
|
1167 CHuiVisual* visual = iHuiLayoutPrivateData->iChildren[i]; |
|
1168 //Ignore inactive child visuals |
|
1169 if ( visual->Flags()& EHuiVisualFlagInactive ) |
|
1170 { |
|
1171 continue; |
|
1172 } |
|
1173 if(visual->Flags() & EHuiVisualFlagDrawAfterOthers) |
|
1174 { |
|
1175 afterOthers = ETrue; |
|
1176 continue; |
|
1177 } |
|
1178 |
|
1179 // @todo No need to draw children that won't be visible. |
|
1180 visual->Draw(aGc); |
|
1181 } |
|
1182 if(afterOthers) |
|
1183 { |
|
1184 for(TInt i = 0; i < count; ++i) |
|
1185 { |
|
1186 if(iHuiLayoutPrivateData->iChildren[i]->Flags() & EHuiVisualFlagDrawAfterOthers) |
|
1187 { |
|
1188 iHuiLayoutPrivateData->iChildren[i]->Draw(aGc); |
|
1189 } |
|
1190 } |
|
1191 } |
|
1192 } |
|
1193 else |
|
1194 { |
|
1195 CHuiVisual::DrawSelf(aGc, aDisplayRect); |
|
1196 } |
|
1197 } |
|
1198 |
|
1199 EXPORT_C TReal32 CHuiLayout::BrushOpacity() const __SOFTFP |
|
1200 { |
|
1201 return CHuiVisual::BrushOpacity(); |
|
1202 } |
|
1203 |
|
1204 EXPORT_C THuiRealRect CHuiLayout::BrushRect() const __SOFTFP |
|
1205 { |
|
1206 return CHuiVisual::BrushRect(); |
|
1207 } |
|
1208 |
|
1209 |
|
1210 EXPORT_C CHuiSkin& CHuiLayout::BrushSkin() const |
|
1211 { |
|
1212 return CHuiVisual::BrushSkin(); |
|
1213 } |
|
1214 |
|
1215 HUI_SESSION_OBJECT_IMPL_EXPORT(CHuiLayout, ETypeVisual) |
|
1216 |
|
1217 EXPORT_C void CHuiLayout::GetInstanceName(TDes& aName) const |
|
1218 { |
|
1219 CHuiVisual::GetInstanceName(aName); |
|
1220 } |
|
1221 |
|
1222 |
|
1223 EXPORT_C void CHuiLayout::GetClassName(TDes& aName) const |
|
1224 { |
|
1225 aName = _L("CHuiLayout"); |
|
1226 } |
|
1227 |
|
1228 TBool CHuiLayout::HasActiveChilderen() const |
|
1229 { |
|
1230 TBool hasActiveChildren = EFalse; |
|
1231 const TInt count = Count(); |
|
1232 for(TInt i = 0; i < count; ++i) |
|
1233 { |
|
1234 CHuiVisual* visual = iHuiLayoutPrivateData->iChildren[i]; |
|
1235 if (!(visual->Flags()& EHuiVisualFlagInactive )) |
|
1236 { |
|
1237 hasActiveChildren = ETrue; |
|
1238 break; |
|
1239 } |
|
1240 } |
|
1241 return hasActiveChildren; |
|
1242 } |
|
1243 |
|
1244 TBool CHuiLayout::EffectIsAppliedToChildren() const |
|
1245 { |
|
1246 if (Effect() && !LoadingEffect() && !(Effect()->EffectFlags() & KHuiFxEffectExcludeChildrenFlag)) |
|
1247 { |
|
1248 return ETrue; |
|
1249 } |
|
1250 else |
|
1251 { |
|
1252 return EFalse; |
|
1253 } |
|
1254 } |