|
1 /* |
|
2 * Copyright (c) 2007-2008 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: Description of various grid templates |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "mulcoverflowtemplate.h" |
|
20 |
|
21 #include <AknUtils.h> |
|
22 |
|
23 #include <alf/alftextvisual.h> |
|
24 #include <alf/alfutil.h> |
|
25 #include "mulassert.h" |
|
26 |
|
27 namespace Alf |
|
28 { |
|
29 |
|
30 // --------------------------------------------------------------------------- |
|
31 // MulCoverLogicalTemplate4 |
|
32 // --------------------------------------------------------------------------- |
|
33 // |
|
34 MulCoverFlowTemplate4::MulCoverFlowTemplate4(MulCoverFlowControl &aControl, |
|
35 MulBaseElement &aBaseElement):MulCoverFlowTemplate(aControl, aBaseElement) |
|
36 { |
|
37 |
|
38 } |
|
39 |
|
40 // --------------------------------------------------------------------------- |
|
41 // ~MulCoverLogicalTemplate4 |
|
42 // --------------------------------------------------------------------------- |
|
43 // |
|
44 MulCoverFlowTemplate4::~MulCoverFlowTemplate4() |
|
45 { |
|
46 |
|
47 } |
|
48 |
|
49 |
|
50 // --------------------------------------------------------------------------- |
|
51 // GetIconSize |
|
52 // --------------------------------------------------------------------------- |
|
53 // |
|
54 void MulCoverFlowTemplate4::GetIconSize(mulvisualitem::TVisualAttribute aAttribute,bool aIslandscape, int& aHeight, int& aWidth) |
|
55 { |
|
56 int appMainPaneVerityId; |
|
57 int coverFlowPaneVarietyId; |
|
58 int imagePaneVerityId ; |
|
59 int videoIndVerityId ; |
|
60 if (aIslandscape) |
|
61 { |
|
62 appMainPaneVerityId = 7; |
|
63 coverFlowPaneVarietyId = 1; |
|
64 imagePaneVerityId = 6; |
|
65 videoIndVerityId = 0; |
|
66 } |
|
67 else |
|
68 { |
|
69 appMainPaneVerityId = 7; |
|
70 coverFlowPaneVarietyId = 1; |
|
71 imagePaneVerityId = 6; |
|
72 videoIndVerityId = 0; |
|
73 } |
|
74 |
|
75 // Get the size of the appwindow |
|
76 TAknWindowLineLayout appMainLayout = |
|
77 AknLayoutScalable_UiAccel::main_pane(appMainPaneVerityId).LayoutLine(); |
|
78 TAknLayoutRect appMainRect; |
|
79 appMainRect.LayoutRect( AlfUtil::ScreenSize(), appMainLayout ); |
|
80 TSize appMainSize(appMainRect.Rect().Size()); |
|
81 |
|
82 // Get the size of the coverflow main window |
|
83 TAknWindowLineLayout mainLayout = |
|
84 AknLayoutScalable_UiAccel::main_aa_coverflow_pane(coverFlowPaneVarietyId).LayoutLine(); |
|
85 TAknLayoutRect mainRect; |
|
86 mainRect.LayoutRect( AlfUtil::ScreenSize(), mainLayout ); |
|
87 TSize mainSize(mainRect.Rect().Size()); |
|
88 |
|
89 switch(aAttribute) |
|
90 { |
|
91 case mulvisualitem::KMulIcon1: |
|
92 { |
|
93 TAknWindowLineLayout centerLayout = |
|
94 AknLayoutScalable_UiAccel::aacf_image_pane(imagePaneVerityId).LayoutLine(); |
|
95 TAknLayoutRect centerRect; |
|
96 centerRect.LayoutRect( TSize(mainSize), centerLayout ); |
|
97 aHeight = centerRect.Rect().Size().iHeight; |
|
98 aWidth = centerRect.Rect().Size().iWidth; |
|
99 break; |
|
100 } |
|
101 case mulvisualitem::KMulIndicator2: |
|
102 { |
|
103 TAknWindowLineLayout centerLayout = |
|
104 AknLayoutScalable_UiAccel::main_aa_video_pane_g1(videoIndVerityId).LayoutLine(); |
|
105 TAknLayoutRect centerRect; |
|
106 centerRect.LayoutRect( TSize(mainSize), centerLayout ); |
|
107 aHeight = centerRect.Rect().Size().iHeight; |
|
108 aWidth = centerRect.Rect().Size().iWidth; |
|
109 break; |
|
110 } |
|
111 default: |
|
112 { |
|
113 // invalid attribute |
|
114 // raise exception. |
|
115 __MUL_ASSERT(false,KInvalidAttribute); |
|
116 |
|
117 break; |
|
118 } |
|
119 } |
|
120 } |
|
121 |
|
122 |
|
123 // --------------------------------------------------------------------------- |
|
124 // CreateVisualisation |
|
125 // --------------------------------------------------------------------------- |
|
126 // |
|
127 void MulCoverFlowTemplate4::CreateVisualisation(bool aIsLandscape,bool aIsOrientationChange) |
|
128 { |
|
129 // set the default attribue of the template |
|
130 // irrespective of the orientation |
|
131 mData->mSliderEnabled = false; |
|
132 mData->mUiOnOffFlag = true; |
|
133 mData->mMaxVisibleCount = 1; |
|
134 mData->mEnhancedSupportFlag = true; |
|
135 |
|
136 // store the default attribute in base element |
|
137 mData->mBaseElement->SetFitMode(true); |
|
138 mData->mBaseElement->StoreTextVisibility( false ); |
|
139 |
|
140 // get the main text layout |
|
141 CAlfLayout& textLayout = mData->mBaseElement->TextLayout(); |
|
142 textLayout.SetOpacity(0); |
|
143 |
|
144 mData->mOrientationChange = aIsOrientationChange; |
|
145 if (aIsLandscape) |
|
146 { |
|
147 // create visualisation for landscape |
|
148 CreateLscStructure(); |
|
149 } |
|
150 else |
|
151 { |
|
152 // create visualisation for potrait |
|
153 CreatePrtStructure(); |
|
154 } |
|
155 mData->mOrientationChange = false; |
|
156 } |
|
157 |
|
158 |
|
159 // --------------------------------------------------------------------------- |
|
160 // CreatePrtStructure |
|
161 // --------------------------------------------------------------------------- |
|
162 // |
|
163 void MulCoverFlowTemplate4::CreatePrtStructure() |
|
164 { |
|
165 // list of all component lct verity id. |
|
166 int mainPaneVerityId = 1; |
|
167 int imagePaneVerityId = 6; |
|
168 int videoPaneVerityId = 0; |
|
169 int counterPaneVerityId = 3; |
|
170 |
|
171 CAlfVisual* main = mData->mBaseElement->findVisual(KMainLayoutIndex); |
|
172 CAlfLayout* parentLayout = main->Layout(); |
|
173 TSize mainSize = parentLayout->Size().Target().AsSize(); |
|
174 |
|
175 // get for main layout |
|
176 TAknWindowLineLayout componentLayout = |
|
177 AknLayoutScalable_UiAccel::main_aa_coverflow_pane(mainPaneVerityId).LayoutLine(); |
|
178 TRect mainRect = IconWindowRect(componentLayout, mainSize); |
|
179 main->SetPos(TAlfRealPoint(0,0)); |
|
180 main->SetSize(mainRect.Size()); |
|
181 |
|
182 |
|
183 // for deck layout |
|
184 CAlfDeckLayout& deckLayout = static_cast<CAlfDeckLayout&>( |
|
185 static_cast<CAlfLayout*>(main)->Visual(KMainLayoutIndex) ); |
|
186 deckLayout.SetSize(mainRect.Size(),0); |
|
187 |
|
188 // if set background with some skin id is called before calling set model |
|
189 // then the visual and texture would be created with 0,0 sizes |
|
190 // hence we need to resize them |
|
191 CAlfVisual* backgroundVisual = deckLayout.FindTag(backgroundvisual); |
|
192 if(backgroundVisual) |
|
193 { |
|
194 backgroundVisual->SetSize(mainRect.Size(),0); |
|
195 } |
|
196 |
|
197 // for center item |
|
198 componentLayout = |
|
199 AknLayoutScalable_UiAccel::aacf_image_pane(imagePaneVerityId).LayoutLine(); |
|
200 TRect centerRect = IconWindowRect(componentLayout,mainRect); |
|
201 |
|
202 TMulCoverFlowItem highlightItem(centerRect.iTl.iX, |
|
203 centerRect.iTl.iY,centerRect.Size().iWidth,centerRect.Size().iHeight); |
|
204 |
|
205 // apply attribute |
|
206 mData->mBaseElement->StoreVisualDimensions(highlightItem,highlightItem,mData->mMaxVisibleCount ); |
|
207 |
|
208 |
|
209 |
|
210 // for indicator icon |
|
211 componentLayout = |
|
212 AknLayoutScalable_UiAccel::main_aa_video_pane_g1(videoPaneVerityId).LayoutLine(); |
|
213 TRect indRect = IconWindowRect(componentLayout,mainRect); |
|
214 TSize indSize(indRect.Size()); |
|
215 mData->mIndicatorDimensions.height = indSize.iHeight; |
|
216 mData->mIndicatorDimensions.width = indSize.iWidth; |
|
217 mData->mIndicatorDimensions.posx = indRect.iTl.iX; |
|
218 mData->mIndicatorDimensions.posy = indRect.iTl.iY; |
|
219 |
|
220 // crete counter |
|
221 ApplyCounterAttribute(counterPaneVerityId,mainRect); |
|
222 } |
|
223 |
|
224 // --------------------------------------------------------------------------- |
|
225 // CreateLscStructure |
|
226 // --------------------------------------------------------------------------- |
|
227 // |
|
228 void MulCoverFlowTemplate4::CreateLscStructure() |
|
229 { |
|
230 // list of all component lct verity id. |
|
231 int mainPaneVerityId = 1; |
|
232 int imagePaneVerityId = 6; |
|
233 int videoPaneVerityId = 0; |
|
234 int counterPaneVerityId = 8; |
|
235 |
|
236 CAlfVisual* main = mData->mBaseElement->findVisual(KMainLayoutIndex); |
|
237 CAlfLayout* prntLay = main->Layout(); |
|
238 TSize main_size = prntLay->Size().Target().AsSize(); |
|
239 TAknWindowLineLayout componentLayout; |
|
240 |
|
241 // get for main layout |
|
242 componentLayout = |
|
243 AknLayoutScalable_UiAccel::main_aa_coverflow_pane(mainPaneVerityId).LayoutLine(); |
|
244 TRect mainRect = IconWindowRect(componentLayout, main_size); |
|
245 main->SetPos(TAlfRealPoint(0,0)); |
|
246 main->SetSize(mainRect.Size()); |
|
247 |
|
248 // for deck layout |
|
249 CAlfDeckLayout& deckLayout = static_cast<CAlfDeckLayout&>( |
|
250 static_cast<CAlfLayout*>(main)->Visual(KMainLayoutIndex) ); |
|
251 deckLayout.SetSize(mainRect.Size(),0); |
|
252 |
|
253 // if set background with some skin id is called before calling set model |
|
254 // then the visual and texture would be created with 0,0 sizes |
|
255 // hence we need to resize them |
|
256 CAlfVisual* backgroundVisual = deckLayout.FindTag(backgroundvisual); |
|
257 if(backgroundVisual) |
|
258 { |
|
259 backgroundVisual->SetSize(mainRect.Size(),0); |
|
260 } |
|
261 |
|
262 // for center item |
|
263 |
|
264 componentLayout = |
|
265 AknLayoutScalable_UiAccel::aacf_image_pane(imagePaneVerityId).LayoutLine(); |
|
266 TRect centerRect = IconWindowRect(componentLayout,mainRect); |
|
267 |
|
268 TMulCoverFlowItem highlightItem(centerRect.iTl.iX, |
|
269 centerRect.iTl.iY,centerRect.Size().iWidth,centerRect.Size().iHeight); |
|
270 |
|
271 // apply attribute |
|
272 mData->mBaseElement->StoreVisualDimensions(highlightItem,highlightItem,mData->mMaxVisibleCount ); |
|
273 |
|
274 |
|
275 // for indicator icon |
|
276 componentLayout = |
|
277 AknLayoutScalable_UiAccel::main_aa_video_pane_g1(videoPaneVerityId).LayoutLine(); |
|
278 TRect indRect = IconWindowRect(componentLayout,mainRect); |
|
279 TSize indSize(indRect.Size()); |
|
280 mData->mIndicatorDimensions.height = indSize.iHeight; |
|
281 mData->mIndicatorDimensions.width = indSize.iWidth; |
|
282 mData->mIndicatorDimensions.posx = indRect.iTl.iX; |
|
283 mData->mIndicatorDimensions.posy = indRect.iTl.iY; |
|
284 |
|
285 // crete counter |
|
286 ApplyCounterAttribute(counterPaneVerityId,mainRect); |
|
287 } |
|
288 |
|
289 // --------------------------------------------------------------------------- |
|
290 // ApplyCounterAttribute |
|
291 // --------------------------------------------------------------------------- |
|
292 // |
|
293 void MulCoverFlowTemplate4::ApplyCounterAttribute(int acounterPaneVerityId,const TRect& aMainRect) |
|
294 { |
|
295 mData->mUiOnOffFlag = true; |
|
296 TAknTextLineLayout counterComponentLayout = |
|
297 AknLayoutScalable_UiAccel::main_aa_coverflow_pane_t1(acounterPaneVerityId).LayoutLine(); |
|
298 |
|
299 TRect counterRect = TextWindowRect(counterComponentLayout, aMainRect); |
|
300 TSize counterSize(counterRect.Size()); |
|
301 mData->mCounterDimensions.posx = counterRect.iTl.iX; |
|
302 mData->mCounterDimensions.posy = counterRect.iTl.iY; |
|
303 mData->mCounterDimensions.width = counterSize.iWidth; |
|
304 mData->mCounterDimensions.height = counterSize.iHeight; |
|
305 |
|
306 // Create a Counter visual if it is not Created. |
|
307 CAlfTextVisual& counterVisual = mData->mBaseElement->CounterVisual(); |
|
308 |
|
309 // Set Properties to Counter Visual if we are creating. |
|
310 // no need to apply attribute for orientation change |
|
311 // as all are same. |
|
312 if(!mData->mOrientationChange) |
|
313 { |
|
314 //get font Id for counter |
|
315 int fontId = counterComponentLayout.FontId(); |
|
316 int counterFontId = 0x000000FF & fontId; |
|
317 // apply default brush color to the counter background |
|
318 ApplyBrush(counterVisual,KRgbBlack,0.5); |
|
319 // apply default attribute |
|
320 counterVisual.SetAlign(EAlfAlignHCenter,EAlfAlignVCenter); |
|
321 SetTextStyle(counterFontId, counterVisual); |
|
322 |
|
323 // check if user has set some different attribute. |
|
324 TMulVisualColorProperty counterColor = mData->mBaseElement->TextColor(ECounterVisual); |
|
325 if (counterColor.mIsColorSet) |
|
326 { |
|
327 // apply the color set by the application |
|
328 counterVisual.SetColor(counterColor.mColor); |
|
329 } |
|
330 else |
|
331 { |
|
332 // apply the default color |
|
333 counterVisual.SetColor(KRgbWhite); |
|
334 } |
|
335 mData->mCounterFontMaxCharLength = UpdateMaxFontWidth(&counterVisual); |
|
336 } |
|
337 |
|
338 } |
|
339 |
|
340 }//namespace ends |