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