17 |
17 |
18 // Alf Headers |
18 // Alf Headers |
19 #include <alf/alflayout.h> |
19 #include <alf/alflayout.h> |
20 #include <alf/alfgridlayout.h> // For CAlfGridLayout |
20 #include <alf/alfgridlayout.h> // For CAlfGridLayout |
21 #include <alf/alfborderbrush.h> // For CAlfBorderBrush |
21 #include <alf/alfborderbrush.h> // For CAlfBorderBrush |
|
22 #include <alf/alfroster.h> // For CalfRoster |
22 #include <alf/alfanchorlayout.h> |
23 #include <alf/alfanchorlayout.h> |
23 #include <alf/alftextvisual.h> |
24 #include <alf/alftextvisual.h> |
24 #include <alf/alfimagevisual.h> |
25 #include <alf/alfimagevisual.h> |
25 #include <alf/alfbrusharray.h> |
26 #include <alf/alfbrusharray.h> |
26 #include <alf/alftextstyle.h> |
27 #include <alf/alftextstyle.h> |
63 const TReal KOpacityTransparent = 0.0; |
64 const TReal KOpacityTransparent = 0.0; |
64 const TPoint KDummyPoint(500, 500); |
65 const TPoint KDummyPoint(500, 500); |
65 //6 Seconds delay for menu control visibility on screen |
66 //6 Seconds delay for menu control visibility on screen |
66 const TInt KTimerDelay = 6000000; |
67 const TInt KTimerDelay = 6000000; |
67 //Control complete height |
68 //Control complete height |
68 const TInt KGridHeight = KReqHeightPerMenuItem * KNumofMenuItems; |
69 const TInt KGridHeight = ((KReqHeightPerMenuItem * KNumofMenuItems) + (KMinimalGap * (KNumofMenuItems + 1))); |
69 //Text size for menu items |
70 //Text size for menu items |
70 const TInt KTextSizeInPixels = 20; |
71 const TInt KTextSizeInPixels = 20; |
71 //X shrink factor for stylus menu border to be drawn/visible |
72 //X shrink factor for stylus menu border to be drawn/visible |
72 const TInt KShrinkXCoord = 5; |
73 const TInt KShrinkXCoord = 5; |
73 //Y shrink factor for stylus menu border to be drawn/visible |
74 //Y shrink factor for stylus menu border to be drawn/visible |
74 const TInt KShrinkYCoord = 5; |
75 const TInt KShrinkYCoord = 5; |
75 //Padding value for Minimum width for control |
76 //Padding value for Minimum width for control |
76 const TInt KWidthPadding = 20; |
77 const TInt KWidthPadding = 30; |
77 //Padding value for Minimum spacing for line separators |
78 //Padding value for Minimum spacing for line separators |
78 const TInt KLinePadding = 5; |
79 const TInt KLinePadding = 5; |
79 //Context menu separator line thickness value |
80 //Context menu separator line thickness value |
80 const TReal KSeparatorLineThickness = 0.2; |
81 const TReal KSeparatorLineThickness = 0.2; |
81 //For Tagging the visuals |
82 //For Tagging the visuals |
114 // CGlxTagsContextMenuControl() |
115 // CGlxTagsContextMenuControl() |
115 // --------------------------------------------------------------------------- |
116 // --------------------------------------------------------------------------- |
116 // |
117 // |
117 CGlxTagsContextMenuControl::CGlxTagsContextMenuControl( |
118 CGlxTagsContextMenuControl::CGlxTagsContextMenuControl( |
118 MGlxItemMenuObserver& aItemMenuObserver) : |
119 MGlxItemMenuObserver& aItemMenuObserver) : |
119 iItemMenuObserver(aItemMenuObserver) |
120 iItemMenuObserver(aItemMenuObserver), iCommandId(KErrNotFound) |
120 { |
121 { |
121 TRACER("GLX_CLOUD::CGlxTagsContextMenuControl::CGlxTagsContextMenuControl"); |
122 TRACER("GLX_CLOUD::CGlxTagsContextMenuControl::CGlxTagsContextMenuControl"); |
122 //Nothing more to do for now |
123 //Nothing more to do for now |
123 } |
124 } |
124 // --------------------------------------------------------------------------- |
125 // --------------------------------------------------------------------------- |
140 iMainVisual->SetFlag(EAlfVisualFlagManualLayout); |
141 iMainVisual->SetFlag(EAlfVisualFlagManualLayout); |
141 iMainVisual->SetPos(TAlfRealPoint(KDummyPoint)); |
142 iMainVisual->SetPos(TAlfRealPoint(KDummyPoint)); |
142 // Create a new 3x1 grid layout visual. |
143 // Create a new 3x1 grid layout visual. |
143 iGrid = CAlfGridLayout::AddNewL(*this, KNoOfColumns, KNumofMenuItems, |
144 iGrid = CAlfGridLayout::AddNewL(*this, KNoOfColumns, KNumofMenuItems, |
144 iMainVisual);//columns, rows |
145 iMainVisual);//columns, rows |
145 |
146 iGrid->SetFlag(EAlfVisualFlagManualLayout); |
146 //Finally create the menu list that will appear in screen |
147 //Finally create the menu list that will appear in screen |
147 CreateMenuListL(CreateFontL()); |
148 CreateMenuListL(CreateFontL()); |
148 CalculateMaxWidth(); |
149 CalculateMaxWidth(); |
149 iMainVisual->SetSize(TSize(KWidthPadding + iMaxTextWidth, KGridHeight)); |
150 iMainVisual->SetSize(TSize(KWidthPadding + iMaxTextWidth, KGridHeight)); |
|
151 iGrid->SetInnerPadding(TPoint(KLinePadding,KLinePadding)); |
|
152 const TRect gridSize(TPoint(KLinePadding,KLinePadding),TSize(KTextSizeInPixels + iMaxTextWidth, KGridHeight - 10)); |
|
153 iGrid->SetRect(TAlfRealRect(gridSize)); |
150 |
154 |
151 iMainVisual->EnableBrushesL(ETrue); |
155 iMainVisual->EnableBrushesL(ETrue); |
152 |
156 |
153 TRect outerRect(TRect(TPoint(KDummyPoint), |
157 TRect outerRect(TRect(TPoint(KDummyPoint), |
154 TSize(KWidthPadding + iMaxTextWidth, KGridHeight))); |
158 TSize(KWidthPadding + iMaxTextWidth, KGridHeight))); |
294 iTimer->SetDelay(KTimerDelay); |
298 iTimer->SetDelay(KTimerDelay); |
295 } |
299 } |
296 } |
300 } |
297 |
301 |
298 // --------------------------------------------------------------------------- |
302 // --------------------------------------------------------------------------- |
299 // ShowItemMenu() |
303 // ShowItemMenuL() |
300 // --------------------------------------------------------------------------- |
304 // --------------------------------------------------------------------------- |
301 // |
305 // |
302 void CGlxTagsContextMenuControl::ShowItemMenu (TBool aShow) |
306 void CGlxTagsContextMenuControl::ShowItemMenuL(TBool aShow) |
303 { |
307 { |
304 TRACER("GLX_CLOUD::CGlxTagsContextMenuControl::ShowItemMenu"); |
308 TRACER("GLX_CLOUD::CGlxTagsContextMenuControl::ShowItemMenuL"); |
305 if(aShow) |
309 if(aShow) |
306 { |
310 { |
307 iMainVisual->SetOpacity(KOpacityOpaque); |
311 iMainVisual->SetOpacity(KOpacityOpaque); |
308 iItemMenuVisibility = ETrue; |
312 iItemMenuVisibility = ETrue; |
309 } |
313 } |
310 else |
314 else |
311 { |
315 { |
312 iMainVisual->SetOpacity(KOpacityTransparent); |
316 iMainVisual->SetOpacity(KOpacityTransparent); |
|
317 iRenameTextVisual->EnableBrushesL(EFalse); |
|
318 iDeleteTextVisual->EnableBrushesL(EFalse); |
|
319 iSlideshowTextVisual->EnableBrushesL(EFalse); |
313 iItemMenuVisibility = EFalse; |
320 iItemMenuVisibility = EFalse; |
314 iMainVisual->SetPos(TAlfRealPoint(KDummyPoint)); |
321 iMainVisual->SetPos(TAlfRealPoint(KDummyPoint)); |
315 } |
322 } |
316 } |
323 } |
317 |
324 |
331 TBool CGlxTagsContextMenuControl::OfferEventL(const TAlfEvent& aEvent) |
338 TBool CGlxTagsContextMenuControl::OfferEventL(const TAlfEvent& aEvent) |
332 { |
339 { |
333 TRACER("GLX_CLOUD::CGlxTagsContextMenuControl::OfferEventL"); |
340 TRACER("GLX_CLOUD::CGlxTagsContextMenuControl::OfferEventL"); |
334 TBool consumed = EFalse; |
341 TBool consumed = EFalse; |
335 |
342 |
336 if(iItemMenuVisibility && aEvent.IsPointerEvent() && aEvent.PointerDown() ) |
343 if (aEvent.IsPointerEvent() && iItemMenuVisibility ) |
337 { |
344 { |
338 CAlfVisual* onVisual = aEvent.Visual(); |
345 if (aEvent.PointerDown()) |
339 TInt cmdId = KErrNotFound; |
|
340 if(AlfUtil::TagMatches(onVisual->Tag(), KTagSlideshow)) |
|
341 { |
346 { |
342 cmdId = EGlxCmdSlideshowPlay; |
347 iCommandId = KErrNotFound; |
343 } |
348 Display()->Roster().SetPointerEventObservers( |
344 else if(AlfUtil::TagMatches(onVisual->Tag(), KTagDelete)) |
349 EAlfPointerEventReportDrag |
|
350 + EAlfPointerEventReportLongTap |
|
351 + EAlfPointerEventReportUnhandled, *this); |
|
352 if (iItemMenuVisibility) |
|
353 { |
|
354 CAlfVisual* onVisual = aEvent.Visual(); |
|
355 CAlfFrameBrush* brush = CAlfFrameBrush::NewLC(*iAlfEnv, |
|
356 KAknsIIDQsnFrList); |
|
357 TRect textVisualRect = TRect(TPoint( |
|
358 iSlideshowTextVisual->Pos().IntValueNow()), TSize( |
|
359 iSlideshowTextVisual->Size().ValueNow().AsSize())); |
|
360 TRect innerRect(textVisualRect); |
|
361 innerRect.Shrink(KShrinkXCoord, KShrinkYCoord); |
|
362 brush->SetFrameRectsL(innerRect, textVisualRect); |
|
363 iTimer->Cancel(); //cancels any outstanding requests |
|
364 if (AlfUtil::TagMatches(onVisual->Tag(), KTagSlideshow)) |
|
365 { |
|
366 iSlideshowTextVisual->EnableBrushesL(ETrue); |
|
367 iSlideshowTextVisual->Brushes()->AppendL(brush, |
|
368 EAlfHasOwnership); |
|
369 |
|
370 iCommandId = EGlxCmdSlideshowPlay; |
|
371 } |
|
372 else if (AlfUtil::TagMatches(onVisual->Tag(), KTagDelete)) |
|
373 { |
|
374 iDeleteTextVisual->EnableBrushesL(ETrue); |
|
375 iDeleteTextVisual->Brushes()->AppendL(brush, |
|
376 EAlfHasOwnership); |
|
377 |
|
378 iCommandId = EGlxCmdDelete; |
|
379 } |
|
380 else if (AlfUtil::TagMatches(onVisual->Tag(), KTagRename)) |
|
381 { |
|
382 iRenameTextVisual->EnableBrushesL(ETrue); |
|
383 iRenameTextVisual->Brushes()->AppendL(brush, |
|
384 EAlfHasOwnership); |
|
385 |
|
386 iCommandId = EGlxCmdRename; |
|
387 } |
|
388 consumed = ETrue; |
|
389 CleanupStack::Pop(brush); |
|
390 }//End of iItemMenuVisibility check |
|
391 }//End of Pointer down event |
|
392 else if (aEvent.PointerUp()) |
345 { |
393 { |
346 cmdId = EGlxCmdDelete; |
394 if (iCommandId >= 0) |
347 } |
395 { |
348 else if(AlfUtil::TagMatches(onVisual->Tag(), KTagRename)) |
396 TBool eventInsideControl = HitTest( |
349 { |
397 aEvent.PointerEvent().iParentPosition); |
350 cmdId = EGlxCmdRename; |
398 //If Up event is received only within Menu control, handle the command |
351 } |
399 if (eventInsideControl) |
352 |
400 { |
353 if(cmdId >= 0) |
401 ShowItemMenuL(EFalse); |
354 { |
402 |
355 ShowItemMenu(EFalse); |
403 iItemMenuObserver.HandleGridMenuListL(iCommandId); |
356 iItemMenuObserver.HandleGridMenuListL(cmdId); |
404 iCommandId = KErrNotFound; |
|
405 } |
|
406 else |
|
407 { |
|
408 HandleUpEventL(); |
|
409 } |
|
410 } |
357 consumed = ETrue; |
411 consumed = ETrue; |
358 } |
412 } |
359 } |
413 else if (aEvent.PointerEvent().EDrag) |
360 |
414 { |
|
415 TBool eventInsideControl = HitTest( |
|
416 aEvent.PointerEvent().iParentPosition); |
|
417 if (!eventInsideControl) |
|
418 { |
|
419 HandleUpEventL(); |
|
420 } |
|
421 consumed = ETrue; |
|
422 } |
|
423 consumed = ETrue; |
|
424 } |
361 return consumed; |
425 return consumed; |
362 } |
426 } |
363 |
427 |
364 // --------------------------------------------------------------------------- |
428 // --------------------------------------------------------------------------- |
365 // TimerComplete() |
429 // TimerCompleteL() |
366 // --------------------------------------------------------------------------- |
430 // --------------------------------------------------------------------------- |
367 // |
431 // |
368 void CGlxTagsContextMenuControl::TimerComplete() |
432 void CGlxTagsContextMenuControl::TimerCompleteL() |
369 { |
433 { |
370 TRACER("GLX_CLOUD::CGlxTagsContextMenuControl::TimerComplete"); |
434 TRACER("GLX_CLOUD::CGlxTagsContextMenuControl::TimerCompleteL"); |
371 ShowItemMenu(EFalse); |
435 ShowItemMenuL(EFalse); |
372 } |
436 } |
373 |
437 |
374 // --------------------------------------------------------------------------- |
438 // --------------------------------------------------------------------------- |
375 // SetViewableRect() |
439 // SetViewableRect() |
376 // --------------------------------------------------------------------------- |
440 // --------------------------------------------------------------------------- |
400 ? iMaxTextWidth |
464 ? iMaxTextWidth |
401 : iDeleteTextVisual->TextExtents().iWidth); |
465 : iDeleteTextVisual->TextExtents().iWidth); |
402 |
466 |
403 } |
467 } |
404 // --------------------------------------------------------------------------- |
468 // --------------------------------------------------------------------------- |
|
469 // HandleUpEventL() |
|
470 // --------------------------------------------------------------------------- |
|
471 // |
|
472 void CGlxTagsContextMenuControl::HandleUpEventL() |
|
473 { |
|
474 TRACER("GLX_CLOUD::CGlxTagsContextMenuControl::HandleUpEventL"); |
|
475 if(iCommandId >=0 && iItemMenuVisibility) |
|
476 { |
|
477 iCommandId = KErrNotFound; |
|
478 |
|
479 iRenameTextVisual->EnableBrushesL(EFalse); |
|
480 iDeleteTextVisual->EnableBrushesL(EFalse); |
|
481 iSlideshowTextVisual->EnableBrushesL(EFalse); |
|
482 |
|
483 iTimer->SetDelay(KTimerDelay); |
|
484 } |
|
485 } |
405 // --------------------------------------------------------------------------- |
486 // --------------------------------------------------------------------------- |
406 // DrawLineSeparatorsL() |
487 // DrawLineSeparatorsL() |
407 // --------------------------------------------------------------------------- |
488 // --------------------------------------------------------------------------- |
408 // |
489 // |
409 void CGlxTagsContextMenuControl::DrawLineSeparatorsL() |
490 void CGlxTagsContextMenuControl::DrawLineSeparatorsL() |
415 KAknsIIDQsnLineColors, EAknsCIQsnLineColorsCG11); |
496 KAknsIIDQsnLineColors, EAknsCIQsnLineColorsCG11); |
416 |
497 |
417 for (TInt i = 1; i < KNumofMenuItems; i++) |
498 for (TInt i = 1; i < KNumofMenuItems; i++) |
418 { |
499 { |
419 CAlfCurvePath* curvePath = CAlfCurvePath::NewLC(*iAlfEnv); |
500 CAlfCurvePath* curvePath = CAlfCurvePath::NewLC(*iAlfEnv); |
420 curvePath->AppendArcL( |
501 curvePath->AppendArcL(TPoint(KLinePadding, ((KReqHeightPerMenuItem |
421 TPoint(KLinePadding, KReqHeightPerMenuItem * i), TSize(), 0, |
502 * i) + (KLinePadding * i + 2))), TSize(), 0, 0, 0); |
422 0, 0); |
503 curvePath->AppendLineL(TPoint(KLinePadding, ((KReqHeightPerMenuItem |
423 curvePath->AppendLineL( |
504 * i) + (KLinePadding * i + 2))), TPoint( |
424 TPoint(KLinePadding, KReqHeightPerMenuItem * i), TPoint( |
505 iMainVisual->DisplayRect().Width() - KLinePadding, |
425 iMainVisual->DisplayRect().Width() - KLinePadding, |
506 ((KReqHeightPerMenuItem * i) + (KLinePadding * i + 2))), 0); |
426 KReqHeightPerMenuItem * i), 0); |
|
427 |
507 |
428 CAlfLineVisual* line = CAlfLineVisual::AddNewL(*this, iMainVisual); |
508 CAlfLineVisual* line = CAlfLineVisual::AddNewL(*this, iMainVisual); |
429 line->SetPath(curvePath, EAlfHasOwnership); |
509 line->SetPath(curvePath, EAlfHasOwnership); |
430 line->SetThickness(KSeparatorLineThickness); |
510 line->SetThickness(KSeparatorLineThickness); |
431 line->SetColor(color); |
511 line->SetColor(color); |