22 #include <alf/alfevent.h> |
22 #include <alf/alfevent.h> |
23 #include <alf/alfimagevisual.h> |
23 #include <alf/alfimagevisual.h> |
24 #include <alf/alftexture.h> |
24 #include <alf/alftexture.h> |
25 #include <alf/alfanchorlayout.h> |
25 #include <alf/alfanchorlayout.h> |
26 #include <alf/alfdecklayout.h> |
26 #include <alf/alfdecklayout.h> |
|
27 #include <AknUtils.h> |
|
28 #include <aknlayoutscalable_apps.cdl.h> |
27 |
29 |
28 // Constants |
30 // Constants |
29 |
31 |
30 // Scroll bar opacity (visible) |
32 // Scroll bar opacity (visible) |
31 const TReal32 KVisibleOpacity = 1.0f; |
33 const TReal32 KVisibleOpacity = 1.0f; |
32 // Thumb opacity (visible) |
34 // Thumb opacity (visible) |
33 const TReal32 KVisibleOpacityThumb = 0.85f; |
35 const TReal32 KVisibleOpacityThumb = 0.85f; |
34 // Background opacity (visible) |
36 // Background opacity (visible) |
35 const TReal32 KVisibleOpacityBackground = 0.65f; |
37 const TReal32 KVisibleOpacityBackground = 0.65f; |
36 // How long scrollbar will be visible after change |
38 // How long scrollbar will be visible after change |
37 const TReal32 KVisibleTimeout = 500; |
39 const TReal32 KVisibleTimeout = 250; |
38 // How long fading will take |
40 // How long fading will take |
39 const TReal32 KFadeTimeout = 500; |
41 const TReal32 KFadeTimeout = 500; |
40 // Width of the scrollbar (this will be replaced with value from layout) |
42 |
41 const TInt KScrollBarWidth = 18; |
43 // Local methods |
|
44 |
|
45 // --------------------------------------------------------------------------- |
|
46 // ScrollBarWidth |
|
47 // --------------------------------------------------------------------------- |
|
48 TInt ScrollBarWidth() |
|
49 { |
|
50 FUNC_LOG; |
|
51 TRect mainPaneRect; |
|
52 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPaneRect ); |
|
53 TAknLayoutRect layoutRect; |
|
54 layoutRect.LayoutRect( mainPaneRect, AknLayoutScalable_Apps::main_sp_fs_email_pane() ); |
|
55 layoutRect.LayoutRect( layoutRect.Rect(), AknLayoutScalable_Apps::listscroll_cmail_pane() ); |
|
56 layoutRect.LayoutRect( layoutRect.Rect(), AknLayoutScalable_Apps::list_cmail_pane() ); |
|
57 layoutRect.LayoutRect( layoutRect.Rect(), AknLayoutScalable_Apps::sp_fs_scroll_pane_cp02() ); |
|
58 return layoutRect.Rect().Width(); |
|
59 } |
42 |
60 |
43 // CUiCCompositeImage |
61 // CUiCCompositeImage |
44 |
62 |
45 // --------------------------------------------------------------------------- |
63 // --------------------------------------------------------------------------- |
46 // CUiCCompositeImage::NewL |
64 // CUiCCompositeImage::NewL |
109 // --------------------------------------------------------------------------- |
127 // --------------------------------------------------------------------------- |
110 // |
128 // |
111 void CUiCCompositeImage::SetAnchors() |
129 void CUiCCompositeImage::SetAnchors() |
112 { |
130 { |
113 FUNC_LOG; |
131 FUNC_LOG; |
|
132 const TInt width( ScrollBarWidth() ); |
|
133 |
114 // iTop |
134 // iTop |
115 iLayout->SetAnchor( |
135 iLayout->SetAnchor( |
116 EAlfAnchorTopLeft, 0, |
136 EAlfAnchorTopLeft, 0, |
117 EAlfAnchorOriginLeft, EAlfAnchorOriginTop, |
137 EAlfAnchorOriginLeft, EAlfAnchorOriginTop, |
118 EAlfAnchorMetricAbsolute, EAlfAnchorMetricAbsolute, |
138 EAlfAnchorMetricAbsolute, EAlfAnchorMetricAbsolute, |
119 TAlfTimedPoint( 0, 0 ) ); |
139 TAlfTimedPoint( 0, 0 ) ); |
120 iLayout->SetAnchor( |
140 iLayout->SetAnchor( |
121 EAlfAnchorBottomRight, 0, |
141 EAlfAnchorBottomRight, 0, |
122 EAlfAnchorOriginRight, EAlfAnchorOriginTop, |
142 EAlfAnchorOriginRight, EAlfAnchorOriginTop, |
123 EAlfAnchorMetricAbsolute, EAlfAnchorMetricAbsolute, |
143 EAlfAnchorMetricAbsolute, EAlfAnchorMetricAbsolute, |
124 TAlfTimedPoint( 0, KScrollBarWidth ) ); |
144 TAlfTimedPoint( 0, width ) ); |
125 |
145 |
126 // iMiddle |
146 // iMiddle |
127 iLayout->SetAnchor( |
147 iLayout->SetAnchor( |
128 EAlfAnchorTopLeft, 1, |
148 EAlfAnchorTopLeft, 1, |
129 EAlfAnchorOriginLeft, EAlfAnchorOriginTop, |
149 EAlfAnchorOriginLeft, EAlfAnchorOriginTop, |
130 EAlfAnchorMetricAbsolute, EAlfAnchorMetricAbsolute, |
150 EAlfAnchorMetricAbsolute, EAlfAnchorMetricAbsolute, |
131 TAlfTimedPoint( 0, KScrollBarWidth ) ); |
151 TAlfTimedPoint( 0, width ) ); |
132 iLayout->SetAnchor( |
152 iLayout->SetAnchor( |
133 EAlfAnchorBottomRight, 1, |
153 EAlfAnchorBottomRight, 1, |
134 EAlfAnchorOriginRight, EAlfAnchorOriginBottom, |
154 EAlfAnchorOriginRight, EAlfAnchorOriginBottom, |
135 EAlfAnchorMetricAbsolute, EAlfAnchorMetricAbsolute, |
155 EAlfAnchorMetricAbsolute, EAlfAnchorMetricAbsolute, |
136 TAlfTimedPoint( 0, -KScrollBarWidth ) ); |
156 TAlfTimedPoint( 0, -width ) ); |
137 |
157 |
138 // iBottom |
158 // iBottom |
139 iLayout->SetAnchor( |
159 iLayout->SetAnchor( |
140 EAlfAnchorTopLeft, 2, |
160 EAlfAnchorTopLeft, 2, |
141 EAlfAnchorOriginLeft, EAlfAnchorOriginBottom, |
161 EAlfAnchorOriginLeft, EAlfAnchorOriginBottom, |
142 EAlfAnchorMetricAbsolute, EAlfAnchorMetricAbsolute, |
162 EAlfAnchorMetricAbsolute, EAlfAnchorMetricAbsolute, |
143 TAlfTimedPoint( 0, -KScrollBarWidth ) ); |
163 TAlfTimedPoint( 0, -width ) ); |
144 iLayout->SetAnchor( |
164 iLayout->SetAnchor( |
145 EAlfAnchorBottomRight, 2, |
165 EAlfAnchorBottomRight, 2, |
146 EAlfAnchorOriginRight, EAlfAnchorOriginBottom, |
166 EAlfAnchorOriginRight, EAlfAnchorOriginBottom, |
147 EAlfAnchorMetricAbsolute, EAlfAnchorMetricAbsolute, |
167 EAlfAnchorMetricAbsolute, EAlfAnchorMetricAbsolute, |
148 TAlfTimedPoint( 0, 0 ) ); |
168 TAlfTimedPoint( 0, 0 ) ); |
330 |
350 |
331 AknsUtils::CreateIconL( AknsUtils::SkinInstance(), itemId, aBitmap, aMaskBitmap, KNullDesC, -1, -1 ); |
351 AknsUtils::CreateIconL( AknsUtils::SkinInstance(), itemId, aBitmap, aMaskBitmap, KNullDesC, -1, -1 ); |
332 |
352 |
333 if ( aBitmap ) |
353 if ( aBitmap ) |
334 { |
354 { |
|
355 const TInt width( ScrollBarWidth() ); |
|
356 |
335 TAknContentDimensions origDim; |
357 TAknContentDimensions origDim; |
336 AknIconUtils::GetContentDimensions( aBitmap, origDim ); |
358 AknIconUtils::GetContentDimensions( aBitmap, origDim ); |
337 TSize iconSize( origDim.iWidth, origDim.iHeight ); |
359 TSize iconSize( origDim.iWidth, origDim.iHeight ); |
338 if (iconSize.iWidth != KScrollBarWidth && iconSize.iWidth > 0) |
360 if (iconSize.iWidth != width && iconSize.iWidth > 0) |
339 { |
361 { |
340 iconSize.iHeight = iconSize.iHeight * KScrollBarWidth / iconSize.iWidth; |
362 iconSize.iHeight = iconSize.iHeight * width / iconSize.iWidth; |
341 iconSize.iWidth = KScrollBarWidth; |
363 iconSize.iWidth = width; |
342 } |
364 } |
343 AknIconUtils::DisableCompression( aBitmap ); |
365 AknIconUtils::DisableCompression( aBitmap ); |
344 AknIconUtils::SetSize( aBitmap, iconSize, EAspectRatioNotPreserved ); |
366 AknIconUtils::SetSize( aBitmap, iconSize, EAspectRatioNotPreserved ); |
345 if ( aMaskBitmap ) |
367 if ( aMaskBitmap ) |
346 { |
368 { |
398 iThumbVisual = CUiCCompositeImage::NewL( *this, iThumbLayout, |
420 iThumbVisual = CUiCCompositeImage::NewL( *this, iThumbLayout, |
399 Env().TextureManager().CreateTextureL( EThumbTop, this, EAlfTextureFlagSkinContent ), |
421 Env().TextureManager().CreateTextureL( EThumbTop, this, EAlfTextureFlagSkinContent ), |
400 Env().TextureManager().CreateTextureL( EThumbMiddle, this, EAlfTextureFlagSkinContent ), |
422 Env().TextureManager().CreateTextureL( EThumbMiddle, this, EAlfTextureFlagSkinContent ), |
401 Env().TextureManager().CreateTextureL( EThumbBottom, this, EAlfTextureFlagSkinContent ) ); |
423 Env().TextureManager().CreateTextureL( EThumbBottom, this, EAlfTextureFlagSkinContent ) ); |
402 iThumbVisual->Layout().SetFlags( EAlfVisualFlagDrawAfterOthers ); |
424 iThumbVisual->Layout().SetFlags( EAlfVisualFlagDrawAfterOthers ); |
403 SetAnchors(); |
425 SetAnchors(); |
404 } |
426 } |
405 |
427 |
406 // --------------------------------------------------------------------------- |
428 // --------------------------------------------------------------------------- |
407 // CUiCScrollBar::ConstructL |
429 // CUiCScrollBar::ConstructL |
408 // --------------------------------------------------------------------------- |
430 // --------------------------------------------------------------------------- |
423 FUNC_LOG; |
445 FUNC_LOG; |
424 iBgLayout->SetAnchor( |
446 iBgLayout->SetAnchor( |
425 EAlfAnchorTopLeft, 0, |
447 EAlfAnchorTopLeft, 0, |
426 EAlfAnchorOriginRight, EAlfAnchorOriginTop, |
448 EAlfAnchorOriginRight, EAlfAnchorOriginTop, |
427 EAlfAnchorMetricAbsolute, EAlfAnchorMetricAbsolute, |
449 EAlfAnchorMetricAbsolute, EAlfAnchorMetricAbsolute, |
428 TAlfTimedPoint( -KScrollBarWidth, 0 ) ); |
450 TAlfTimedPoint( -ScrollBarWidth(), 0 ) ); |
429 iBgLayout->SetAnchor( |
451 iBgLayout->SetAnchor( |
430 EAlfAnchorBottomRight, 0, |
452 EAlfAnchorBottomRight, 0, |
431 EAlfAnchorOriginRight, EAlfAnchorOriginBottom, |
453 EAlfAnchorOriginRight, EAlfAnchorOriginBottom, |
432 EAlfAnchorMetricAbsolute, EAlfAnchorMetricAbsolute, |
454 EAlfAnchorMetricAbsolute, EAlfAnchorMetricAbsolute, |
433 TAlfTimedPoint( 0, 0 ) ); |
455 TAlfTimedPoint( 0, 0 ) ); |
443 FUNC_LOG; |
465 FUNC_LOG; |
444 iThumbLayout->SetAnchor( |
466 iThumbLayout->SetAnchor( |
445 EAlfAnchorTopLeft, 0, |
467 EAlfAnchorTopLeft, 0, |
446 EAlfAnchorOriginRight, EAlfAnchorOriginTop, |
468 EAlfAnchorOriginRight, EAlfAnchorOriginTop, |
447 EAlfAnchorMetricAbsolute, EAlfAnchorMetricAbsolute, |
469 EAlfAnchorMetricAbsolute, EAlfAnchorMetricAbsolute, |
448 TAlfTimedPoint( -KScrollBarWidth, iModel.ThumbPosition() ) ); |
470 TAlfTimedPoint( -ScrollBarWidth(), iModel.ThumbPosition() ) ); |
449 iThumbLayout->SetAnchor( |
471 iThumbLayout->SetAnchor( |
450 EAlfAnchorBottomRight, 0, |
472 EAlfAnchorBottomRight, 0, |
451 EAlfAnchorOriginRight, EAlfAnchorOriginTop, |
473 EAlfAnchorOriginRight, EAlfAnchorOriginTop, |
452 EAlfAnchorMetricAbsolute, EAlfAnchorMetricAbsolute, |
474 EAlfAnchorMetricAbsolute, EAlfAnchorMetricAbsolute, |
453 TAlfTimedPoint( 0, iModel.ThumbPosition() + iModel.ThumbHeight() ) ); |
475 TAlfTimedPoint( 0, iModel.ThumbPosition() + iModel.ThumbHeight() ) ); |