author | Simon Howkins <simonh@symbian.org> |
Tue, 16 Nov 2010 11:12:20 +0000 | |
branch | RCL_3 |
changeset 108 | cf9be2d674f1 |
parent 102 | ba63c83f4716 |
permissions | -rw-r--r-- |
83 | 1 |
/* |
2 |
* Copyright (c) 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: Taskswitcher Fast Swap area UI |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
#include <gulicon.h> |
|
20 |
#include <eikenv.h> |
|
21 |
#include <AknUtils.h> |
|
22 |
#include <AknIconUtils.h> |
|
23 |
#include <AknIconArray.h> |
|
24 |
#include <aknstyluspopupmenu.h> |
|
25 |
#include <AknQueryDialog.h> |
|
26 |
#include <StringLoader.h> |
|
27 |
#include <taskswitcher.rsg> |
|
28 |
#include <aknlayoutscalable_apps.cdl.h> |
|
29 |
#include <layoutmetadata.cdl.h> |
|
30 |
#include <aknlists.h> |
|
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
31 |
#include <touchfeedback.h> |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
32 |
#include <akntransitionutils.h> |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
33 |
#include <akntranseffect.h> |
83 | 34 |
#include <aknlongtapanimation.h> |
35 |
||
36 |
#include "tsfastswaparea.h" |
|
37 |
#include "tsapplogging.h" |
|
38 |
#include "tsfswclient.h" |
|
39 |
#include "tsappui.h" |
|
40 |
#include "tsdatachangeobserver.h" |
|
41 |
#include "tseventcontroler.h" |
|
42 |
#include "tsappview.h" |
|
43 |
||
44 |
/** command ids for the fsw popup */ |
|
45 |
enum TPopupCommands |
|
46 |
{ |
|
47 |
EFswCmdClose = 10000, |
|
48 |
EFswCmdCloseAll |
|
49 |
}; |
|
50 |
||
51 |
/** Number of closable applications, to show "close all" option. */ |
|
52 |
const TInt KTsMaxClosableApps = 2; |
|
53 |
||
54 |
/** Default grid item to highlight.*/ |
|
55 |
const TInt KItemToHighlight = 2; |
|
56 |
||
57 |
const TInt KAppKeyTypeShort = 1; |
|
58 |
const TInt KAppKeyTypeLong = 2; |
|
59 |
||
60 |
const TInt KLayoutItemCount = 4; |
|
61 |
||
62 |
const TInt KRedrawTime = 250000; // 0.25 sec |
|
63 |
const TInt KRedrawTimeForLayoutSwitch = 700000; // 0.7 sec |
|
64 |
const TInt KHighlighActivationTime = 100000; // 100 ms |
|
65 |
const TInt KUpdateGridTime = 0; // imediately |
|
66 |
const TInt KOrientationSwitchTime = 1000000; // 1 sec |
|
67 |
const TInt KLongTapAnimationInitTime = 150000; // 0.15 sec |
|
68 |
const TInt KLongTapAnimationTimeout = 1000000; // 1 sec |
|
69 |
||
70 |
const TInt KMaxGranularity = 4; |
|
71 |
||
72 |
const TUid KTsMenuUid = { 0x101f4cd2 }; |
|
73 |
const TUid KTsHomescreenUid = { 0x102750f0 }; |
|
74 |
||
75 |
// ----------------------------------------------------------------------------- |
|
76 |
// CTsFastSwapArea::NewL |
|
77 |
// ----------------------------------------------------------------------------- |
|
78 |
// |
|
79 |
CTsFastSwapArea* CTsFastSwapArea::NewL( const TRect& aRect, |
|
80 |
CCoeControl& aParent, CTsDeviceState& aDeviceState, |
|
81 |
CTsEventControler& aEventHandler ) |
|
82 |
{ |
|
83 |
CTsFastSwapArea* self = CTsFastSwapArea::NewLC(aRect, |
|
84 |
aParent, aDeviceState, aEventHandler); |
|
85 |
CleanupStack::Pop( self ); |
|
86 |
return self; |
|
87 |
} |
|
88 |
||
89 |
// ----------------------------------------------------------------------------- |
|
90 |
// CTsFastSwapArea::NewLC |
|
91 |
// ----------------------------------------------------------------------------- |
|
92 |
// |
|
93 |
CTsFastSwapArea* CTsFastSwapArea::NewLC( const TRect& aRect, |
|
94 |
CCoeControl& aParent, CTsDeviceState& aDeviceState, |
|
95 |
CTsEventControler& aEventHandler) |
|
96 |
{ |
|
97 |
CTsFastSwapArea* self = new (ELeave) CTsFastSwapArea( |
|
98 |
aParent, aDeviceState, aEventHandler); |
|
99 |
CleanupStack::PushL( self ); |
|
100 |
self->ConstructL( aRect ); |
|
101 |
return self; |
|
102 |
} |
|
103 |
||
104 |
// ----------------------------------------------------------------------------- |
|
105 |
// CTsFastSwapArea::CTsFastSwapArea |
|
106 |
// ----------------------------------------------------------------------------- |
|
107 |
// |
|
108 |
CTsFastSwapArea::CTsFastSwapArea(CCoeControl& aParent, |
|
109 |
CTsDeviceState& aDeviceState, |
|
110 |
CTsEventControler& aEventHandler) : |
|
111 |
iParent(aParent), iDeviceState(aDeviceState), iEvtHandler(aEventHandler), |
|
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
112 |
iIgnoreLayoutSwitch(EFalse), iWidgetClosingCount(0), iLongTapAnimationRunning(EFalse) |
83 | 113 |
{ |
114 |
// no implementation required |
|
115 |
} |
|
116 |
||
117 |
// ----------------------------------------------------------------------------- |
|
118 |
// CTsFastSwapArea::~CTsFastSwapArea |
|
119 |
// ----------------------------------------------------------------------------- |
|
120 |
// |
|
121 |
CTsFastSwapArea::~CTsFastSwapArea() |
|
122 |
{ |
|
123 |
iArray.ResetAndDestroy(); |
|
124 |
iIsClosing.Close(); |
|
125 |
delete iGrid; |
|
126 |
delete iFSClient; |
|
127 |
delete iPopup; |
|
128 |
delete iHighlightTimer; |
|
129 |
delete iRedrawTimer; |
|
130 |
delete iUpdateGridTimer; |
|
131 |
delete iOrientationSignalTimer; |
|
132 |
delete iLongTapAnimation; |
|
133 |
delete iLongTapAnimationTimer; |
|
134 |
} |
|
135 |
||
136 |
// ----------------------------------------------------------------------------- |
|
137 |
// CTsFastSwapArea::ConstructL |
|
138 |
// ----------------------------------------------------------------------------- |
|
139 |
// |
|
140 |
void CTsFastSwapArea::ConstructL( const TRect& aRect ) |
|
141 |
{ |
|
142 |
SetContainerWindowL( iParent ); |
|
143 |
||
144 |
SetRect( aRect ); |
|
145 |
||
146 |
// setup grid |
|
147 |
ReCreateGridL(); |
|
148 |
||
149 |
// create stylus popup instance |
|
150 |
PreCreatePopupL(); |
|
151 |
||
152 |
// connect to fsw server |
|
153 |
iFSClient = CTsFswClient::NewL(); |
|
154 |
||
155 |
iEvtHandler.ReInitPhysicsL(GridWorldSize(), ViewSize(), ETrue); |
|
156 |
||
157 |
// add self to device state observer |
|
158 |
iDeviceState.AddObserverL( *this, EDeviceType ); |
|
159 |
||
160 |
iHighlightTimer = new (ELeave) CTsFastSwapTimer( *this ); |
|
161 |
iHighlightTimer->ConstructL(); |
|
162 |
||
163 |
iRedrawTimer = new (ELeave) CTsFastSwapTimer( *this ); |
|
164 |
iRedrawTimer->ConstructL(); |
|
165 |
||
166 |
iUpdateGridTimer = new (ELeave) CTsFastSwapTimer( *this ); |
|
167 |
iUpdateGridTimer->ConstructL(); |
|
168 |
||
169 |
iOrientationSignalTimer = new (ELeave) CTsFastSwapTimer( *this ); |
|
170 |
iOrientationSignalTimer->ConstructL(); |
|
171 |
||
172 |
iLongTapAnimationTimer = new (ELeave) CTsFastSwapTimer( *this ); |
|
173 |
iLongTapAnimationTimer->ConstructL(); |
|
174 |
||
175 |
iActivateOnPointerRelease = TPoint(); |
|
176 |
iHandlePointerCandidate = EFalse; |
|
177 |
||
178 |
ActivateL(); |
|
179 |
} |
|
180 |
||
181 |
// ----------------------------------------------------------------------------- |
|
182 |
// CTsFastSwapArea::ReCreateGridL |
|
183 |
// ----------------------------------------------------------------------------- |
|
184 |
// |
|
185 |
void CTsFastSwapArea::ReCreateGridL() |
|
186 |
{ |
|
187 |
MCoeControlObserver* obs = NULL; |
|
188 |
TBool wasHighlight = iDeviceState.DeviceType() == |
|
189 |
CTsDeviceState::EHybrid ? ETrue : EFalse; |
|
190 |
if ( iGrid ) |
|
191 |
{ |
|
192 |
obs = iGrid->Observer(); |
|
193 |
iDeviceState.RemoveObserver(*iGrid); |
|
194 |
wasHighlight = iGrid->IsHighlightVisible(); |
|
195 |
delete iGrid; |
|
196 |
iGrid = NULL; |
|
197 |
} |
|
198 |
||
199 |
iGrid = new( ELeave ) CTsFastSwapGrid; |
|
200 |
iGrid->ConstructL( this ); |
|
201 |
iGrid->DisableSingleClick(ETrue);//enables highlight on pointer |
|
202 |
iDeviceState.AddObserverL(*iGrid, MTsDeviceStateObserver::ESkin); |
|
203 |
||
204 |
AknListBoxLayouts::SetupStandardGrid( *iGrid ); |
|
205 |
||
206 |
// Setup layout |
|
207 |
LayoutGridL(); |
|
208 |
||
209 |
if( wasHighlight ) |
|
210 |
{ |
|
211 |
iGrid->ShowHighlight(); |
|
212 |
} |
|
213 |
else |
|
214 |
{ |
|
215 |
iGrid->HideHighlight(); |
|
216 |
} |
|
217 |
||
218 |
// Setup empty text |
|
219 |
HBufC* text = StringLoader::LoadLC( R_TS_FSW_NO_APPS ); |
|
220 |
iGrid->SetEmptyGridTextL( *text ); |
|
221 |
CleanupStack::PopAndDestroy( text ); |
|
222 |
||
223 |
// Setup grid observers |
|
224 |
if ( obs ) |
|
225 |
{ |
|
226 |
iGrid->SetObserver( obs ); |
|
227 |
} |
|
228 |
iGrid->SetListBoxObserver(this); |
|
229 |
iGrid->SetFastSwapGridObserver(this); |
|
230 |
iGrid->SetContainerWindowL(*this); |
|
231 |
||
232 |
// Make sure that there is an ActivateL call even when we are not |
|
233 |
// called from ConstructL. (in order to have the grid's parent ptr set properly) |
|
234 |
ActivateL(); |
|
235 |
} |
|
236 |
||
237 |
||
238 |
// -------------------------------------------------------------------------- |
|
239 |
// CTsFastSwapArea::LayoutGridL |
|
240 |
// -------------------------------------------------------------------------- |
|
241 |
// |
|
242 |
void CTsFastSwapArea::LayoutGridL() |
|
243 |
{ |
|
244 |
RArray<TAknLayoutRect> rects; |
|
245 |
CleanupClosePushL(rects); |
|
246 |
rects.ReserveL(KLayoutItemCount); |
|
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
247 |
GetFastSwapAreaRects(rects); |
83 | 248 |
TAknLayoutRect gridAppPane = rects[0]; |
249 |
TAknLayoutRect gridItem = rects[1]; |
|
250 |
TAknLayoutRect gridImage = rects[2]; |
|
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
251 |
TAknLayoutRect gridNextItem = rects[3]; |
83 | 252 |
CleanupStack::PopAndDestroy(&rects); |
253 |
||
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
254 |
iGrid->SetRect(gridAppPane.Rect()); |
88
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
83
diff
changeset
|
255 |
|
83 | 256 |
TInt variety; |
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
257 |
TBool disable = GetVariety(variety); |
83 | 258 |
if ( disable ) |
259 |
{ |
|
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
260 |
TRAP_IGNORE(static_cast<CTsAppUi*>(iEikonEnv->AppUi())->RequestPopUpL()); |
83 | 261 |
} |
262 |
variety = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0; // double check to avoid layout panic |
|
263 |
||
264 |
TAknLayoutScalableParameterLimits gridParams = |
|
265 |
AknLayoutScalable_Apps::cell_tport_appsw_pane_ParamLimits( variety ); |
|
266 |
TPoint empty( ELayoutEmpty, ELayoutEmpty ); |
|
267 |
||
268 |
// Setup bitmap layout |
|
269 |
AknListBoxLayouts::SetupFormGfxCell( *iGrid, iGrid->ItemDrawer(), 0, |
|
270 |
AknLayoutScalable_Apps::cell_tport_appsw_pane_g1( variety ).LayoutLine(), |
|
271 |
empty, empty ); |
|
272 |
||
273 |
// Setup text layout |
|
274 |
AknListBoxLayouts::SetupFormTextCell(*iGrid, iGrid->ItemDrawer(), 1, |
|
275 |
AknLayoutScalable_Apps::cell_tport_appsw_pane_t1( variety ).LayoutLine(), |
|
276 |
empty, empty); |
|
277 |
||
278 |
// Text colors |
|
279 |
TRgb textColor; |
|
280 |
AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), textColor, |
|
281 |
KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG19 ); |
|
282 |
TRgb highlightTextColor; |
|
283 |
AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), highlightTextColor, |
|
284 |
KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG11 ); |
|
285 |
CFormattedCellListBoxData::TColors colors; |
|
286 |
colors.iText = textColor; |
|
287 |
colors.iBack = iGrid->ItemDrawer()->BackColor(); |
|
288 |
colors.iHighlightedText = highlightTextColor; |
|
289 |
colors.iHighlightedBack = iGrid->ItemDrawer()->HighlightedBackColor(); |
|
290 |
iGrid->ItemDrawer()->FormattedCellData()->SetSubCellColorsL(1, colors); |
|
291 |
iGrid->SetStrokeColors(textColor, highlightTextColor); |
|
292 |
||
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
293 |
if ( AknLayoutUtils::LayoutMirrored() ) |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
294 |
{ |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
295 |
iGridItemGap = gridItem.Rect().iTl.iX - gridNextItem.Rect().iBr.iX; |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
296 |
} |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
297 |
else |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
298 |
{ |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
299 |
iGridItemGap = gridNextItem.Rect().iTl.iX - gridItem.Rect().iBr.iX; |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
300 |
} |
83 | 301 |
iMaxItemsOnScreen = Rect().Width() / gridItem.Rect().Width(); |
302 |
if ( iMaxItemsOnScreen > 1 ) |
|
303 |
{ |
|
304 |
TInt widthWithGaps = |
|
305 |
(iMaxItemsOnScreen - 1) * iGridItemGap + iMaxItemsOnScreen * gridItem.Rect().Width(); |
|
306 |
if ( widthWithGaps > Rect().Width() ) |
|
307 |
{ |
|
308 |
iMaxItemsOnScreen--; |
|
309 |
} |
|
310 |
} |
|
311 |
iGridItemWidth = gridItem.Rect().Width(); |
|
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
312 |
|
83 | 313 |
// Update item drawer |
314 |
iGrid->UpdateItemDrawerLayoutDataL(); |
|
315 |
||
316 |
// Update state |
|
317 |
HandleDeviceStateChanged( EDeviceType ); |
|
318 |
||
319 |
if ( disable ) |
|
320 |
{ |
|
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
321 |
TRAP_IGNORE(static_cast<CTsAppUi*>(iEikonEnv->AppUi())->DisablePopUpL()); |
83 | 322 |
} |
323 |
} |
|
324 |
||
325 |
||
326 |
// -------------------------------------------------------------------------- |
|
327 |
// CTsFastSwapArea::LayoutGridView |
|
328 |
// -------------------------------------------------------------------------- |
|
329 |
// |
|
330 |
void CTsFastSwapArea::LayoutGridViewL( TInt aItemCount ) |
|
331 |
{ |
|
332 |
RArray<TAknLayoutRect> rects; |
|
333 |
CleanupClosePushL(rects); |
|
334 |
rects.ReserveL(KLayoutItemCount); |
|
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
335 |
GetFastSwapAreaRects(rects); |
83 | 336 |
TAknLayoutRect gridItem = rects[1]; |
337 |
CleanupStack::PopAndDestroy(&rects); |
|
338 |
if ( aItemCount ) |
|
339 |
{ |
|
340 |
iGrid->ItemDrawer()->ColumnData()->SetDrawBackground(EFalse); |
|
341 |
static_cast<CTsAppView*>(&iParent)->EnableDragEvents(ETrue); |
|
342 |
if ( AknLayoutUtils::LayoutMirrored() ) |
|
343 |
{ |
|
344 |
iGrid->SetLayoutL( EFalse, EFalse, ETrue, aItemCount, 1, gridItem.Rect().Size(), iGridItemGap ); |
|
345 |
} |
|
346 |
else |
|
347 |
{ |
|
348 |
iGrid->SetLayoutL( EFalse, ETrue, ETrue, aItemCount, 1, gridItem.Rect().Size(), iGridItemGap ); |
|
349 |
} |
|
350 |
} |
|
351 |
else |
|
352 |
{ |
|
353 |
iGrid->ItemDrawer()->ColumnData()->SetDrawBackground(ETrue); |
|
354 |
static_cast<CTsAppView*>(&iParent)->EnableDragEvents(EFalse); |
|
355 |
} |
|
356 |
||
357 |
// Update scrollbar frame |
|
358 |
if( iGrid->ScrollBarFrame() ) |
|
359 |
{ |
|
360 |
iGrid->SetScrollBarFrame(NULL,CEikListBox::EOwnedExternally); |
|
361 |
} |
|
362 |
} |
|
363 |
||
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
364 |
|
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
365 |
// -------------------------------------------------------------------------- |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
366 |
// CTsFastSwapArea::GetFastSwapAreaRects |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
367 |
// -------------------------------------------------------------------------- |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
368 |
// |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
369 |
void CTsFastSwapArea::GetFastSwapAreaRects( RArray<TAknLayoutRect>& aRects ) |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
370 |
{ |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
371 |
TAknLayoutRect gridAppPane; |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
372 |
TAknLayoutRect gridItem; |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
373 |
TAknLayoutRect gridImage; |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
374 |
TAknLayoutRect gridNextItem; |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
375 |
|
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
376 |
TInt variety; |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
377 |
TBool disable = GetVariety(variety); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
378 |
if ( disable ) |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
379 |
{ |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
380 |
TRAP_IGNORE(static_cast<CTsAppUi*>(iEikonEnv->AppUi())->RequestPopUpL()); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
381 |
} |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
382 |
variety = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0; // double check to avoid layout panic |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
383 |
|
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
384 |
gridAppPane.LayoutRect( Rect(), |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
385 |
AknLayoutScalable_Apps::tport_appsw_pane( variety ) ); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
386 |
aRects.Append(gridAppPane); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
387 |
|
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
388 |
gridItem.LayoutRect( gridAppPane.Rect(), |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
389 |
AknLayoutScalable_Apps::cell_tport_appsw_pane( variety, 0, 0 ) ); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
390 |
aRects.Append(gridItem); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
391 |
|
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
392 |
gridImage.LayoutRect( gridItem.Rect(), |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
393 |
AknLayoutScalable_Apps::cell_tport_appsw_pane_g1( variety ) ); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
394 |
aRects.Append(gridImage); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
395 |
gridNextItem.LayoutRect( gridAppPane.Rect(), |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
396 |
AknLayoutScalable_Apps::cell_tport_appsw_pane_cp03( variety ) ); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
397 |
aRects.Append(gridNextItem); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
398 |
|
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
399 |
if ( disable ) |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
400 |
{ |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
401 |
TRAP_IGNORE(static_cast<CTsAppUi*>(iEikonEnv->AppUi())->DisablePopUpL()); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
402 |
} |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
403 |
} |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
404 |
|
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
405 |
|
83 | 406 |
// -------------------------------------------------------------------------- |
407 |
// CTsFastSwapArea::Setup |
|
408 |
// -------------------------------------------------------------------------- |
|
409 |
// |
|
410 |
void CTsFastSwapArea::Setup( MCoeControlObserver& aControlObserver ) |
|
411 |
{ |
|
412 |
iGrid->SetObserver( &aControlObserver ); |
|
413 |
} |
|
414 |
||
415 |
// ----------------------------------------------------------------------------- |
|
416 |
// CTsFastSwapArea::SizeChanged |
|
417 |
// ----------------------------------------------------------------------------- |
|
418 |
// |
|
419 |
void CTsFastSwapArea::SizeChanged() |
|
420 |
{ |
|
421 |
TSLOG_CONTEXT( CTsFastSwapArea::SizeChanged, TSLOG_LOCAL ); |
|
422 |
TSLOG_IN(); |
|
423 |
||
424 |
if ( iGrid && !iIgnoreLayoutSwitch ) |
|
425 |
{ |
|
426 |
// Cancel ongoing pointer event |
|
427 |
iHandlePointerCandidate = EFalse; |
|
428 |
// Grid needs to be recreated to proper reinitilize |
|
429 |
// data with new layout values |
|
430 |
TInt selIdx = SelectedIndex(); |
|
431 |
TRAPD(err, |
|
432 |
LayoutGridL(); |
|
433 |
LayoutGridViewL( iArray.Count() ); |
|
434 |
iEvtHandler.ReInitPhysicsL( GridWorldSize(), ViewSize(), ETrue ); |
|
435 |
); |
|
436 |
||
437 |
if ( err != KErrNone ) |
|
438 |
{ |
|
439 |
TSLOG1( TSLOG_INFO, "LayoutGridL leaves with %d", err ); |
|
440 |
} |
|
441 |
||
442 |
// Update grid view |
|
443 |
iGrid->SetCurrentDataIndex(selIdx); |
|
444 |
UpdateGrid(ETrue, EFalse); |
|
445 |
iGrid->DrawDeferred(); |
|
446 |
||
447 |
// Order full redraw after switch |
|
448 |
if(iRedrawTimer) |
|
449 |
{ |
|
450 |
iRedrawTimer->Cancel(); |
|
451 |
iRedrawTimer->After(KRedrawTimeForLayoutSwitch); |
|
452 |
} |
|
453 |
} |
|
454 |
||
455 |
TSLOG_OUT(); |
|
456 |
} |
|
457 |
||
458 |
// ----------------------------------------------------------------------------- |
|
459 |
// CTsFastSwapArea::Draw |
|
460 |
// ----------------------------------------------------------------------------- |
|
461 |
// |
|
462 |
void CTsFastSwapArea::Draw( const TRect& /*aRect*/ ) const |
|
463 |
{ |
|
464 |
// CWindowGc& gc = SystemGc(); |
|
465 |
// MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
466 |
// MAknsControlContext* cc = AknsDrawUtils::ControlContext( this ); |
|
467 |
// AknsDrawUtils::Background( skin, |
|
468 |
// cc, |
|
469 |
// this, |
|
470 |
// gc, |
|
471 |
// Rect() ); |
|
472 |
} |
|
473 |
||
474 |
// -------------------------------------------------------------------------- |
|
475 |
// CTsFastSwapArea::SwitchToApp |
|
476 |
// -------------------------------------------------------------------------- |
|
477 |
// |
|
478 |
void CTsFastSwapArea::SwitchToApp( TInt aIndex ) |
|
479 |
{ |
|
480 |
if ( aIndex >= 0 && aIndex < iArray.Count() ) |
|
481 |
{ |
|
482 |
TInt wgId = iArray[aIndex]->WgId(); |
|
483 |
TUid appUid = iArray[aIndex]->AppUid(); |
|
484 |
SwitchToApp( wgId, appUid ); |
|
485 |
} |
|
486 |
} |
|
487 |
||
488 |
// -------------------------------------------------------------------------- |
|
489 |
// CTsFastSwapArea::SwitchToApp |
|
490 |
// -------------------------------------------------------------------------- |
|
491 |
// |
|
492 |
void CTsFastSwapArea::SwitchToApp( const TUid& aUid ) |
|
493 |
{ |
|
494 |
TApaTaskList taskList( iEikonEnv->WsSession() ); |
|
495 |
TApaTask task = taskList.FindApp( aUid ); |
|
496 |
TInt wgId = task.WgId(); |
|
497 |
SwitchToApp( wgId, aUid ); |
|
498 |
} |
|
499 |
||
500 |
||
501 |
// -------------------------------------------------------------------------- |
|
502 |
// CTsFastSwapArea::SwitchToApp |
|
503 |
// -------------------------------------------------------------------------- |
|
504 |
// |
|
505 |
void CTsFastSwapArea::SwitchToApp( TInt aWgId, const TUid& aUid ) |
|
506 |
{ |
|
507 |
CTsAppUi* appui = |
|
508 |
static_cast<CTsAppUi*>( iEikonEnv->AppUi() ); |
|
509 |
TBool effectsEnabled = appui->EffectsEnabled(); |
|
510 |
||
511 |
// Move other app to foreground |
|
512 |
if ( !effectsEnabled ) |
|
513 |
{ |
|
514 |
iFSClient->SwitchToApp( aWgId ); |
|
515 |
} |
|
516 |
||
517 |
// We do not want to come back to ts if the activated app is closed. |
|
518 |
// Therefore ts must be moved to background. Ignore orientation updates, it |
|
519 |
// will be done after task switcher is sent to background |
|
520 |
iIgnoreLayoutSwitch = ETrue; |
|
521 |
appui->MoveAppToBackground( CTsAppUi::EActivationTransition, aUid, aWgId ); |
|
522 |
iIgnoreLayoutSwitch = EFalse; |
|
523 |
||
524 |
// Move other app to foreground |
|
525 |
if ( effectsEnabled ) |
|
526 |
{ |
|
527 |
iFSClient->SwitchToApp( aWgId ); |
|
528 |
} |
|
529 |
||
530 |
// Orientation update |
|
531 |
iPrevScreenOrientation = -1; // force orientation reinit |
|
532 |
iOrientationSignalTimer->Cancel(); |
|
533 |
iOrientationSignalTimer->After(KOrientationSwitchTime); |
|
534 |
} |
|
535 |
||
536 |
// -------------------------------------------------------------------------- |
|
537 |
// CTsFastSwapArea::TryCloseAppL |
|
538 |
// -------------------------------------------------------------------------- |
|
539 |
// |
|
540 |
void CTsFastSwapArea::TryCloseAppL( TInt aIndex, |
|
541 |
TBool aSuppressRendering ) |
|
542 |
{ |
|
543 |
TSLOG_CONTEXT( TryCloseAppL, TSLOG_LOCAL ); |
|
544 |
TSLOG2_IN( "%d %d", aIndex, aSuppressRendering ); |
|
545 |
||
546 |
if ( aIndex >= 0 && aIndex < iArray.Count() && CanClose( aIndex ) ) |
|
547 |
{ |
|
548 |
TInt wgId = iArray[aIndex]->WgId(); |
|
549 |
iFSClient->CloseApp( wgId ); |
|
550 |
iIsClosing.Append(wgId); |
|
551 |
if ( iArray[aIndex]->Widget() ) |
|
552 |
{ |
|
553 |
iWidgetClosingCount++; |
|
554 |
} |
|
555 |
||
556 |
// Orientation update |
|
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
557 |
iPrevScreenOrientation = GetCurrentScreenOrientation(); |
83 | 558 |
iOrientationSignalTimer->Cancel(); |
559 |
iOrientationSignalTimer->After(KOrientationSwitchTime); |
|
560 |
} |
|
561 |
||
562 |
TSLOG_OUT(); |
|
563 |
} |
|
564 |
||
565 |
// -------------------------------------------------------------------------- |
|
566 |
// CTsFastSwapArea::TryCloseAllL |
|
567 |
// -------------------------------------------------------------------------- |
|
568 |
// |
|
569 |
void CTsFastSwapArea::TryCloseAllL() |
|
570 |
{ |
|
571 |
for ( TInt i = iArray.Count() - 1; i >= 0; --i ) |
|
572 |
{ |
|
573 |
if ( CanClose( i ) ) |
|
574 |
{ |
|
575 |
TryCloseAppL( i, ETrue ); |
|
576 |
} |
|
577 |
} |
|
578 |
} |
|
579 |
||
580 |
// -------------------------------------------------------------------------- |
|
581 |
// CTsFastSwapArea::CanClose |
|
582 |
// -------------------------------------------------------------------------- |
|
583 |
// |
|
584 |
TBool CTsFastSwapArea::CanClose( TInt aIndex ) const |
|
585 |
{ |
|
586 |
TBool canClose(EFalse); |
|
587 |
if ( aIndex >= 0 && aIndex < iArray.Count() ) |
|
588 |
{ |
|
589 |
CTsFswEntry* e = iArray[aIndex]; |
|
590 |
canClose = !e->AlwaysShown() && !e->SystemApp(); |
|
591 |
// Special cases: Menu |
|
592 |
canClose |= e->AppUid() == KTsMenuUid; |
|
593 |
} |
|
594 |
return canClose; |
|
595 |
} |
|
596 |
||
597 |
// -------------------------------------------------------------------------- |
|
598 |
// CTsFastSwapArea::CanCloseOthers |
|
599 |
// -------------------------------------------------------------------------- |
|
600 |
// |
|
601 |
TBool CTsFastSwapArea::CanCloseAll( TInt aSelectedItem ) const |
|
602 |
{ |
|
603 |
TInt count( 0 ); |
|
604 |
||
605 |
// Count number of closable applications and if number exceeds 2 finish |
|
606 |
// counting, because it is already enough to show the option. |
|
607 |
for ( TInt i = iArray.Count(); --i >= 0 && count < KTsMaxClosableApps; ) |
|
608 |
{ |
|
609 |
if ( CanClose( i ) ) |
|
610 |
{ |
|
611 |
count++; |
|
612 |
} |
|
613 |
} |
|
614 |
return ( count >= KTsMaxClosableApps ) || |
|
615 |
( count && !CanClose( aSelectedItem ) ); |
|
616 |
} |
|
617 |
||
618 |
// -------------------------------------------------------------------------- |
|
619 |
// CTsFastSwapArea::HandleFswContentChanged |
|
620 |
// From MTsFswObserver |
|
621 |
// -------------------------------------------------------------------------- |
|
622 |
// |
|
623 |
void CTsFastSwapArea::HandleFswContentChanged() |
|
624 |
{ |
|
625 |
TSLOG_CONTEXT( HandleFswContentChanged, TSLOG_LOCAL ); |
|
626 |
TSLOG_IN(); |
|
627 |
||
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
628 |
TRAPD( err, HandleFswContentChangedL() ); |
83 | 629 |
if ( err != KErrNone ) |
630 |
{ |
|
631 |
TSLOG1( TSLOG_INFO, "leave occured: %d", err ); |
|
632 |
} |
|
633 |
||
634 |
TSLOG_OUT(); |
|
635 |
} |
|
636 |
||
637 |
// -------------------------------------------------------------------------- |
|
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
638 |
// CTsFastSwapArea::HandleFswContentChangedL |
83 | 639 |
// -------------------------------------------------------------------------- |
640 |
// |
|
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
641 |
void CTsFastSwapArea::HandleFswContentChangedL() |
83 | 642 |
{ |
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
643 |
TSLOG_CONTEXT( HandleFswContentChangedL, TSLOG_LOCAL ); |
83 | 644 |
TSLOG_IN(); |
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
645 |
|
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
646 |
// get current content from fastswap server |
83 | 647 |
iFSClient->GetContentL( iArray ); |
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
648 |
|
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
649 |
#ifdef _DEBUG |
83 | 650 |
for ( TInt i = 0, ie = iArray.Count(); i != ie; ++i ) |
651 |
{ |
|
652 |
CTsFswEntry* e = iArray[i]; |
|
653 |
const TDesC& name( e->AppName() ); |
|
654 |
TSLOG4( TSLOG_INFO, "[%d]: %d %d %S", i, e->WgId(), e->AppUid(), &name ); |
|
655 |
} |
|
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
656 |
#endif |
83 | 657 |
|
658 |
// Update closing widget count if necessary |
|
659 |
if ( iWidgetClosingCount ) |
|
660 |
{ |
|
661 |
TInt widgetCount(0); |
|
662 |
for ( TInt i = 0, ie = iArray.Count(); i != ie; ++i ) |
|
663 |
{ |
|
664 |
if ( iArray[i]->Widget() ) |
|
665 |
{ |
|
666 |
widgetCount++; |
|
667 |
} |
|
668 |
} |
|
669 |
iWidgetClosingCount = widgetCount; |
|
670 |
} |
|
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
671 |
|
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
672 |
// draw |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
673 |
RenderContentL(); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
674 |
|
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
675 |
// notify observer, if present |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
676 |
NotifyChange(); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
677 |
|
83 | 678 |
TSLOG_OUT(); |
679 |
} |
|
680 |
||
681 |
// -------------------------------------------------------------------------- |
|
682 |
// CTsFastSwapArea::RenderContentL |
|
683 |
// -------------------------------------------------------------------------- |
|
684 |
// |
|
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
685 |
void CTsFastSwapArea::RenderContentL( TBool aSuppressAnimation ) |
83 | 686 |
{ |
687 |
TSLOG_CONTEXT( RenderContentL, TSLOG_LOCAL ); |
|
688 |
TSLOG_IN(); |
|
689 |
||
690 |
_LIT(KSeparator, "\t"); |
|
691 |
||
692 |
CArrayPtr<CGulIcon>* iconArray = new ( ELeave ) CAknIconArray( KMaxGranularity ); |
|
693 |
CleanupStack::PushL( iconArray ); |
|
694 |
CDesCArrayFlat* textArray = new ( ELeave ) CDesCArrayFlat( KMaxGranularity ); |
|
695 |
CleanupStack::PushL( textArray ); |
|
696 |
RArray<TInt> closeItemArray; |
|
697 |
CleanupClosePushL(closeItemArray); |
|
698 |
RArray<TInt> strokeItemArray; |
|
699 |
CleanupClosePushL(strokeItemArray); |
|
700 |
||
701 |
// Update view based on number of items |
|
702 |
LayoutGridViewL( iArray.Count() ); |
|
703 |
||
704 |
for ( TInt i = 0; i < iArray.Count(); ++i ) |
|
705 |
{ |
|
706 |
const TDesC& appName( iArray[i]->AppName() ); |
|
707 |
const TInt formatLen = 3 + 2; |
|
708 |
RBuf formAppName; |
|
709 |
CleanupClosePushL(formAppName); |
|
710 |
formAppName.CreateL(appName.Length() + formatLen); |
|
711 |
formAppName.AppendNum(i); |
|
712 |
formAppName.Append(KSeparator); |
|
713 |
formAppName.Append(appName); |
|
714 |
textArray->AppendL(formAppName); |
|
715 |
CleanupStack::PopAndDestroy(&formAppName); |
|
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
716 |
TSize sz = PreferredImageSize(); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
717 |
|
83 | 718 |
// take the screenshot or appicon+mask and make a copy and scale |
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
719 |
CFbsBitmap* bitmap = 0; |
83 | 720 |
TInt h = iArray[i]->ScreenshotHandle(); |
721 |
TSLOG2( TSLOG_INFO, "'%S' screenshot handle %d", &appName, h ); |
|
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
722 |
TInt maskh = 0; |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
723 |
CFbsBitmap* mask = 0; |
83 | 724 |
if ( !h ) |
725 |
{ |
|
726 |
// No screenshot, take app icon |
|
727 |
h = iArray[i]->AppIconBitmapHandle(); |
|
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
728 |
maskh = iArray[i]->AppIconMaskHandle(); |
83 | 729 |
TSLOG1( TSLOG_INFO, "using appicon, handle = %d", h ); |
730 |
} |
|
731 |
else |
|
732 |
{ |
|
733 |
// Screenshot exists, mark it for stroke |
|
734 |
strokeItemArray.AppendL(i); |
|
735 |
} |
|
736 |
__ASSERT_DEBUG( h, User::Invariant() ); |
|
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
737 |
bitmap = CopyBitmapL( h, sz ); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
738 |
CleanupStack::PushL( bitmap ); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
739 |
if ( maskh ) |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
740 |
{ |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
741 |
mask = CopyBitmapL( maskh, sz ); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
742 |
} |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
743 |
CleanupStack::PushL( mask ); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
744 |
|
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
745 |
CGulIcon* icon = CGulIcon::NewL( bitmap, mask ); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
746 |
CleanupStack::PushL(icon); |
93
b01126ce0bec
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
747 |
iconArray->AppendL(icon); |
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
748 |
CleanupStack::Pop( 3, bitmap ); // mask, bitmap, icon |
93
b01126ce0bec
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
749 |
|
83 | 750 |
// Check if item can be closed |
751 |
if ( CanClose(i) && AknLayoutUtils::PenEnabled() ) |
|
752 |
{ |
|
753 |
closeItemArray.AppendL(i); |
|
754 |
} |
|
755 |
} |
|
756 |
// Setup grid |
|
757 |
iGrid->Model()->SetItemTextArray(textArray); |
|
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
758 |
CArrayPtr<CGulIcon>* oldIconArray = |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
759 |
iGrid->ItemDrawer()->FormattedCellData()->IconArray(); |
83 | 760 |
if(oldIconArray) |
761 |
{ |
|
762 |
delete oldIconArray; |
|
763 |
oldIconArray = NULL; |
|
764 |
} |
|
765 |
iGrid->ItemDrawer()->FormattedCellData()->SetIconArrayL(iconArray); |
|
766 |
iGrid->SetCloseItemsL(closeItemArray); |
|
767 |
iGrid->SetStrokeItemsL(strokeItemArray); |
|
768 |
||
769 |
// Update scrollbar visibility |
|
770 |
if( iGrid->ScrollBarFrame() ) |
|
771 |
{ |
|
772 |
iGrid->SetScrollBarFrame(NULL,CEikListBox::EOwnedExternally); |
|
773 |
} |
|
774 |
||
775 |
// Cleanup |
|
776 |
CleanupStack::PopAndDestroy(&strokeItemArray); |
|
777 |
CleanupStack::PopAndDestroy(&closeItemArray); |
|
778 |
CleanupStack::Pop(textArray); |
|
779 |
CleanupStack::Pop(iconArray); |
|
780 |
||
781 |
// refresh the items in the grid |
|
782 |
iGrid->HandleItemAdditionL(); |
|
783 |
iEvtHandler.ReInitPhysicsL( GridWorldSize(), ViewSize(), ETrue ); |
|
784 |
if ( SelectedIndex() >= GridItemCount() && GridItemCount() ) |
|
785 |
{ |
|
786 |
iGrid->SetCurrentDataIndex( GridItemCount() - 1 ); |
|
787 |
} |
|
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
788 |
UpdateGrid( ETrue, !aSuppressAnimation ); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
789 |
|
83 | 790 |
TSLOG_OUT(); |
791 |
} |
|
792 |
||
93
b01126ce0bec
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
793 |
// -------------------------------------------------------------------------- |
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
794 |
// CTsFastSwapArea::CopyBitmapL |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
795 |
// Copy and scale. |
93
b01126ce0bec
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
796 |
// -------------------------------------------------------------------------- |
b01126ce0bec
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
797 |
// |
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
798 |
CFbsBitmap* CTsFastSwapArea::CopyBitmapL( TInt aFbsHandle, TSize aSize ) |
93
b01126ce0bec
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
799 |
{ |
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
800 |
CFbsBitmap* ret = new (ELeave) CFbsBitmap(); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
801 |
CleanupStack::PushL( ret ); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
802 |
|
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
803 |
CFbsBitmap* bmp = new (ELeave) CFbsBitmap(); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
804 |
CleanupStack::PushL( bmp ); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
805 |
User::LeaveIfError( bmp->Duplicate( aFbsHandle ) ); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
806 |
|
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
807 |
// do not always use aSize, preserving the aspect ratio is quite |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
808 |
// important when showing app icons instead of screenshots |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
809 |
TSize sz = CalculateSizePreserveRatio( aSize, bmp->SizeInPixels() ); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
810 |
User::LeaveIfError( ret->Create( sz, bmp->DisplayMode() ) ); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
811 |
|
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
812 |
AknIconUtils::ScaleBitmapL( sz, ret, bmp ); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
813 |
|
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
814 |
CleanupStack::PopAndDestroy( bmp ); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
815 |
CleanupStack::Pop( ret ); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
816 |
|
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
817 |
return ret; |
93
b01126ce0bec
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
818 |
} |
b01126ce0bec
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
819 |
|
83 | 820 |
// -------------------------------------------------------------------------- |
821 |
// CTsFastSwapArea::CountComponentControls |
|
822 |
// -------------------------------------------------------------------------- |
|
823 |
// |
|
824 |
TInt CTsFastSwapArea::CountComponentControls() const |
|
825 |
{ |
|
826 |
return 1; |
|
827 |
} |
|
828 |
||
829 |
// -------------------------------------------------------------------------- |
|
830 |
// CTsFastSwapArea::ComponentControl |
|
831 |
// -------------------------------------------------------------------------- |
|
832 |
// |
|
833 |
CCoeControl* CTsFastSwapArea::ComponentControl( TInt aIndex ) const |
|
834 |
{ |
|
835 |
if ( aIndex == 0 ) |
|
836 |
{ |
|
837 |
return iGrid; |
|
838 |
} |
|
839 |
return NULL; |
|
840 |
} |
|
841 |
||
842 |
// ----------------------------------------------------------------------------- |
|
843 |
// CTsFastSwapArea::HandleSwitchToBackgroundEvent |
|
844 |
// ----------------------------------------------------------------------------- |
|
845 |
// |
|
846 |
void CTsFastSwapArea::HandleSwitchToBackgroundEvent() |
|
847 |
{ |
|
848 |
// stop listening for changes in fsw content |
|
849 |
iFSClient->CancelSubscribe(); |
|
850 |
// Hide highlight |
|
851 |
if ( iGrid->GridBehaviour() == CTsFastSwapGrid::ETouchOnly ) |
|
852 |
{ |
|
853 |
iGrid->HideHighlight(); |
|
854 |
} |
|
855 |
CancelLongTapAnimation(); |
|
856 |
iGrid->MakeVisible(EFalse); |
|
857 |
iGrid->DrawNow(); |
|
858 |
} |
|
859 |
||
860 |
// ----------------------------------------------------------------------------- |
|
861 |
// CTsFastSwapArea::HandleSwitchToForegroundEvent |
|
862 |
// ----------------------------------------------------------------------------- |
|
863 |
// |
|
864 |
void CTsFastSwapArea::HandleSwitchToForegroundEvent() |
|
865 |
{ |
|
866 |
TSLOG_CONTEXT( CTsFastSwapArea::HandleSwitchToForegroundEvent, TSLOG_LOCAL ); |
|
867 |
TSLOG_IN(); |
|
868 |
||
869 |
iIsClosing.Reset(); |
|
870 |
iWidgetClosingCount = 0; |
|
871 |
iHandlePointerCandidate = EFalse; |
|
872 |
||
873 |
CTsGridItemDrawer* itemDrawer = |
|
874 |
static_cast<CTsGridItemDrawer*>( iGrid->ItemDrawer() ); |
|
875 |
itemDrawer->SetRedrawBackground(ETrue); |
|
876 |
||
877 |
// Update Layout |
|
878 |
CTsAppUi* appUi = static_cast<CTsAppUi*>(iEikonEnv->AppUi()); |
|
879 |
if ( appUi && appUi->EffectsEnabled() ) |
|
880 |
{ |
|
881 |
TRAP_IGNORE( LayoutGridL() ); |
|
882 |
} |
|
883 |
||
884 |
// Reset grid |
|
885 |
if ( iDeviceState.DeviceType() == CTsDeviceState::EFullTouch ) |
|
886 |
{ |
|
887 |
iGrid->HideHighlight(); |
|
888 |
} |
|
889 |
else |
|
890 |
{ |
|
891 |
iGrid->ShowHighlight(); |
|
892 |
} |
|
893 |
||
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
894 |
// get the current task list |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
895 |
HandleFswContentChanged(); |
83 | 896 |
// and then start listening for changes |
897 |
iFSClient->Subscribe( *this ); |
|
898 |
||
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
899 |
RestoreSelectedIndex(); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
900 |
UpdateGrid(EFalse, EFalse); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
901 |
|
83 | 902 |
iRedrawTimer->Cancel(); |
903 |
iRedrawTimer->After(KRedrawTime); |
|
904 |
||
905 |
// give feedback |
|
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
906 |
LaunchPopupFeedback(); |
83 | 907 |
|
908 |
iPrevAppCount = iArray.Count(); |
|
909 |
||
910 |
if ( !appUi->DelayedForegroundLaunched() ) |
|
911 |
{ |
|
912 |
iGrid->MakeVisible(ETrue); |
|
913 |
} |
|
914 |
||
915 |
TSLOG_OUT(); |
|
916 |
} |
|
917 |
||
918 |
// ----------------------------------------------------------------------------- |
|
919 |
// CTsFastSwapArea::FocusChanged |
|
920 |
// ----------------------------------------------------------------------------- |
|
921 |
// |
|
922 |
void CTsFastSwapArea::FocusChanged( TDrawNow /*aDrawNow*/ ) |
|
923 |
{ |
|
924 |
if ( IsFocused() ) |
|
925 |
{ |
|
926 |
// if in non-touch mode then select (highlight) some item |
|
927 |
if ( !AknLayoutUtils::PenEnabled() |
|
928 |
&& SelectedIndex() == KErrNotFound |
|
929 |
&& GridItemCount() ) |
|
930 |
{ |
|
931 |
RestoreSelectedIndex(); |
|
932 |
} |
|
933 |
} |
|
934 |
else |
|
935 |
{ |
|
936 |
// store the currently selected index if there is one |
|
937 |
SaveSelectedIndex(); |
|
938 |
} |
|
939 |
} |
|
940 |
||
941 |
// ----------------------------------------------------------------------------- |
|
942 |
// CTsFastSwapArea::OfferKeyEventL |
|
943 |
// ----------------------------------------------------------------------------- |
|
944 |
// |
|
945 |
TKeyResponse CTsFastSwapArea::OfferKeyEventL( |
|
946 |
const TKeyEvent& aKeyEvent, |
|
947 |
TEventCode aType ) |
|
948 |
{ |
|
949 |
CancelLongTapAnimation(); |
|
950 |
||
951 |
iKeyEvent = ETrue; |
|
952 |
||
953 |
//do not forward the event until item is higlighted |
|
954 |
TKeyResponse response = ShowHighlightOnKeyEvent(aKeyEvent, aType); |
|
955 |
if( response == EKeyWasConsumed ) |
|
956 |
{ |
|
957 |
return EKeyWasConsumed; |
|
958 |
} |
|
959 |
||
960 |
// handle the 'clear' key |
|
961 |
if ( aType == EEventKey && aKeyEvent.iCode == EKeyBackspace ) |
|
962 |
{ |
|
963 |
TInt idx = SelectedIndex(); |
|
964 |
if ( idx >= 0 ) |
|
965 |
{ |
|
966 |
TryCloseAppL( idx ); |
|
967 |
} |
|
968 |
return EKeyWasConsumed; |
|
969 |
} |
|
970 |
||
971 |
// pass the event to grid |
|
972 |
// do not pass down and up arrow key events |
|
973 |
if ( aKeyEvent.iScanCode != EStdKeyUpArrow && |
|
974 |
aKeyEvent.iScanCode != EStdKeyDownArrow && |
|
975 |
aKeyEvent.iScanCode != EStdKeyApplication0 ) |
|
976 |
{ |
|
977 |
TBool animate(ETrue); |
|
978 |
TBool redraw(EFalse); |
|
979 |
TInt prevItem = SelectedIndex(); |
|
980 |
TKeyResponse response = iGrid->OfferKeyEventL( aKeyEvent, aType ); |
|
981 |
if ( prevItem != SelectedIndex() && // item changed |
|
982 |
( ( prevItem == 0 && |
|
983 |
SelectedIndex() == GridItemCount() - 1 && |
|
984 |
GridItemCount() > iMaxItemsOnScreen + 1 ) || // loop from first to last item |
|
985 |
( prevItem == GridItemCount() - 1 && |
|
986 |
SelectedIndex() == 0 && |
|
987 |
GridItemCount() > iMaxItemsOnScreen + 1) // loop from last to first item |
|
988 |
) // loop |
|
989 |
) |
|
990 |
{ |
|
991 |
// Loop occured |
|
992 |
animate = EFalse; |
|
993 |
} |
|
994 |
if ( prevItem != SelectedIndex() ) |
|
995 |
{ |
|
996 |
redraw = ETrue; |
|
997 |
iGrid->ShowHighlight(); |
|
998 |
} |
|
999 |
UpdateGrid( redraw, animate ); |
|
1000 |
return response; |
|
1001 |
} |
|
1002 |
||
1003 |
return EKeyWasNotConsumed; |
|
1004 |
} |
|
1005 |
||
1006 |
// ----------------------------------------------------------------------------- |
|
1007 |
// CTsFastSwapArea::CatchKeyEvent |
|
1008 |
// ----------------------------------------------------------------------------- |
|
1009 |
// |
|
1010 |
TKeyResponse CTsFastSwapArea::ShowHighlightOnKeyEvent( |
|
1011 |
const TKeyEvent& aKeyEvent, TEventCode aType) |
|
1012 |
{ |
|
1013 |
TKeyResponse retVal(EKeyWasNotConsumed); |
|
1014 |
||
1015 |
if (aKeyEvent.iScanCode == EStdKeyLeftArrow || |
|
1016 |
aKeyEvent.iScanCode == EStdKeyRightArrow || |
|
1017 |
aKeyEvent.iScanCode == EStdKeyDevice3 || |
|
1018 |
aKeyEvent.iScanCode == EStdKeyBackspace || |
|
1019 |
aKeyEvent.iScanCode == EStdKeyEnter ) |
|
1020 |
{ |
|
1021 |
if (!iGrid->IsHighlightVisible()) |
|
1022 |
{ |
|
1023 |
if (aType == EEventKey) |
|
1024 |
{ |
|
1025 |
iGrid->ShowHighlight(); |
|
1026 |
iConsumeEvent = ETrue; |
|
1027 |
} |
|
1028 |
retVal = EKeyWasConsumed; |
|
1029 |
} |
|
1030 |
else if (iConsumeEvent) |
|
1031 |
{ |
|
1032 |
if (aType == EEventKeyUp) |
|
1033 |
{ |
|
1034 |
retVal = EKeyWasConsumed; |
|
1035 |
} |
|
1036 |
else |
|
1037 |
{ |
|
1038 |
iConsumeEvent = EFalse; |
|
1039 |
} |
|
1040 |
} |
|
1041 |
} |
|
1042 |
return retVal; |
|
1043 |
} |
|
1044 |
||
1045 |
||
1046 |
// ----------------------------------------------------------------------------- |
|
1047 |
// CTsFastSwapArea::HandlePointerEventL |
|
1048 |
// ----------------------------------------------------------------------------- |
|
1049 |
// |
|
1050 |
void CTsFastSwapArea::HandlePointerEventL( const TPointerEvent& aPointerEvent ) |
|
1051 |
{ |
|
1052 |
iKeyEvent = EFalse; |
|
1053 |
if(aPointerEvent.iType == TPointerEvent::EButton1Down) |
|
1054 |
{ |
|
1055 |
iHandlePointerCandidate = ETrue; |
|
1056 |
iTapEvent = aPointerEvent; |
|
1057 |
iGrid->EnableAknEventHandling(EFalse); |
|
1058 |
iGrid->HandlePointerEventL(aPointerEvent); |
|
1059 |
iGrid->EnableAknEventHandling(ETrue); |
|
1060 |
// Check if long tap animation should be launched |
|
1061 |
if ( LongTapAnimForPos(aPointerEvent.iParentPosition) ) |
|
1062 |
{ |
|
1063 |
iLongTapAnimationTimer->Cancel(); |
|
1064 |
iLongTapAnimationTimer->After(KLongTapAnimationInitTime); |
|
1065 |
} |
|
1066 |
} |
|
1067 |
else if ( aPointerEvent.iType == TPointerEvent::EButton1Up ) |
|
1068 |
{ |
|
1069 |
CancelLongTapAnimation( EFalse ); |
|
93
b01126ce0bec
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
1070 |
if( iActivateOnPointerRelease != TPoint() ) |
83 | 1071 |
{ |
1072 |
iHandlePointerCandidate = ETrue; |
|
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1073 |
TapL(iActivateOnPointerRelease); |
83 | 1074 |
iActivateOnPointerRelease = TPoint(); |
1075 |
} |
|
1076 |
} |
|
1077 |
} |
|
1078 |
||
1079 |
// ----------------------------------------------------------------------------- |
|
1080 |
// CTsFastSwapArea::SelectedIndex |
|
1081 |
// ----------------------------------------------------------------------------- |
|
1082 |
// |
|
1083 |
TInt CTsFastSwapArea::SelectedIndex() const |
|
1084 |
{ |
|
1085 |
return iGrid->CurrentDataIndex(); |
|
1086 |
} |
|
1087 |
||
1088 |
// ----------------------------------------------------------------------------- |
|
1089 |
// CTsFastSwapArea::SaveSelectedIndex |
|
1090 |
// ----------------------------------------------------------------------------- |
|
1091 |
// |
|
1092 |
void CTsFastSwapArea::SaveSelectedIndex() |
|
1093 |
{ |
|
1094 |
iSavedSelectedIndex = SelectedIndex(); |
|
1095 |
} |
|
1096 |
||
1097 |
// ----------------------------------------------------------------------------- |
|
1098 |
// CTsFastSwapArea::RestoreSelectedIndex |
|
1099 |
// ----------------------------------------------------------------------------- |
|
1100 |
// |
|
1101 |
void CTsFastSwapArea::RestoreSelectedIndex() |
|
1102 |
{ |
|
1103 |
iSavedSelectedIndex = KErrNotFound; |
|
1104 |
if ( GridItemCount() ) |
|
1105 |
{ |
|
1106 |
// highlight second recent item (that has index 1) if possible |
|
1107 |
TInt highlightItem = 0; |
|
1108 |
TInt count = GridItemCount(); |
|
1109 |
while( highlightItem < count |
|
1110 |
&& highlightItem < KItemToHighlight ) |
|
1111 |
{ |
|
1112 |
++highlightItem; |
|
1113 |
} |
|
1114 |
iSavedSelectedIndex = highlightItem - 1;//count from 0 |
|
1115 |
iGrid->SetCurrentDataIndex( iSavedSelectedIndex ); |
|
1116 |
} |
|
1117 |
} |
|
1118 |
||
1119 |
// ----------------------------------------------------------------------------- |
|
1120 |
// CTsFastSwapArea::ProcessCommandL |
|
1121 |
// Handle fsw popup commands |
|
1122 |
// ----------------------------------------------------------------------------- |
|
1123 |
// |
|
1124 |
void CTsFastSwapArea::ProcessCommandL( TInt aCommandId ) |
|
1125 |
{ |
|
1126 |
static_cast<CTsAppUi*>(iEikonEnv->AppUi())->DisablePopUpL(); |
|
1127 |
switch ( aCommandId ) |
|
1128 |
{ |
|
1129 |
case EFswCmdClose: |
|
1130 |
TryCloseAppL( iAppIndexForPopup ); |
|
1131 |
break; |
|
1132 |
||
1133 |
case EFswCmdCloseAll: |
|
1134 |
TryCloseAllL(); |
|
1135 |
break; |
|
1136 |
||
1137 |
case KErrCancel: |
|
1138 |
// popup dismisses automatically when tapping outside or when switching to other app |
|
1139 |
break; |
|
1140 |
} |
|
1141 |
} |
|
1142 |
||
1143 |
||
1144 |
// ----------------------------------------------------------------------------- |
|
1145 |
// CTsFastSwapArea::HandleCloseEventL |
|
1146 |
// ----------------------------------------------------------------------------- |
|
1147 |
// |
|
1148 |
void CTsFastSwapArea::HandleCloseEventL(TInt aItemIdx) |
|
1149 |
{ |
|
1150 |
TryCloseAppL( aItemIdx ); |
|
1151 |
} |
|
1152 |
||
1153 |
||
1154 |
// ----------------------------------------------------------------------------- |
|
1155 |
// CTsFastSwapArea::HandleDeviceStateChanged |
|
1156 |
// ----------------------------------------------------------------------------- |
|
1157 |
// |
|
1158 |
void CTsFastSwapArea::HandleDeviceStateChanged( TChangeType aChangeType ) |
|
1159 |
{ |
|
1160 |
if ( aChangeType == EDeviceType ) |
|
1161 |
{ |
|
1162 |
CTsDeviceState::TDeviceType state = iDeviceState.DeviceType(); |
|
1163 |
switch ( state ) |
|
1164 |
{ |
|
1165 |
case CTsDeviceState::EHybrid: |
|
1166 |
{ |
|
1167 |
iGrid->SetGridBehaviour( CTsFastSwapGrid::EHybrid ); |
|
1168 |
} |
|
1169 |
break; |
|
1170 |
case CTsDeviceState::EFullTouch: |
|
1171 |
{ |
|
1172 |
iGrid->SetGridBehaviour( CTsFastSwapGrid::ETouchOnly ); |
|
1173 |
} |
|
1174 |
break; |
|
1175 |
default: |
|
1176 |
break; |
|
1177 |
} |
|
1178 |
} |
|
1179 |
} |
|
1180 |
||
1181 |
||
1182 |
// ----------------------------------------------------------------------------- |
|
1183 |
// CTsFastSwapArea::TimerCompletedL |
|
1184 |
// ----------------------------------------------------------------------------- |
|
1185 |
// |
|
1186 |
void CTsFastSwapArea::TimerCompletedL( CTsFastSwapTimer* aSource ) |
|
1187 |
{ |
|
1188 |
if(aSource == iHighlightTimer) |
|
1189 |
{ |
|
1190 |
iTapEvent.iType = TPointerEvent::EButton1Up; |
|
1191 |
iGrid->HandlePointerEventL(iTapEvent); |
|
1192 |
} |
|
1193 |
else if(aSource == iRedrawTimer) |
|
1194 |
{ |
|
1195 |
iGrid->MakeVisible(ETrue); |
|
1196 |
static_cast<CTsAppView*>(&iParent)->OrderFullWindowRedraw(); |
|
1197 |
} |
|
1198 |
else if( aSource == iUpdateGridTimer ) |
|
1199 |
{ |
|
1200 |
UpdateGrid(ETrue, ETrue); |
|
1201 |
} |
|
1202 |
else if ( aSource == iOrientationSignalTimer ) |
|
1203 |
{ |
|
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1204 |
TInt currentOrientation = GetCurrentScreenOrientation(); |
83 | 1205 |
if ( currentOrientation != iPrevScreenOrientation ) |
1206 |
{ |
|
1207 |
// Order layout change |
|
1208 |
static_cast<CAknAppUi*>(iCoeEnv->AppUi())->HandleResourceChangeL(KEikDynamicLayoutVariantSwitch); |
|
1209 |
iRedrawTimer->Cancel(); |
|
1210 |
iRedrawTimer->After(KRedrawTime); |
|
1211 |
} |
|
1212 |
} |
|
1213 |
else if ( aSource == iLongTapAnimationTimer ) |
|
1214 |
{ |
|
1215 |
if ( iLongTapAnimationRunning ) |
|
1216 |
{ |
|
1217 |
CancelLongTapAnimation(); |
|
1218 |
} |
|
1219 |
else |
|
1220 |
{ |
|
1221 |
static_cast<CTsAppUi*>(iEikonEnv->AppUi())->RequestPopUpL(); |
|
1222 |
if ( iLongTapAnimation ) |
|
1223 |
{ |
|
1224 |
delete iLongTapAnimation; |
|
1225 |
iLongTapAnimation = NULL; |
|
1226 |
} |
|
1227 |
iLongTapAnimation = CAknLongTapAnimation::NewL(EFalse); |
|
1228 |
iLongTapAnimation->SetParent( this ); |
|
1229 |
iLongTapAnimation->ShowAnimationL( iTapEvent.iParentPosition.iX, |
|
1230 |
iTapEvent.iParentPosition.iY ); |
|
1231 |
iLongTapAnimationRunning = ETrue; |
|
1232 |
iLongTapAnimationTimer->Cancel(); |
|
1233 |
iLongTapAnimationTimer->After(KLongTapAnimationTimeout); |
|
1234 |
} |
|
1235 |
} |
|
1236 |
} |
|
1237 |
||
1238 |
||
1239 |
// ----------------------------------------------------------------------------- |
|
1240 |
// CTsFastSwapArea::PreCreatePopupL |
|
1241 |
// ----------------------------------------------------------------------------- |
|
1242 |
// |
|
1243 |
void CTsFastSwapArea::PreCreatePopupL() |
|
1244 |
{ |
|
1245 |
if ( !iPopup ) |
|
1246 |
{ |
|
1247 |
iPopup = CAknStylusPopUpMenu::NewL( this, Rect().iTl ); |
|
1248 |
HBufC* text = StringLoader::LoadLC( R_TS_FSW_CLOSE ); |
|
1249 |
iPopup->AddMenuItemL( *text, EFswCmdClose ); |
|
1250 |
CleanupStack::PopAndDestroy( text ); |
|
1251 |
text = StringLoader::LoadLC( R_TS_FSW_CLOSE_ALL ); |
|
1252 |
iPopup->AddMenuItemL( *text, EFswCmdCloseAll ); |
|
1253 |
CleanupStack::PopAndDestroy( text ); |
|
1254 |
} |
|
1255 |
} |
|
1256 |
||
1257 |
// ----------------------------------------------------------------------------- |
|
1258 |
// CTsFastSwapArea::ShowPopupL |
|
1259 |
// ----------------------------------------------------------------------------- |
|
1260 |
// |
|
1261 |
TBool CTsFastSwapArea::ShowPopupL( TInt aIndex, const TPoint& aPoint ) |
|
1262 |
{ |
|
1263 |
TBool showPopUp(EFalse); |
|
1264 |
TBool showPopupItem; |
|
1265 |
// hide 'close' if app cannot be closed |
|
1266 |
showPopupItem = CanClose( aIndex ); |
|
1267 |
iPopup->SetItemDimmed( EFswCmdClose, !showPopupItem ); |
|
1268 |
showPopUp = showPopUp || showPopupItem; |
|
1269 |
// hide 'close all' if there are no applications to close. |
|
1270 |
showPopupItem = CanCloseAll( aIndex ); |
|
1271 |
iPopup->SetItemDimmed( EFswCmdCloseAll, !showPopupItem ); |
|
1272 |
showPopUp = showPopUp || showPopupItem; |
|
1273 |
||
1274 |
if(showPopUp) |
|
1275 |
{ |
|
1276 |
static_cast<CTsAppUi*>(iEikonEnv->AppUi())->RequestPopUpL(); |
|
1277 |
// give feedback |
|
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1278 |
LaunchPopupFeedback(); |
83 | 1279 |
// save index for later use & show popup |
1280 |
iAppIndexForPopup = aIndex; |
|
1281 |
iPopup->SetPosition( aPoint, CAknStylusPopUpMenu::EPositionTypeLeftBottom ); |
|
1282 |
iPopup->ShowMenu(); |
|
1283 |
} |
|
1284 |
return showPopUp; |
|
1285 |
} |
|
1286 |
||
1287 |
||
1288 |
// ----------------------------------------------------------------------------- |
|
1289 |
// CTsFastSwapArea::Count |
|
1290 |
// ----------------------------------------------------------------------------- |
|
1291 |
// |
|
1292 |
TInt CTsFastSwapArea::Count() const |
|
1293 |
{ |
|
1294 |
return iArray.Count(); |
|
1295 |
} |
|
1296 |
||
1297 |
// ----------------------------------------------------------------------------- |
|
1298 |
// CTsFastSwapArea::SetDataChangeObserver |
|
1299 |
// ----------------------------------------------------------------------------- |
|
1300 |
// |
|
1301 |
void CTsFastSwapArea::SetDataChangeObserver( |
|
1302 |
MTsDataChangeObserver* aDcObserver ) |
|
1303 |
{ |
|
1304 |
iDcObserver = aDcObserver; |
|
1305 |
} |
|
1306 |
||
1307 |
// ----------------------------------------------------------------------------- |
|
1308 |
// CTsFastSwapArea::NotifyChange |
|
1309 |
// ----------------------------------------------------------------------------- |
|
1310 |
// |
|
1311 |
void CTsFastSwapArea::NotifyChange() |
|
1312 |
{ |
|
1313 |
if ( iDcObserver ) |
|
1314 |
{ |
|
1315 |
iDcObserver->DataChanged( this, Count() ); |
|
1316 |
} |
|
1317 |
} |
|
1318 |
||
1319 |
// ----------------------------------------------------------------------------- |
|
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1320 |
// CTsFastSwapArea::PreferredImageSize |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1321 |
// ----------------------------------------------------------------------------- |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1322 |
// |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1323 |
TSize CTsFastSwapArea::PreferredImageSize() |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1324 |
{ |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1325 |
TAknLayoutRect gridImage; |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1326 |
TRAP_IGNORE( |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1327 |
RArray<TAknLayoutRect> rects; |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1328 |
CleanupClosePushL(rects); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1329 |
rects.ReserveL(KLayoutItemCount); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1330 |
GetFastSwapAreaRects(rects); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1331 |
gridImage = rects[2]; |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1332 |
CleanupStack::PopAndDestroy(&rects); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1333 |
); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1334 |
return gridImage.Rect().Size(); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1335 |
} |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1336 |
|
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1337 |
// ----------------------------------------------------------------------------- |
83 | 1338 |
// CTsFastSwapArea::GridItemCount |
1339 |
// ----------------------------------------------------------------------------- |
|
1340 |
// |
|
1341 |
TInt CTsFastSwapArea::GridItemCount() |
|
1342 |
{ |
|
1343 |
return iGrid->Model()->ItemTextArray()->MdcaCount(); |
|
1344 |
} |
|
1345 |
||
1346 |
// ----------------------------------------------------------------------------- |
|
1347 |
// CTsFastSwapArea::HandleListBoxEventL |
|
1348 |
// ----------------------------------------------------------------------------- |
|
1349 |
// |
|
1350 |
void CTsFastSwapArea::HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType) |
|
1351 |
{ |
|
1352 |
if ( aListBox == iGrid ) |
|
1353 |
{ |
|
1354 |
switch ( aEventType ) |
|
1355 |
{ |
|
1356 |
case EEventEnterKeyPressed: |
|
1357 |
case EEventItemClicked: |
|
1358 |
case EEventItemSingleClicked: |
|
1359 |
{ |
|
1360 |
SwitchToApp(SelectedIndex()); |
|
1361 |
} |
|
1362 |
break; |
|
1363 |
case EEventPenDownOnItem: |
|
1364 |
{ |
|
1365 |
iGrid->ShowHighlight(); |
|
1366 |
} |
|
1367 |
break; |
|
1368 |
default: |
|
1369 |
break; |
|
1370 |
} |
|
1371 |
} |
|
1372 |
} |
|
1373 |
||
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1374 |
// -------------------------------------------------------------------------- |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1375 |
// CTsFastSwapArea::CalculateSizePreserveRatio |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1376 |
// -------------------------------------------------------------------------- |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1377 |
// |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1378 |
TSize CTsFastSwapArea::CalculateSizePreserveRatio( |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1379 |
const TSize& aTargetAreaSize, |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1380 |
const TSize& aSourceSize ) |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1381 |
{ |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1382 |
const TReal |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1383 |
resizedAspectRatio(aTargetAreaSize.iWidth/(TReal)aTargetAreaSize.iHeight); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1384 |
const TReal |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1385 |
orginalAspectRatio(aSourceSize.iWidth/(TReal)aSourceSize.iHeight); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1386 |
//this condition avoid empty margins ( bigger output ). to realy fit area change it |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1387 |
const TReal scaleFactor = |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1388 |
( orginalAspectRatio > resizedAspectRatio ) ? |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1389 |
(aTargetAreaSize.iHeight /(TReal)aSourceSize.iHeight) ://scale by height |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1390 |
(aTargetAreaSize.iWidth /(TReal)aSourceSize.iWidth) ;//scale by width |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1391 |
return TSize(aSourceSize.iWidth * scaleFactor, aSourceSize.iHeight * scaleFactor); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1392 |
} |
83 | 1393 |
|
1394 |
// -------------------------------------------------------------------------- |
|
1395 |
// CTsFastSwapArea::SelectNextItem |
|
1396 |
// -------------------------------------------------------------------------- |
|
1397 |
// |
|
1398 |
void CTsFastSwapArea::SelectNextItem() |
|
1399 |
{ |
|
1400 |
iKeyEvent = ETrue; |
|
1401 |
TBool forceRedraw(ETrue); |
|
1402 |
TBool animate(ETrue); |
|
1403 |
TInt selectedItem = SelectedIndex(); |
|
1404 |
selectedItem++; |
|
1405 |
if ( selectedItem == GridItemCount() ) |
|
1406 |
{ |
|
1407 |
// Last item is selected, move to first one |
|
1408 |
selectedItem = 0; |
|
1409 |
animate = EFalse; |
|
1410 |
} |
|
1411 |
iGrid->SetCurrentDataIndex(selectedItem); |
|
1412 |
UpdateGrid(forceRedraw, animate); |
|
1413 |
} |
|
1414 |
||
1415 |
||
1416 |
// -------------------------------------------------------------------------- |
|
1417 |
// CTsFastSwapArea::CenterItem |
|
1418 |
// -------------------------------------------------------------------------- |
|
1419 |
// |
|
1420 |
void CTsFastSwapArea::CenterItem(TInt aRedrawDelay) |
|
1421 |
{ |
|
1422 |
if( iMaxItemsOnScreen < GridItemCount() ) |
|
1423 |
{ |
|
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1424 |
TInt visibleItem = ViewToVisibleItem( ViewPos() ); |
83 | 1425 |
if(iKeyEvent) |
1426 |
{ |
|
1427 |
visibleItem = SelectedIndex(); |
|
1428 |
} |
|
1429 |
if(visibleItem != SelectedIndex()) |
|
1430 |
{ |
|
1431 |
iGrid->SetCurrentDataIndex( visibleItem ); |
|
1432 |
iParent.DrawDeferred(); |
|
1433 |
iGrid->DrawDeferred(); |
|
1434 |
} |
|
1435 |
} |
|
1436 |
||
1437 |
// Check if view is outside of grid world |
|
1438 |
TPoint absViewPos = ViewPos(); |
|
1439 |
absViewPos.iX -= Rect().Width() / 2; |
|
1440 |
if( !iEvtHandler.IsPhysicsRunning() && |
|
1441 |
( absViewPos.iX < 0 ||( absViewPos.iX + Rect().Width() > GridWorldSize().iWidth && GridItemCount() ) ) |
|
1442 |
) |
|
1443 |
{ |
|
1444 |
// View is outside of grid world - update view |
|
1445 |
iUpdateGridTimer->Cancel(); |
|
1446 |
iUpdateGridTimer->After(aRedrawDelay); |
|
1447 |
} |
|
1448 |
} |
|
1449 |
||
1450 |
// -------------------------------------------------------------------------- |
|
1451 |
// CTsFastSwapArea::GridWorldSize |
|
1452 |
// -------------------------------------------------------------------------- |
|
1453 |
// |
|
1454 |
TSize CTsFastSwapArea::GridWorldSize() |
|
1455 |
{ |
|
1456 |
return TSize( GridItemCount() * iGridItemWidth + (GridItemCount() - 1) * iGridItemGap, Rect().Height() ); |
|
1457 |
} |
|
1458 |
||
1459 |
// -------------------------------------------------------------------------- |
|
1460 |
// CTsFastSwapArea::UpdateGrid |
|
1461 |
// -------------------------------------------------------------------------- |
|
1462 |
// |
|
1463 |
void CTsFastSwapArea::UpdateGrid( TBool aForceRedraw, TBool aAnimate ) |
|
1464 |
{ |
|
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1465 |
TPoint targetPoint = ItemViewPosition( SelectedIndex() ); |
83 | 1466 |
if ( aForceRedraw || targetPoint.iX != ViewPos().iX ) |
1467 |
{ |
|
1468 |
if ( aAnimate ) |
|
1469 |
{ |
|
1470 |
iEvtHandler.Animate( targetPoint ); |
|
1471 |
} |
|
1472 |
else |
|
1473 |
{ |
|
1474 |
MoveOffset(targetPoint, ETrue); |
|
1475 |
iEvtHandler.StopAnimation(); |
|
1476 |
} |
|
1477 |
if ( aForceRedraw ) |
|
1478 |
{ |
|
1479 |
iParent.DrawDeferred(); |
|
1480 |
iGrid->DrawNow(); |
|
1481 |
} |
|
1482 |
} |
|
1483 |
} |
|
1484 |
||
1485 |
// -------------------------------------------------------------------------- |
|
1486 |
// CTsFastSwapArea::HandleAppKey |
|
1487 |
// -------------------------------------------------------------------------- |
|
1488 |
// |
|
1489 |
void CTsFastSwapArea::HandleAppKey(TInt aType) |
|
1490 |
{ |
|
1491 |
if ( iArray.Count() ) |
|
1492 |
{ |
|
1493 |
if( aType == KAppKeyTypeShort ) |
|
1494 |
{ |
|
1495 |
//SwitchToApp( KTsHomescreenUid ); |
|
1496 |
TRAP_IGNORE( iEikonEnv->EikAppUi()->HandleCommandL(EAknSoftkeyExit) ); |
|
1497 |
} |
|
1498 |
else if( aType == KAppKeyTypeLong ) |
|
1499 |
{ |
|
1500 |
// Dismiss task switcher |
|
1501 |
TRAP_IGNORE( iEikonEnv->EikAppUi()->HandleCommandL(EAknSoftkeyExit) ); |
|
1502 |
} |
|
1503 |
} |
|
1504 |
else |
|
1505 |
{ |
|
1506 |
TRAP_IGNORE( iEikonEnv->EikAppUi()->HandleCommandL(EAknSoftkeyExit) ); |
|
1507 |
} |
|
1508 |
} |
|
1509 |
||
1510 |
// -------------------------------------------------------------------------- |
|
1511 |
// CTsFastSwapArea::MoveOffset |
|
1512 |
// -------------------------------------------------------------------------- |
|
1513 |
// |
|
1514 |
void CTsFastSwapArea::MoveOffset(const TPoint& aPoint, TBool aDrawNow) |
|
1515 |
{ |
|
1516 |
if( iHandlePointerCandidate ) |
|
1517 |
{ |
|
1518 |
//pointer was pressed and it's being waiting for handling |
|
1519 |
return; |
|
1520 |
} |
|
1521 |
||
1522 |
//postpone center item request in case of being moved |
|
1523 |
if(iUpdateGridTimer->IsActive()) |
|
1524 |
{ |
|
1525 |
iUpdateGridTimer->Cancel(); |
|
1526 |
iUpdateGridTimer->After(KUpdateGridTime); |
|
1527 |
} |
|
1528 |
||
1529 |
if ( aDrawNow ) |
|
1530 |
{ |
|
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1531 |
TInt currentXPos = aPoint.iX; |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1532 |
currentXPos -= Rect().Width() / 2; |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1533 |
TRect gridViewRect = Rect(); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1534 |
gridViewRect.iTl.iX = -currentXPos; |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1535 |
// Take edge offset into account |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1536 |
gridViewRect.iTl.iX += Rect().iTl.iX; |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1537 |
if(GridItemCount() && GridItemCount() <= iMaxItemsOnScreen) |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1538 |
{ |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1539 |
// Center view |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1540 |
gridViewRect.iTl.iX += ( Rect().Width() - GridItemCount() * iGridItemWidth ) / 2; |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1541 |
} |
83 | 1542 |
//iParent.DrawDeferred(); |
1543 |
iGrid->DrawDeferred(); |
|
1544 |
iGrid->SetRect( gridViewRect ); |
|
1545 |
iLogicalViewPosOffset = 0; |
|
1546 |
} |
|
1547 |
else |
|
1548 |
{ |
|
1549 |
// Update logical view position |
|
1550 |
iLogicalViewPosOffset = aPoint.iX - ViewPos().iX; |
|
1551 |
} |
|
1552 |
} |
|
1553 |
||
1554 |
// -------------------------------------------------------------------------- |
|
1555 |
// CTsFastSwapArea::Tap |
|
1556 |
// -------------------------------------------------------------------------- |
|
1557 |
// |
|
1558 |
void CTsFastSwapArea::TapL(const TPoint& aPoint) |
|
1559 |
{ |
|
1560 |
CancelLongTapAnimation(); |
|
1561 |
||
1562 |
if(!iHandlePointerCandidate) |
|
1563 |
{ |
|
1564 |
return; |
|
1565 |
} |
|
1566 |
||
1567 |
if(Rect().Contains(aPoint) && iArray.Count()) |
|
1568 |
{ |
|
1569 |
//provide tap pointer event to grid |
|
1570 |
iGrid->HandlePointerEventL(iTapEvent); |
|
1571 |
iHighlightTimer->Cancel(); |
|
1572 |
iHighlightTimer->After(KHighlighActivationTime); |
|
1573 |
} |
|
1574 |
else |
|
1575 |
{ |
|
1576 |
//move task switcher to background |
|
1577 |
iEikonEnv->EikAppUi()->HandleCommandL(EAknSoftkeyExit); |
|
1578 |
} |
|
1579 |
iHandlePointerCandidate = EFalse; |
|
1580 |
} |
|
1581 |
||
1582 |
// -------------------------------------------------------------------------- |
|
1583 |
// CTsFastSwapArea::LongTap |
|
1584 |
// -------------------------------------------------------------------------- |
|
1585 |
// |
|
1586 |
void CTsFastSwapArea::LongTapL(const TPoint& aPoint) |
|
1587 |
{ |
|
1588 |
CancelLongTapAnimation(); |
|
1589 |
||
1590 |
if(!iHandlePointerCandidate) |
|
1591 |
{ |
|
1592 |
return; |
|
1593 |
} |
|
1594 |
||
1595 |
TInt index(KErrNotFound); |
|
1596 |
if( iGrid->GridView()->XYPosToItemIndex(aPoint,index) && iArray.Count() ) |
|
1597 |
{ |
|
1598 |
iGrid->SetCurrentItemIndex(index); |
|
1599 |
SaveSelectedIndex(); |
|
1600 |
if ( !ShowPopupL(iSavedSelectedIndex, aPoint) ) |
|
1601 |
{ |
|
1602 |
iActivateOnPointerRelease = aPoint; |
|
1603 |
} |
|
1604 |
iGrid->ShowHighlight(); |
|
1605 |
DrawNow(); |
|
1606 |
} |
|
1607 |
iHandlePointerCandidate = EFalse; |
|
1608 |
} |
|
1609 |
||
1610 |
// -------------------------------------------------------------------------- |
|
1611 |
// CTsFastSwapArea::DragL |
|
1612 |
// -------------------------------------------------------------------------- |
|
1613 |
// |
|
1614 |
void CTsFastSwapArea::DragL( |
|
1615 |
const MAknTouchGestureFwDragEvent& aEvent) |
|
1616 |
{ |
|
1617 |
CancelLongTapAnimation(); |
|
1618 |
// Reset activation point |
|
1619 |
iActivateOnPointerRelease = TPoint(); |
|
1620 |
iHandlePointerCandidate = EFalse; |
|
1621 |
if( aEvent.State() == EAknTouchGestureFwStop) |
|
1622 |
{ |
|
1623 |
CenterItem( KUpdateGridTime ); |
|
1624 |
} |
|
1625 |
||
1626 |
iGrid->HideHighlight(); |
|
1627 |
} |
|
1628 |
||
1629 |
// ----------------------------------------------------------------------------- |
|
1630 |
// CTsFastSwapArea::ViewSize |
|
1631 |
// ----------------------------------------------------------------------------- |
|
1632 |
// |
|
1633 |
TSize CTsFastSwapArea::ViewSize() |
|
1634 |
{ |
|
1635 |
return TSize(Rect().Width(), Rect().Height()); |
|
1636 |
} |
|
1637 |
||
1638 |
// ----------------------------------------------------------------------------- |
|
1639 |
// CTsFastSwapArea::Stop |
|
1640 |
// ----------------------------------------------------------------------------- |
|
1641 |
// |
|
1642 |
void CTsFastSwapArea::Stop() |
|
1643 |
{ |
|
1644 |
CenterItem( KUpdateGridTime ); |
|
1645 |
DrawDeferred(); |
|
1646 |
} |
|
1647 |
||
1648 |
// ----------------------------------------------------------------------------- |
|
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1649 |
// CTsFastSwapArea::ViewSize |
83 | 1650 |
// ----------------------------------------------------------------------------- |
1651 |
// |
|
1652 |
TPoint CTsFastSwapArea::ViewPos() const |
|
1653 |
{ |
|
1654 |
TPoint retVal; |
|
1655 |
retVal.iY = iGrid->Rect().iTl.iY + Rect().Height() / 2; |
|
1656 |
retVal.iX = - (iGrid->Rect().iTl.iX - Rect().iTl.iX) + Rect().Width() / 2 ; |
|
1657 |
TInt gridItemCount = iGrid->Model()->ItemTextArray()->MdcaCount(); |
|
1658 |
if(gridItemCount && gridItemCount <= iMaxItemsOnScreen) |
|
1659 |
{ |
|
1660 |
// View centered |
|
1661 |
retVal.iX += ( Rect().Width() - gridItemCount * iGridItemWidth ) / 2; |
|
1662 |
} |
|
1663 |
retVal.iX += iLogicalViewPosOffset; |
|
1664 |
return retVal; |
|
1665 |
} |
|
1666 |
||
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1667 |
// ----------------------------------------------------------------------------- |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1668 |
// CTsFastSwapArea::ItemPosition |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1669 |
// ----------------------------------------------------------------------------- |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1670 |
// |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1671 |
TPoint CTsFastSwapArea::ItemViewPosition( TInt aItemIdx ) |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1672 |
{ |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1673 |
TPoint retVal = Rect().iTl; |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1674 |
if ( aItemIdx < 0 ) |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1675 |
{ |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1676 |
// No items |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1677 |
retVal.iX = 0; |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1678 |
} |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1679 |
else if ( aItemIdx == 0 ) |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1680 |
{ |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1681 |
// First item |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1682 |
if( AknLayoutUtils::LayoutMirrored() ) |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1683 |
{ |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1684 |
if ( GridItemCount() > iMaxItemsOnScreen ) |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1685 |
{ |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1686 |
retVal.iX = GridWorldSize().iWidth - Rect().Width(); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1687 |
} |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1688 |
else |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1689 |
{ |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1690 |
retVal.iX = 0; |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1691 |
} |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1692 |
} |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1693 |
else // normal layout |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1694 |
{ |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1695 |
retVal.iX = 0; |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1696 |
} |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1697 |
} |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1698 |
else if ( aItemIdx == GridItemCount() - 1 ) |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1699 |
{ |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1700 |
// Last item selected |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1701 |
if( AknLayoutUtils::LayoutMirrored() ) |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1702 |
{ |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1703 |
retVal.iX = 0; |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1704 |
} |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1705 |
else // normal layout |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1706 |
{ |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1707 |
if ( GridItemCount() > iMaxItemsOnScreen ) |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1708 |
{ |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1709 |
retVal.iX = GridWorldSize().iWidth - Rect().Width(); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1710 |
} |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1711 |
else |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1712 |
{ |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1713 |
retVal.iX = 0; |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1714 |
} |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1715 |
} |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1716 |
} |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1717 |
else |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1718 |
{ |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1719 |
// Middle item |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1720 |
TInt screenMiddleItemOffset = ( Rect().Width() - iGridItemWidth ) / 2; |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1721 |
if( AknLayoutUtils::LayoutMirrored() ) |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1722 |
{ |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1723 |
retVal.iX = iGridItemWidth * ( GridItemCount() - 1 - aItemIdx ) - screenMiddleItemOffset; |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1724 |
retVal.iX += ( GridItemCount() - 1 - aItemIdx ) * iGridItemGap; |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1725 |
} |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1726 |
else // normal layout |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1727 |
{ |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1728 |
retVal.iX = iGridItemWidth * aItemIdx - screenMiddleItemOffset; |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1729 |
retVal.iX += iGridItemGap * aItemIdx; |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1730 |
} |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1731 |
if ( retVal.iX < 0 ) |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1732 |
{ |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1733 |
retVal.iX = 0; |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1734 |
} |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1735 |
else if ( retVal.iX + Rect().Width() > GridWorldSize().iWidth ) |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1736 |
{ |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1737 |
retVal.iX = GridWorldSize().iWidth - Rect().Width(); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1738 |
} |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1739 |
} |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1740 |
|
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1741 |
// Return middle of the view rectangle |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1742 |
retVal.iX += Rect().Width() / 2; |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1743 |
|
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1744 |
return retVal; |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1745 |
} |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1746 |
|
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1747 |
// ----------------------------------------------------------------------------- |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1748 |
// CTsFastSwapArea::ViewToVisibleItem |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1749 |
// ----------------------------------------------------------------------------- |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1750 |
// |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1751 |
TInt CTsFastSwapArea::ViewToVisibleItem( const TPoint aViewPos ) |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1752 |
{ |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1753 |
TInt retVal(0); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1754 |
TPoint absViewPos = aViewPos; |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1755 |
absViewPos.iX -= Rect().Width() / 2; |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1756 |
if ( absViewPos.iX < 0 ) |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1757 |
{ |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1758 |
if ( AknLayoutUtils::LayoutMirrored() ) |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1759 |
{ |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1760 |
// View crossed left border of grid world rect, last item selected |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1761 |
retVal = GridItemCount() - 1; |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1762 |
} |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1763 |
else // normal layout |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1764 |
{ |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1765 |
// View crossed left border of grid world rect, first item selected |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1766 |
retVal = 0; |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1767 |
} |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1768 |
} |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1769 |
else if ( absViewPos.iX + Rect().Width() > GridWorldSize().iWidth ) |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1770 |
{ |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1771 |
if ( AknLayoutUtils::LayoutMirrored() ) |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1772 |
{ |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1773 |
// View crossed right border of grid world rect, first item selected |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1774 |
retVal = 0; |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1775 |
} |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1776 |
else // normal layout |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1777 |
{ |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1778 |
// View crossed right border of grid world rect, last item selected |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1779 |
retVal = GridItemCount() - 1; |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1780 |
} |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1781 |
} |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1782 |
else |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1783 |
{ |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1784 |
TInt retItemPosX(0); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1785 |
TInt offsetCheck = GridWorldSize().iWidth; |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1786 |
// View inside of grid world rect |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1787 |
for ( TInt i = 0 ; i < GridItemCount(); i++ ) |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1788 |
{ |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1789 |
TInt itemPosX = ItemViewPosition( i ).iX; |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1790 |
TInt offset = aViewPos.iX - itemPosX; |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1791 |
if ( Abs( offset ) <= offsetCheck ) |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1792 |
{ |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1793 |
offsetCheck = Abs( offset ); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1794 |
retVal = i; |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1795 |
retItemPosX = itemPosX; |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1796 |
} |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1797 |
else |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1798 |
{ |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1799 |
break; |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1800 |
} |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1801 |
} |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1802 |
// Check if item is fully visible. If not |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1803 |
// return next one if possible |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1804 |
if ( retItemPosX - iGridItemWidth / 2 < absViewPos.iX && |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1805 |
retVal + 1 < GridItemCount() ) |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1806 |
{ |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1807 |
retVal++; |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1808 |
} |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1809 |
} |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1810 |
|
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1811 |
return retVal; |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1812 |
} |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1813 |
|
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1814 |
|
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1815 |
// ----------------------------------------------------------------------------- |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1816 |
// CTsFastSwapArea::LaunchPopupFeedback |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1817 |
// ----------------------------------------------------------------------------- |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1818 |
// |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1819 |
void CTsFastSwapArea::LaunchPopupFeedback() |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1820 |
{ |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1821 |
if ( AknLayoutUtils::PenEnabled() ) |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1822 |
{ |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1823 |
MTouchFeedback* feedback = MTouchFeedback::Instance(); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1824 |
if ( feedback ) |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1825 |
{ |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1826 |
TTouchLogicalFeedback fbLogicalType = ETouchFeedbackPopUp; |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1827 |
if ( CAknTransitionUtils::TransitionsEnabled( |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1828 |
AknTransEffect::EComponentTransitionsOff ) ) |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1829 |
{ |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1830 |
fbLogicalType = ETouchFeedbackIncreasingPopUp; |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1831 |
} |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1832 |
feedback->InstantFeedback( this, |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1833 |
fbLogicalType, |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1834 |
ETouchFeedbackVibra, |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1835 |
TPointerEvent() ); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1836 |
} |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1837 |
} |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1838 |
} |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1839 |
|
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1840 |
|
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1841 |
// ----------------------------------------------------------------------------- |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1842 |
// CTsFastSwapArea::GetCurrentScreenOrientation |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1843 |
// ----------------------------------------------------------------------------- |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1844 |
// |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1845 |
TInt CTsFastSwapArea::GetCurrentScreenOrientation() |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1846 |
{ |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1847 |
TPixelsAndRotation availableRect; |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1848 |
iEikonEnv->ScreenDevice()->GetDefaultScreenSizeAndRotation(availableRect); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1849 |
return availableRect.iPixelSize.iWidth > availableRect.iPixelSize.iHeight; |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1850 |
} |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1851 |
|
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1852 |
|
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1853 |
// ----------------------------------------------------------------------------- |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1854 |
// CTsFastSwapArea::GetVariety |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1855 |
// ----------------------------------------------------------------------------- |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1856 |
// |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1857 |
TBool CTsFastSwapArea::GetVariety( TInt& aVariety ) |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1858 |
{ |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1859 |
aVariety = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0; |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1860 |
TBool foreground = static_cast<CTsAppUi*>(iEikonEnv->AppUi())->IsForeground(); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1861 |
if ( foreground ) |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1862 |
{ |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1863 |
TInt screenOrientation = GetCurrentScreenOrientation(); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1864 |
if ( aVariety != screenOrientation ) |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1865 |
{ |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1866 |
aVariety = screenOrientation; |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1867 |
return ETrue; |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1868 |
} |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1869 |
} |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1870 |
return EFalse; |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
93
diff
changeset
|
1871 |
} |
83 | 1872 |
|
1873 |
// ----------------------------------------------------------------------------- |
|
1874 |
// CTsFastSwapArea::IsAppClosing |
|
1875 |
// ----------------------------------------------------------------------------- |
|
1876 |
// |
|
1877 |
TBool CTsFastSwapArea::IsAppClosing( TInt aWgId ) |
|
1878 |
{ |
|
1879 |
TBool retVal(EFalse); |
|
1880 |
if ( iIsClosing.Count() ) |
|
1881 |
{ |
|
1882 |
TInt idx = iIsClosing.Find(aWgId); |
|
1883 |
retVal = idx != KErrNotFound; |
|
1884 |
if ( retVal ) |
|
1885 |
{ |
|
1886 |
iIsClosing.Remove(idx); |
|
1887 |
} |
|
1888 |
else if ( iWidgetClosingCount ) |
|
1889 |
{ |
|
1890 |
retVal = ETrue; |
|
1891 |
iWidgetClosingCount--; |
|
1892 |
} |
|
1893 |
} |
|
1894 |
return retVal; |
|
1895 |
} |
|
1896 |
||
1897 |
||
1898 |
// ----------------------------------------------------------------------------- |
|
1899 |
// CTsFastSwapArea::WgOnTaskList |
|
1900 |
// ----------------------------------------------------------------------------- |
|
1901 |
// |
|
1902 |
TBool CTsFastSwapArea::WgOnTaskList( TInt aWgId ) |
|
1903 |
{ |
|
1904 |
TBool retVal(EFalse); |
|
1905 |
TInt appCount = iArray.Count(); |
|
1906 |
||
1907 |
TApaTaskList taskList( iEikonEnv->WsSession() ); |
|
1908 |
TApaTask task = taskList.FindApp( KTsHomescreenUid ); |
|
1909 |
TInt homescrWgId = task.WgId(); |
|
1910 |
||
1911 |
if ( iPrevAppCount != appCount ) |
|
1912 |
{ |
|
1913 |
for ( TInt i = 0; i < iArray.Count(); i++ ) |
|
1914 |
{ |
|
1915 |
TInt wgId = iArray[i]->WgId(); |
|
1916 |
if ( wgId == aWgId || |
|
1917 |
homescrWgId == aWgId ) |
|
1918 |
{ |
|
1919 |
retVal = ETrue; |
|
1920 |
} |
|
1921 |
} |
|
1922 |
} |
|
1923 |
else if ( aWgId == homescrWgId ) |
|
1924 |
{ |
|
1925 |
retVal = ETrue; |
|
1926 |
} |
|
1927 |
iPrevAppCount = appCount; |
|
1928 |
return retVal; |
|
1929 |
} |
|
1930 |
||
1931 |
// ----------------------------------------------------------------------------- |
|
1932 |
// CTsFastSwapArea::CancelLongTapAnimation |
|
1933 |
// ----------------------------------------------------------------------------- |
|
1934 |
// |
|
1935 |
void CTsFastSwapArea::CancelLongTapAnimation(TBool aDisablePopup) |
|
1936 |
{ |
|
1937 |
iLongTapAnimationRunning = EFalse; |
|
1938 |
iLongTapAnimationTimer->Cancel(); |
|
1939 |
if ( iLongTapAnimation ) |
|
1940 |
{ |
|
1941 |
iLongTapAnimation->HideAnimation(); |
|
1942 |
delete iLongTapAnimation; |
|
1943 |
iLongTapAnimation = NULL; |
|
1944 |
} |
|
1945 |
if( aDisablePopup ) |
|
1946 |
{ |
|
1947 |
TRAP_IGNORE( |
|
1948 |
static_cast<CTsAppUi*>(iEikonEnv->AppUi())->DisablePopUpL() ); |
|
1949 |
} |
|
1950 |
} |
|
1951 |
||
1952 |
||
1953 |
// ----------------------------------------------------------------------------- |
|
1954 |
// CTsFastSwapArea::LongTapAnimForPos |
|
1955 |
// ----------------------------------------------------------------------------- |
|
1956 |
// |
|
1957 |
TBool CTsFastSwapArea::LongTapAnimForPos( const TPoint& aHitPoint ) |
|
1958 |
{ |
|
1959 |
if ( Rect().Contains(aHitPoint) ) |
|
1960 |
{ |
|
1961 |
TInt itemIdx; |
|
1962 |
TBool isItemHit = iGrid->GridView()->XYPosToItemIndex( aHitPoint, itemIdx ); |
|
1963 |
if ( isItemHit && ( CanClose( itemIdx ) || CanCloseAll( itemIdx ) ) ) |
|
1964 |
{ |
|
1965 |
return ETrue; |
|
1966 |
} |
|
1967 |
} |
|
1968 |
return EFalse; |
|
1969 |
} |
|
1970 |
||
1971 |
// End of file |