35
|
1 |
/*
|
|
2 |
* Copyright (c) 2006 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: Zoom popup implementation.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include <AknVolumePopup.h>
|
|
20 |
#include <cvtlogger.h>
|
|
21 |
#include "cvtuizoompopup.h"
|
|
22 |
#include "cvtuifeaturemanager.h"
|
|
23 |
#include "tVtuifeaturevariation.h"
|
|
24 |
#include "CVtUiAppUi.h"
|
|
25 |
#include "cvtengmodel.h"
|
|
26 |
|
|
27 |
// Number of zoom steps
|
|
28 |
static const TInt KZoomStepCount = 10;
|
|
29 |
|
|
30 |
// Minimum zoom factor value
|
|
31 |
static const TInt KMinZoomFactor = 0;
|
|
32 |
|
|
33 |
// default time out time for zoom popup
|
|
34 |
const TInt KDefaultZoomTimeOutTime = 5;
|
|
35 |
|
|
36 |
// ---------------------------------------------------------------------------
|
|
37 |
// CVtUiZoomPopup::NewL
|
|
38 |
// ---------------------------------------------------------------------------
|
|
39 |
//
|
|
40 |
CVtUiZoomPopup* CVtUiZoomPopup::NewL( CVtUiFeatureManager&
|
|
41 |
aFeatureManager )
|
|
42 |
{
|
|
43 |
__VTPRINTENTER( "CVtUiZoomPopup.NewL" )
|
|
44 |
CVtUiZoomPopup* self =
|
|
45 |
new ( ELeave ) CVtUiZoomPopup( aFeatureManager );
|
|
46 |
CleanupStack::PushL( self );
|
|
47 |
self->ConstructL();
|
|
48 |
CleanupStack::Pop();
|
|
49 |
__VTPRINTEXIT( "CVtUiZoomPopup.NewL" )
|
|
50 |
return self;
|
|
51 |
}
|
|
52 |
|
|
53 |
// ---------------------------------------------------------------------------
|
|
54 |
// CVtUiZoomPopup::~CVtUiZoomPopup
|
|
55 |
// ---------------------------------------------------------------------------
|
|
56 |
//
|
|
57 |
CVtUiZoomPopup::~CVtUiZoomPopup()
|
|
58 |
{
|
|
59 |
__VTPRINTENTER( "CVtUiZoomPopup.~" )
|
|
60 |
__VTPRINTEXIT( "CVtUiZoomPopup.~" )
|
|
61 |
}
|
|
62 |
|
|
63 |
// ---------------------------------------------------------------------------
|
|
64 |
// CVtUiZoomPopup::RefreshL
|
|
65 |
// ---------------------------------------------------------------------------
|
|
66 |
//
|
|
67 |
void CVtUiZoomPopup::RefreshL()
|
|
68 |
{
|
|
69 |
__VTPRINTENTER( "CVtUiZoomPopup.RefreshL" )
|
|
70 |
|
|
71 |
UpdateAdjustRangeL();
|
|
72 |
|
|
73 |
iCurrent = CurrentZoomStep();
|
|
74 |
if ( iCurrent < KMinZoomFactor )
|
|
75 |
{
|
|
76 |
User::Leave( KErrArgument );
|
|
77 |
}
|
|
78 |
SetValue( iCurrent );
|
|
79 |
ShowPopupL();
|
|
80 |
__VTPRINTEXIT( "CVtUiZoomPopup.RefreshL" )
|
|
81 |
}
|
|
82 |
|
|
83 |
// ---------------------------------------------------------------------------
|
|
84 |
// CVtUiZoomPopup::DoActivateL()
|
|
85 |
// ---------------------------------------------------------------------------
|
|
86 |
//
|
|
87 |
void CVtUiZoomPopup::DoActivateL()
|
|
88 |
{
|
|
89 |
__VTPRINTENTER( "CVtUiZoomPopup.DoActivateL" )
|
|
90 |
UpdateAdjustRangeL();
|
|
91 |
CVtUiPopupBase::DoActivateL();
|
|
92 |
// In order to refresh softkey.
|
|
93 |
iFeatureManager.AppUi().RefreshSoftkeysL();
|
|
94 |
__VTPRINTEXIT( "CVtUiZoomPopup.DoActivateL" )
|
|
95 |
}
|
|
96 |
|
|
97 |
// ---------------------------------------------------------------------------
|
|
98 |
// CVtUiZoomPopup::OfferKeyEventL()
|
|
99 |
// ---------------------------------------------------------------------------
|
|
100 |
//
|
|
101 |
TKeyResponse CVtUiZoomPopup::OfferKeyEventL( const TKeyEvent& aEvent,
|
|
102 |
TEventCode aCode )
|
|
103 |
{
|
|
104 |
__VTPRINTENTER( "CVtUiZoomPopup.OfferKeyEventL" )
|
|
105 |
TKeyResponse response( EKeyWasNotConsumed );
|
|
106 |
// Don't handle other types here
|
|
107 |
if ( aCode != EEventKey )
|
|
108 |
{
|
|
109 |
return response;
|
|
110 |
}
|
|
111 |
|
|
112 |
if ( aEvent.iScanCode == EStdKeyUpArrow ||
|
|
113 |
aEvent.iScanCode == EStdKeyDownArrow ||
|
|
114 |
aEvent.iCode == EKeyZoomIn ||
|
|
115 |
aEvent.iCode == EKeyZoomOut )
|
|
116 |
{
|
|
117 |
__VTPRINT( DEBUG_GEN, "CVtUiZoomPopup.OfferKeyEventL zoom key" )
|
|
118 |
TInt step( 1 );
|
|
119 |
if ( aEvent.iScanCode == EStdKeyDownArrow ||
|
|
120 |
aEvent.iCode == EKeyZoomOut )
|
|
121 |
{
|
|
122 |
step = -step;
|
|
123 |
}
|
|
124 |
const TInt current( Value() );
|
|
125 |
TInt value( current + step );
|
|
126 |
value = Max( KMinZoomFactor, Min( value, KZoomStepCount ) );
|
|
127 |
if ( value != current )
|
|
128 |
{
|
|
129 |
__VTPRINT2( DEBUG_GEN, "CVtUiZoomPopup.OfferKeyEventL zoom = %d",
|
|
130 |
value )
|
|
131 |
SetValue( value );
|
|
132 |
iFeatureManager.AppUi().SetZoomFactorL( ScaledValue() );
|
|
133 |
response = EKeyWasConsumed;
|
|
134 |
}
|
|
135 |
ShowPopupL();
|
|
136 |
}
|
|
137 |
__VTPRINTEXITR( "CVtUiZoomPopup.OfferKeyEventL %d", response )
|
|
138 |
return response;
|
|
139 |
}
|
|
140 |
|
|
141 |
// ---------------------------------------------------------------------------
|
|
142 |
// CVtUiZoomPopup::HandleControlEventL
|
|
143 |
// ---------------------------------------------------------------------------
|
|
144 |
//
|
|
145 |
void CVtUiZoomPopup::HandleControlEventL( CCoeControl* aControl,
|
|
146 |
TCoeEvent aEventType )
|
|
147 |
{
|
|
148 |
__VTPRINTENTER( "CVtUiZoomPopup.HandleControlEventL" )
|
|
149 |
CVtUiPopupBase::HandleControlEventL( aControl, aEventType );
|
|
150 |
|
|
151 |
if ( aEventType == EEventStateChanged )
|
|
152 |
{
|
|
153 |
__VTPRINT2( DEBUG_GEN, "CVtUiZoomPopup.HandleControlEventL zoom = %d", ScaledValue() )
|
|
154 |
|
|
155 |
if ( CurrentZoomStep() != Value() )
|
|
156 |
{
|
|
157 |
iFeatureManager.AppUi().SetZoomFactorL( ScaledValue() );
|
|
158 |
}
|
|
159 |
}
|
|
160 |
|
|
161 |
__VTPRINTEXIT( "CVtUiZoomPopup.HandleControlEventL" )
|
|
162 |
}
|
|
163 |
|
|
164 |
// ---------------------------------------------------------------------------
|
|
165 |
// CVtUiZoomPopup::CVtUiZoomPopup
|
|
166 |
// ---------------------------------------------------------------------------
|
|
167 |
//
|
|
168 |
CVtUiZoomPopup::CVtUiZoomPopup( CVtUiFeatureManager& aFeatureManager )
|
|
169 |
: CVtUiPopupBase( aFeatureManager.ComponentManager(),
|
|
170 |
TVtUiBlockListBitField(
|
|
171 |
MVtUiComponent::EComponentIdDialer |
|
|
172 |
MVtUiComponent::EComponentIdToolbar |
|
|
173 |
MVtUiComponent::EComponentIdNumberEntry |
|
|
174 |
MVtUiComponent::EComponentIdVolume |
|
|
175 |
MVtUiComponent::EVComponentIdBrightness |
|
|
176 |
MVtUiComponent::EVComponentIdContrast
|
|
177 |
),
|
|
178 |
EComponentIdZoom ),
|
|
179 |
iFeatureManager( aFeatureManager ),
|
|
180 |
iMedia( aFeatureManager.AppUi().Model().Media() ),
|
|
181 |
iCurrent( KErrNotReady )
|
|
182 |
{
|
|
183 |
__VTPRINTENTER( "CVtUiZoomPopup.CVtUiZoomPopup" )
|
|
184 |
__VTPRINTEXIT( "CVtUiZoomPopup.CVtUiZoomPopup" )
|
|
185 |
}
|
|
186 |
|
|
187 |
// ---------------------------------------------------------------------------
|
|
188 |
// CVtUiZoomPopup::ConstructL
|
|
189 |
// ---------------------------------------------------------------------------
|
|
190 |
//
|
|
191 |
void CVtUiZoomPopup::ConstructL()
|
|
192 |
{
|
|
193 |
__VTPRINTENTER( "CVtUiZoomPopup.ConstructL" )
|
|
194 |
BaseConstructL();
|
|
195 |
// Set slider type to percentage
|
|
196 |
SetValueType( EAknSliderValuePercentage );
|
|
197 |
|
|
198 |
// Set timeout
|
|
199 |
SetTimeOut( KDefaultZoomTimeOutTime );
|
|
200 |
__VTPRINTEXIT( "CVtUiZoomPopup.ConstructL" )
|
|
201 |
}
|
|
202 |
|
|
203 |
// ---------------------------------------------------------------------------
|
|
204 |
// CVtUiZoomPopup::UpdateAdjustRangeL
|
|
205 |
// ---------------------------------------------------------------------------
|
|
206 |
//
|
|
207 |
void CVtUiZoomPopup::UpdateAdjustRangeL()
|
|
208 |
{
|
|
209 |
__VTPRINTENTER( "CVtUiZoomPopup.UpdateAdjustRangeL" )
|
|
210 |
// Get max zoom step from engine
|
|
211 |
iMax = MaxZoomStep();
|
|
212 |
// Set value range to visible slider control
|
|
213 |
// range 0-10 or 0-iMax if max < 0
|
|
214 |
// stepcount = 10 or iMax if max < 10
|
|
215 |
SetAdjustRange( KMinZoomFactor, Min( KZoomStepCount, iMax ), Min( KZoomStepCount, iMax ) );
|
|
216 |
|
|
217 |
// Set value range to baseclass
|
|
218 |
// range on e.g. 0-20
|
|
219 |
SetMinAndMaxValues( KMinZoomFactor, iMax );
|
|
220 |
|
|
221 |
// Get current zoom step
|
|
222 |
iCurrent = CurrentZoomStep();
|
|
223 |
|
|
224 |
if ( iCurrent == KErrNotFound || iMax == KErrNotFound || iCurrent > iMax )
|
|
225 |
{
|
|
226 |
User::Leave( KErrNotFound );
|
|
227 |
}
|
|
228 |
// Set new value
|
|
229 |
SetValue( iCurrent );
|
|
230 |
__VTPRINTEXIT( "CVtUiZoomPopup.UpdateAdjustRangeL" )
|
|
231 |
}
|
|
232 |
|
|
233 |
// ---------------------------------------------------------------------------
|
|
234 |
// CVtUiZoomPopup::CurrentZoomStep
|
|
235 |
// ---------------------------------------------------------------------------
|
|
236 |
//
|
|
237 |
TInt CVtUiZoomPopup::CurrentZoomStep() const
|
|
238 |
{
|
|
239 |
__VTPRINTENTER( "CVtUiZoomPopup.CurrentZoomStep" )
|
|
240 |
TInt current( KMinZoomFactor );
|
|
241 |
const TInt error( iMedia.GetCurrentZoomStep( current ) );
|
|
242 |
current = ( error ? KErrNotFound : current );
|
|
243 |
|
|
244 |
// Value asked from the engine must be scaled.
|
|
245 |
// If the current asked value is 1 then the scaling formula in the
|
|
246 |
// popupbase doesn't round the value to 1 there fore value is
|
|
247 |
// initalized to 1.
|
|
248 |
TInt val = 1;
|
|
249 |
if ( current != 1 )
|
|
250 |
{
|
|
251 |
val = SliderValueWithScaling( current );
|
|
252 |
}
|
|
253 |
__VTPRINTEXITR( "CVtUiZoomPopup.CurrentZoomStep %d", val )
|
|
254 |
return val;
|
|
255 |
}
|
|
256 |
|
|
257 |
// ---------------------------------------------------------------------------
|
|
258 |
// CVtUiZoomPopup::MaxZoomStep
|
|
259 |
// ---------------------------------------------------------------------------
|
|
260 |
//
|
|
261 |
TInt CVtUiZoomPopup::MaxZoomStep() const
|
|
262 |
{
|
|
263 |
__VTPRINTENTER( "CVtUiZoomPopup.MaxZoomStep" )
|
|
264 |
TInt max( KMinZoomFactor );
|
|
265 |
const TInt error( iMedia.GetMaxZoomStep( max ) );
|
|
266 |
max = ( error ? KErrNotFound : max );
|
|
267 |
__VTPRINTEXITR( "CVtUiZoomPopup.MaxZoomStep %d", max )
|
|
268 |
return max;
|
|
269 |
}
|
|
270 |
|
|
271 |
// ---------------------------------------------------------------------------
|
|
272 |
// CVtUiZoomPopup::ScaleAndSetZoomFactorL
|
|
273 |
// ---------------------------------------------------------------------------
|
|
274 |
//
|
|
275 |
void CVtUiZoomPopup::ScaleAndSetZoomFactorL( TInt aValue )
|
|
276 |
{
|
|
277 |
__VTPRINTENTER( "CVtUiZoomPopup.ScaleAndSetZoomFactorL" )
|
|
278 |
const TInt value = aValue * MaxZoomStep() / 10; // 10 vakioksi count + 1 ei yhtä
|
|
279 |
iFeatureManager.AppUi().SetZoomFactorL( value );
|
|
280 |
__VTPRINTEXITR( "CVtUiZoomPopup.ScaleAndSetZoomFactorL %d", value )
|
|
281 |
}
|
|
282 |
|