|
1 /* |
|
2 * Copyright (c) 2008-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: Cloud View Context menu control class |
|
15 * |
|
16 */ |
|
17 |
|
18 // Alf Headers |
|
19 #include <alf/alflayout.h> |
|
20 #include <alf/alfgridlayout.h> // For CAlfGridLayout |
|
21 #include <alf/alfborderbrush.h> // For CAlfBorderBrush |
|
22 #include <alf/alfanchorlayout.h> |
|
23 #include <alf/alftextvisual.h> |
|
24 #include <alf/alfimagevisual.h> |
|
25 #include <alf/alfbrusharray.h> |
|
26 #include <alf/alftextstyle.h> |
|
27 #include <alf/alfenv.h> |
|
28 #include <alf/alfeventhandler.h> |
|
29 #include <alf/alfutil.h> |
|
30 #include <alf/alftexture.h> |
|
31 #include <alf/alfevent.h> |
|
32 #include <alf/ialfwidgetfactory.h> |
|
33 #include <alf/ialfviewwidget.h> |
|
34 #include <alf/alfdisplay.h> |
|
35 |
|
36 #include <aknnotewrappers.h> |
|
37 #include <FBS.H> |
|
38 #include <StringLoader.h> |
|
39 #include "utf.h" // UtfConverter |
|
40 |
|
41 // Photos Headers |
|
42 #include "glxtagscontextmenucontrol.h" |
|
43 #include "glxcommandfactory.h" |
|
44 #include <mglxmedialist.h> //for medialist |
|
45 #include <glxuiutility.h> |
|
46 #include <glxtexturemanager.h> // Texturemanager |
|
47 #include <glxicons.mbg> // icons |
|
48 #include <glxuistd.h> // Attribute fetch priority |
|
49 #include <glxcommandhandlers.hrh> |
|
50 #include "glxbubbletimer.h" //for timer functionality |
|
51 #include <glxtagsbrowserview.rsg> // For resources |
|
52 #include <glxtracer.h> // For Logs |
|
53 |
|
54 //Left & Top padding of text within text box (In Pixels) |
|
55 const TInt KMinimalGap = 5; |
|
56 //Height of each menu item |
|
57 const TInt KReqHeightPerMenuItem = 47; |
|
58 //Minimum width for control |
|
59 const TInt KReqWidth = 113; |
|
60 //Number of menu items present in stylus menu |
|
61 const TInt KNumofMenuItems = 3; |
|
62 //Number of columns present in grid control showing menu |
|
63 const TInt KNoOfColumns = 1; |
|
64 //Highest possible value to make control opaque |
|
65 const TReal KOpacityOpaque = 1.0; |
|
66 //lowest possible value to make control completely transparent |
|
67 const TReal KOpacityTransparent = 0.0; |
|
68 const TPoint KDummyPoint(100,100); |
|
69 //6 Seconds delay for menu control visibility on screen |
|
70 const TInt KTimerDelay = 6000000; |
|
71 //Control complete height |
|
72 const TInt KGridHeight = KReqHeightPerMenuItem * KNumofMenuItems; |
|
73 //Text size for menu items |
|
74 const TInt KTextSizeInPixels = 20; |
|
75 |
|
76 //For Tagging the visuals |
|
77 _LIT8(KTagSlideshow, "SS"); |
|
78 _LIT8(KTagRename, "Ren"); |
|
79 _LIT8(KTagDelete, "Del"); |
|
80 |
|
81 // --------------------------------------------------------------------------- |
|
82 // NewL() |
|
83 // --------------------------------------------------------------------------- |
|
84 // |
|
85 CGlxTagsContextMenuControl* CGlxTagsContextMenuControl::NewL( |
|
86 MGlxItemMenuObserver& aItemMenuObserver) |
|
87 { |
|
88 TRACER("GLX_CLOUD::CGlxTagsContextMenuControl::NewL"); |
|
89 CGlxTagsContextMenuControl* self = CGlxTagsContextMenuControl::NewLC( aItemMenuObserver); |
|
90 CleanupStack::Pop(self); |
|
91 return self; |
|
92 } |
|
93 // --------------------------------------------------------------------------- |
|
94 // NewLC() |
|
95 // --------------------------------------------------------------------------- |
|
96 // |
|
97 CGlxTagsContextMenuControl* CGlxTagsContextMenuControl::NewLC( |
|
98 MGlxItemMenuObserver& aItemMenuObserver ) |
|
99 { |
|
100 TRACER("GLX_CLOUD::CGlxTagsContextMenuControl::NewLC"); |
|
101 CGlxTagsContextMenuControl* self = new (ELeave) CGlxTagsContextMenuControl( aItemMenuObserver); |
|
102 CleanupStack::PushL( self ); |
|
103 self->ConstructL(); |
|
104 return self; |
|
105 } |
|
106 // --------------------------------------------------------------------------- |
|
107 // CGlxTagsContextMenuControl() |
|
108 // --------------------------------------------------------------------------- |
|
109 // |
|
110 CGlxTagsContextMenuControl::CGlxTagsContextMenuControl(MGlxItemMenuObserver& aItemMenuObserver) |
|
111 : iItemMenuObserver(aItemMenuObserver) |
|
112 { |
|
113 TRACER("GLX_CLOUD::CGlxTagsContextMenuControl::CGlxTagsContextMenuControl"); |
|
114 //Nothing more to do for now |
|
115 } |
|
116 // --------------------------------------------------------------------------- |
|
117 // ConstructL() |
|
118 // --------------------------------------------------------------------------- |
|
119 // |
|
120 void CGlxTagsContextMenuControl::ConstructL() |
|
121 { |
|
122 TRACER("GLX_CLOUD::CGlxTagsContextMenuControl::ConstructL"); |
|
123 iUiUtility = CGlxUiUtility::UtilityL (); |
|
124 CAlfControl::ConstructL(*(iUiUtility->Env()) ); |
|
125 |
|
126 iTimer = CGlxBubbleTimer::NewL(this); |
|
127 |
|
128 iMainVisual = CAlfAnchorLayout::AddNewL(*this); |
|
129 iMainVisual->SetFlag(EAlfVisualFlagManualLayout); |
|
130 iMainVisual->SetSize(TSize(KReqWidth, KGridHeight)); |
|
131 iMainVisual->SetPos(TAlfRealPoint(KDummyPoint)); |
|
132 |
|
133 CFbsBitmap* bitmap = AknsUtils::GetCachedBitmap( |
|
134 AknsUtils::SkinInstance(), KAknsIIDQsnFrPopupCenter); |
|
135 CleanupStack::PushL(bitmap); |
|
136 |
|
137 CAlfTexture& backgroundAvkonTexture = |
|
138 iUiUtility->GlxTextureManager().CreateColorAvkonIconTextureL( |
|
139 KAknsIIDQsnFrPopupCenter, bitmap->Handle(), KRgbTransparent) ; |
|
140 |
|
141 CleanupStack::Pop(bitmap); |
|
142 |
|
143 // BackGround Border Image Visual |
|
144 iBackgroundBorderImageVisual = CAlfImageVisual::AddNewL(*this,iMainVisual); |
|
145 iBackgroundBorderImageVisual->SetImage(TAlfImage(backgroundAvkonTexture)); |
|
146 |
|
147 // Create a new 3x1 grid layout visual. |
|
148 iGrid = CAlfGridLayout::AddNewL(*this, KNoOfColumns, KNumofMenuItems , |
|
149 iMainVisual);//columns, rows |
|
150 |
|
151 //Finally create the menu list that will appear in screen |
|
152 CreateMenuListL(CreateFontL()); |
|
153 ShowItemMenu(EFalse); |
|
154 } |
|
155 // --------------------------------------------------------------------------- |
|
156 // ~CGlxTagsContextMenuControl() |
|
157 // --------------------------------------------------------------------------- |
|
158 // |
|
159 CGlxTagsContextMenuControl::~CGlxTagsContextMenuControl() |
|
160 { |
|
161 TRACER("GLX_CLOUD::CGlxTagsContextMenuControl::CGlxTagsContextMenuControl"); |
|
162 if (iMainVisual) |
|
163 { |
|
164 iMainVisual->RemoveAndDestroyAllD(); |
|
165 iMainVisual = NULL; |
|
166 } |
|
167 if ( iTimer) |
|
168 { |
|
169 iTimer->Cancel();//cancels any outstanding requests |
|
170 delete iTimer; |
|
171 iTimer = NULL; |
|
172 } |
|
173 |
|
174 if (iUiUtility) |
|
175 { |
|
176 iUiUtility->Close(); |
|
177 iUiUtility = NULL; |
|
178 } |
|
179 } |
|
180 // --------------------------------------------------------------------------- |
|
181 // CreateFont() |
|
182 // --------------------------------------------------------------------------- |
|
183 // |
|
184 TInt CGlxTagsContextMenuControl::CreateFontL() |
|
185 { |
|
186 TRACER("GLX_CLOUD::CGlxTagsContextMenuControl::CreateFont"); |
|
187 |
|
188 // Create a new style based on the required font |
|
189 CAlfTextStyleManager& styleMan = iUiUtility->Env()->TextStyleManager(); |
|
190 |
|
191 // remember its id for return later |
|
192 TInt id = styleMan.CreatePlatformTextStyleL(EAlfTextStyleNormal); |
|
193 |
|
194 // Get style. It is not owned |
|
195 CAlfTextStyle* style = styleMan.TextStyle(id); |
|
196 |
|
197 // Set this style to have required size and to be normal weight |
|
198 style->SetTextSizeInPixels(KTextSizeInPixels); |
|
199 style->SetBold(ETrue); |
|
200 |
|
201 return id; |
|
202 } |
|
203 |
|
204 // --------------------------------------------------------------------------- |
|
205 // CreateMenuListL() |
|
206 // --------------------------------------------------------------------------- |
|
207 // |
|
208 void CGlxTagsContextMenuControl::CreateMenuListL(TInt aFontId) |
|
209 { |
|
210 TRACER("GLX_CLOUD::CGlxTagsContextMenuControl::CreateMenuList"); |
|
211 |
|
212 TRgb color; |
|
213 //Gets the color of the text specific to skin |
|
214 AknsUtils::GetCachedColor(AknsUtils::SkinInstance(), |
|
215 color, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG6 ); |
|
216 |
|
217 //Loading the strings from rss |
|
218 HBufC* renameTitle = StringLoader::LoadLC( R_GLX_TAGS_RENAME_TITLE ); |
|
219 HBufC* slideshowTitle = StringLoader::LoadLC( R_GLX_TAGS_SLIDESHOW_TITLE ); |
|
220 HBufC* deleteTitle = StringLoader::LoadLC( R_GLX_TAGS_DELETE_TITLE ); |
|
221 |
|
222 iSlideshowTextVisual = CAlfTextVisual::AddNewL(*this, iGrid); |
|
223 iSlideshowTextVisual->SetTagL(KTagSlideshow); |
|
224 iSlideshowTextVisual->SetTextStyle(aFontId); |
|
225 iSlideshowTextVisual->SetColor(color); |
|
226 iSlideshowTextVisual->SetTextL(*slideshowTitle); |
|
227 iSlideshowTextVisual->SetOffset(TAlfTimedPoint(10,0)); |
|
228 iSlideshowTextVisual->SetAlign(EAlfAlignHLocale, EAlfAlignVCenter); |
|
229 |
|
230 iDeleteTextVisual = CAlfTextVisual::AddNewL(*this, iGrid); |
|
231 iDeleteTextVisual->SetTagL(KTagDelete); |
|
232 iDeleteTextVisual->SetTextStyle(aFontId); |
|
233 iDeleteTextVisual->SetColor(color); |
|
234 iDeleteTextVisual->SetTextL(*deleteTitle); |
|
235 iDeleteTextVisual->SetOffset(TAlfTimedPoint(10,0)); |
|
236 iDeleteTextVisual->SetAlign(EAlfAlignHLocale, EAlfAlignVCenter); |
|
237 |
|
238 iRenameTextVisual = CAlfTextVisual::AddNewL(*this, iGrid); |
|
239 iRenameTextVisual->SetTagL(KTagRename); |
|
240 iRenameTextVisual->SetTextStyle(aFontId); |
|
241 iRenameTextVisual->SetColor(color); |
|
242 iRenameTextVisual->SetTextL(*renameTitle); |
|
243 iRenameTextVisual->SetOffset(TAlfTimedPoint(10,0)); |
|
244 iRenameTextVisual->SetAlign(EAlfAlignHLocale, EAlfAlignVCenter); |
|
245 |
|
246 CleanupStack::PopAndDestroy(deleteTitle); // for deleteTitle |
|
247 CleanupStack::PopAndDestroy(slideshowTitle);// slideshowTitle |
|
248 CleanupStack::PopAndDestroy(renameTitle);// renameTitle |
|
249 } |
|
250 // --------------------------------------------------------------------------- |
|
251 // SetDisplayL() |
|
252 // --------------------------------------------------------------------------- |
|
253 // |
|
254 void CGlxTagsContextMenuControl::SetDisplay(const TPoint& aPoint) |
|
255 { |
|
256 TRACER("GLX_CLOUD::CGlxTagsContextMenuControl::SetDisplayL"); |
|
257 //if already started , cancel it |
|
258 if(iTimer && iTimer->IsActive()) |
|
259 { |
|
260 iTimer->Cancel();//cancels any outstanding requests |
|
261 } |
|
262 |
|
263 TInt upperYPos = aPoint.iY - KMinimalGap; |
|
264 TInt XPos = aPoint.iX ; |
|
265 |
|
266 //Preferred is to display in upper area |
|
267 TInt upperDisplayableHeight = upperYPos - iViewableRect.iTl.iY; |
|
268 TInt rightDisplayableWidth = iViewableRect.iBr.iY - XPos; |
|
269 |
|
270 //always draw above |
|
271 if(rightDisplayableWidth < KReqWidth) |
|
272 { |
|
273 XPos = aPoint.iX - KReqWidth; |
|
274 } |
|
275 if(upperDisplayableHeight < KGridHeight) |
|
276 { |
|
277 iMainVisual->SetPos(TAlfRealPoint(XPos , upperYPos )); |
|
278 } |
|
279 else |
|
280 { |
|
281 iMainVisual->SetPos(TAlfRealPoint(XPos , upperYPos - KGridHeight)); |
|
282 } |
|
283 |
|
284 iTimer->Cancel(); //cancels any outstanding requests |
|
285 iTimer->SetDelay(KTimerDelay); |
|
286 } |
|
287 |
|
288 // --------------------------------------------------------------------------- |
|
289 // ShowItemMenu() |
|
290 // --------------------------------------------------------------------------- |
|
291 // |
|
292 void CGlxTagsContextMenuControl::ShowItemMenu (TBool aShow) |
|
293 { |
|
294 TRACER("GLX_CLOUD::CGlxTagsContextMenuControl::ShowItemMenu"); |
|
295 if(aShow) |
|
296 { |
|
297 iMainVisual->SetOpacity(KOpacityOpaque); |
|
298 iItemMenuVisibility = ETrue; |
|
299 } |
|
300 else |
|
301 { |
|
302 iMainVisual->SetOpacity(KOpacityTransparent); |
|
303 iItemMenuVisibility = EFalse; |
|
304 } |
|
305 } |
|
306 // --------------------------------------------------------------------------- |
|
307 // OfferEventL() |
|
308 // --------------------------------------------------------------------------- |
|
309 // |
|
310 TBool CGlxTagsContextMenuControl::OfferEventL(const TAlfEvent& aEvent) |
|
311 { |
|
312 TRACER("GLX_CLOUD::CGlxTagsContextMenuControl::OfferEventL"); |
|
313 TBool consumed = EFalse; |
|
314 |
|
315 if(iItemMenuVisibility && aEvent.IsPointerEvent() && aEvent.PointerDown() ) |
|
316 { |
|
317 CAlfVisual* onVisual = aEvent.Visual(); |
|
318 TInt cmdId = KErrNotFound; |
|
319 if(AlfUtil::TagMatches(onVisual->Tag(), KTagSlideshow)) |
|
320 { |
|
321 cmdId = EGlxCmdSlideshowPlay; |
|
322 } |
|
323 else if(AlfUtil::TagMatches(onVisual->Tag(), KTagDelete)) |
|
324 { |
|
325 cmdId = EGlxCmdDelete; |
|
326 } |
|
327 else if(AlfUtil::TagMatches(onVisual->Tag(), KTagRename)) |
|
328 { |
|
329 cmdId = EGlxCmdRename; |
|
330 } |
|
331 |
|
332 if(cmdId >= 0) |
|
333 { |
|
334 ShowItemMenu(EFalse); |
|
335 iItemMenuObserver.HandleGridMenuListL(cmdId); |
|
336 consumed = ETrue; |
|
337 } |
|
338 } |
|
339 |
|
340 return consumed; |
|
341 } |
|
342 |
|
343 // --------------------------------------------------------------------------- |
|
344 // TimerComplete() |
|
345 // --------------------------------------------------------------------------- |
|
346 // |
|
347 void CGlxTagsContextMenuControl::TimerComplete() |
|
348 { |
|
349 TRACER("GLX_CLOUD::CGlxTagsContextMenuControl::TimerComplete"); |
|
350 ShowItemMenu(EFalse); |
|
351 } |
|
352 |
|
353 // --------------------------------------------------------------------------- |
|
354 // SetViewableRect() |
|
355 // --------------------------------------------------------------------------- |
|
356 // |
|
357 void CGlxTagsContextMenuControl::SetViewableRect(TRect aRect) |
|
358 { |
|
359 TRACER("GLX_CLOUD::CGlxTagsContextMenuControl::SetViewableRect"); |
|
360 iViewableRect.SetRect(aRect.iTl.iX, aRect.iTl.iY, |
|
361 aRect.iBr.iX, aRect.iBr.iY); |
|
362 } |