camerauis/cameraapp/generic/inc/CamSceneSettingContainer.h
branchRCL_3
changeset 24 bac7acad7cb3
parent 0 1ddebce53859
equal deleted inserted replaced
23:61bc0f252b2b 24:bac7acad7cb3
       
     1 /*
       
     2 * Copyright (c) 2007 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:  Container for scene setting view
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef CAMSCENESETTINGCONTAINER_H
       
    21 #define CAMSCENESETTINGCONTAINER_H
       
    22 
       
    23 // INCLUDES
       
    24 #include "CamContainerBase.h"
       
    25 #include "CamAppController.h"
       
    26 #include "CamSettings.hrh"
       
    27 #include <aknutils.h>
       
    28 
       
    29 // DATA TYPES
       
    30 // Container class holding data for animated scene icons
       
    31 class TCamAnimationData
       
    32     {
       
    33 public:
       
    34     /**
       
    35     * Set up animation data for scene setting icon 
       
    36     * @since 2.8
       
    37     * @param aRect The initial highlighted rect
       
    38     */
       
    39     void Initialise( const TRect& aRect );
       
    40 
       
    41     // the current highlighted rect to fade in
       
    42     TRect iCurrentRect;
       
    43     // old rect to rub out
       
    44     TRect iCurrentRectOld;
       
    45     // the previous rect to fade out
       
    46     TRect iPreviousRect;
       
    47     // old rect to rub out
       
    48     TRect iPreviousRectOld;
       
    49     // the icon rect to fade out
       
    50     TRect iIconRectFadeOut;
       
    51     // old rect to rub out
       
    52     TRect iIconRectFadeOutOld;
       
    53     // the icon rect to fade in
       
    54     TRect iIconRectFadeIn;
       
    55     // old rect to rub out
       
    56     TRect iIconRectFadeInOld;
       
    57     // the title rect to fade out
       
    58     TRect iTitleFadeOut;
       
    59     // old rect to rub out
       
    60     TRect iTitleFadeOutOld;
       
    61     // the title rect to fade in
       
    62     TRect iTitleFadeIn;
       
    63     // old rect to rub out
       
    64     TRect iTitleFadeInOld;
       
    65     // the pen color to use fading out
       
    66     TRgb iPenFadeOut;
       
    67     // the pen color to use fading in
       
    68     TRgb iPenFadeIn;
       
    69     // icon to fade out
       
    70     const CFbsBitmap* iIconFadeOut;
       
    71     // icon to fade in
       
    72     const CFbsBitmap* iIconFadeIn;
       
    73     // moving down the list
       
    74     TBool iMovingDown;
       
    75     // amount of pixels to animate the fade in/out
       
    76     TBool iDeltaY;
       
    77     // amount of pixels to scroll the list by
       
    78     TBool iScrollingY;
       
    79     // current step in the animation
       
    80     TInt iStep;
       
    81     // amount to add to the left margin when fading icons in/out
       
    82     TReal iIconLeftInc;     
       
    83     // left margin offset for drawing the icon when fading in/out
       
    84     TReal iIconLeftOffset;  
       
    85     // off screen bitmap to assist with the scrolling of the list
       
    86     CFbsBitmap* iOffScreenBitmap;
       
    87     // is the list in scrolling mode
       
    88     TBool iScrolling;
       
    89     // the position of the off screen bitmap
       
    90     TPoint iOffScreenPos;
       
    91     };
       
    92 
       
    93 // the size of the icons used during fading
       
    94 enum TCamIconSize
       
    95     {
       
    96     ECamIconSizeLarge,
       
    97     ECamIconSizeSmall,
       
    98     ECamIconSizeOne,
       
    99     ECamIconSizeTwo,
       
   100     ECamIconSizeThree,
       
   101     ECamIconSizeFour,
       
   102     ECamIconSizeFive,
       
   103     ECamIconSizeSix
       
   104     };
       
   105 
       
   106 // FORWARD DECLARATIONS
       
   107 class CAknView;
       
   108 
       
   109 // CLASS DECLARATION
       
   110 
       
   111 class CCamSceneSettingItem : public CBase
       
   112     {
       
   113     public:
       
   114 
       
   115         /**
       
   116         * Symbian OS two-phased constructor
       
   117         * @since 2.8
       
   118         * @param aSceneId Id of scene to create
       
   119         * @param aLargeBmpSize the size of the largest icon to use
       
   120         * @param aSmallBmpSize the size of the smallest icon to use
       
   121         */
       
   122         static CCamSceneSettingItem* NewL( TCamSceneId aSceneId,
       
   123                                            const TSize& aLargeBmpSize,
       
   124                                            const TSize& aSmallBmpSize ); 
       
   125 
       
   126         /**
       
   127         * Destructor.
       
   128         * @since 2.8
       
   129         */
       
   130         virtual ~CCamSceneSettingItem();
       
   131 
       
   132         /**
       
   133         * Returns the scene id
       
   134         * @return the scene id for this item
       
   135         * @since 2.8
       
   136         */
       
   137         TCamSceneId SceneId() const;
       
   138         
       
   139         /**
       
   140         * returns the bitmap for the given size
       
   141         * @param aSize     The bitmap size to return
       
   142         * @return The bitmap for the size given
       
   143         * @since 2.8
       
   144         */
       
   145         const CFbsBitmap* Icon( TCamIconSize aSize ) const;
       
   146 
       
   147         /**
       
   148         * returns the item title
       
   149         * @return the item title
       
   150         * @since 2.8
       
   151         */
       
   152         const HBufC* Title() const;
       
   153 
       
   154         /**
       
   155         * returns the item description
       
   156         * @return the item description
       
   157         * @since 2.8
       
   158         */
       
   159         const HBufC* Description() const;
       
   160 
       
   161 
       
   162     private:
       
   163 
       
   164         /**
       
   165         * Symbian OS 2nd phase constructor.
       
   166         * @param aLargeBmpSize the size of the largest icon to use
       
   167         * @param aSmallBmpSize the size of the smallest icon to use
       
   168         * @since 2.8
       
   169         */
       
   170         void ConstructL( const TSize& aLargeBmpSize, 
       
   171                          const TSize& aSmallBmpSize );
       
   172 
       
   173         /**
       
   174         * C++ constructor
       
   175         * @param aSceneId Id of scene to create
       
   176         * @since 2.8
       
   177         */
       
   178         CCamSceneSettingItem( TCamSceneId aSceneId );
       
   179 
       
   180     private:
       
   181         // the bitmap for non-highlighted items
       
   182         CFbsBitmap* iBitmapSmall;
       
   183         // bitmap 1 in the fade in/out animation
       
   184         CFbsBitmap* iBitmap1;
       
   185         // bitmap 2 in the fade in/out animation
       
   186         CFbsBitmap* iBitmap2;
       
   187         // bitmap 3 in the fade in/out animation
       
   188         CFbsBitmap* iBitmap3;
       
   189         // bitmap 4 in the fade in/out animation
       
   190         CFbsBitmap* iBitmap4;
       
   191         // bitmap 5 in the fade in/out animation
       
   192         CFbsBitmap* iBitmap5;
       
   193         // bitmap 6 in the fade in/out animation
       
   194         CFbsBitmap* iBitmap6;
       
   195         // the bitmap to use for highlighted items
       
   196         CFbsBitmap* iBitmapLarge;
       
   197         // the title of the item
       
   198         HBufC* iTitle;
       
   199         // the description of the icon
       
   200         HBufC* iDescription;
       
   201         // the scene id of the item
       
   202         TCamSceneId iSceneId;
       
   203 
       
   204     };
       
   205 
       
   206 
       
   207 /**
       
   208 * Container for still image Post capture view
       
   209 */
       
   210 class CCamSceneSettingContainer : public CCamContainerBase, 
       
   211                                   public MEikScrollBarObserver
       
   212             {
       
   213     public: // Constructors and destructor
       
   214         
       
   215         /**
       
   216         * Symbian OS two-phased constructor
       
   217         * @since 2.8
       
   218         * @param aRect Frame rectangle for container.
       
   219         * @param aView Reference to the view containing this container
       
   220         * @param aMode Current capture mode
       
   221         * @param aController reference to CCamAppControllerBase instance
       
   222         * @param aUserBaseScenes Specifies whether this list should
       
   223         * display the base scenes for the user scene.
       
   224         */
       
   225         static CCamSceneSettingContainer* NewL( const TRect& aRect, 
       
   226                                                  CAknView& aView,
       
   227                                                  TCamCameraMode aMode,
       
   228                                                  CCamAppController& aController,
       
   229                                                  TBool aUserBaseScenes = EFalse );
       
   230 
       
   231         /**
       
   232         * Destructor.
       
   233         * @since 2.8
       
   234         */
       
   235         virtual ~CCamSceneSettingContainer();
       
   236 
       
   237     private:
       
   238         /**
       
   239         * Symbian OS 2nd phase constructor.
       
   240         * @since 2.8
       
   241         * @param aRect Frame rectangle for container.
       
   242         */
       
   243         void ConstructL( const TRect& aRect );
       
   244 
       
   245         /**
       
   246         * Reads the layout info from the resource
       
   247         * @since 2.8
       
   248         * @param aResourceId The resource containing the layout info
       
   249         * @param aArray The array to add the layout info to.
       
   250         */
       
   251         void ReadLayoutL( TInt aResourceId, RArray<TAknLayoutRect>& aArray ) const;
       
   252         void ReadLayoutL( TInt aResourceId, RArray<TAknLayoutText>& aArray ) const;
       
   253 
       
   254         /**
       
   255         * C++ constructor
       
   256         * @since 2.8
       
   257         * @param aMode Current capture mode
       
   258         * @param aController reference to CCamAppControllerBase instance
       
   259         * @param aView Reference to the view containing this container
       
   260         * @param aUserBaseScenes Specifies whether this list should
       
   261         * display the base scenes for the user scene.
       
   262         */
       
   263         CCamSceneSettingContainer( TCamCameraMode aMode, 
       
   264                                     CCamAppController& aController,
       
   265                                     CAknView& aView,
       
   266                                     TBool aUserBaseScenes );
       
   267 
       
   268     public: // New functions
       
   269         /**
       
   270         * Is the user scene currently selected
       
   271         * @since 2.8
       
   272         * @return ETrue if user scene highlighted
       
   273         */
       
   274         TBool UserSceneHighlighted();
       
   275 
       
   276         /** 
       
   277         * Saves the selected scene in dynamic settings
       
   278         * @since 2.8
       
   279         * @return ETrue if the scene setting was changed successfully.
       
   280         */
       
   281         TBool SaveSceneSettingL();
       
   282         
       
   283     protected: // Functions from base classes
       
   284         /**
       
   285         * From CoeControl
       
   286         * @since 2.8
       
   287         * @return number of contained controls
       
   288         */
       
   289         TInt CountComponentControls() const;
       
   290 
       
   291         /**
       
   292         * From CCoeControl
       
   293         * @since 2.8
       
   294         * @param aIndex The index of the required control
       
   295         * @return Returns the requested control
       
   296         */
       
   297         CCoeControl* ComponentControl( TInt aIndex ) const;
       
   298 
       
   299         /**
       
   300         * From CCoeControl
       
   301         * @since 2.8
       
   302         * @param aRect area where to draw
       
   303         */
       
   304         void Draw( const TRect& aRect ) const;
       
   305 
       
   306         /**
       
   307         * From CamContainerBase 
       
   308         * @since 2.8
       
   309         * @param aKeyEvent the key event
       
   310         * @param aType the type of the event
       
   311         * @return TKeyResponse key event was used by this control or not
       
   312         */
       
   313         TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent,
       
   314                                      TEventCode aType );
       
   315 
       
   316         /**
       
   317         * From MEikScrollBarObserver
       
   318         * Called when a new thumbnail has been generated       
       
   319         * @since 2.8
       
   320         * @param aScrollBar
       
   321         * @param aEventType
       
   322         */
       
   323         void HandleScrollEventL( CEikScrollBar* aScrollBar, TEikScrollEvent aEventType );
       
   324 
       
   325     private: 
       
   326 
       
   327         /**
       
   328         * Sets up the scroll bar, used on start up and when items are deleted
       
   329         * to update the state
       
   330         * @since 2.8
       
   331         */
       
   332         void SetupScrollbarL();
       
   333 
       
   334         /**
       
   335         * Populates iSettingItemArray with scenes
       
   336         * and scene bitmaps from the MBM file
       
   337         * @param aResourceId resource id for scene array.
       
   338         * @since 2.8
       
   339         */
       
   340         void CreateSceneArrayL( TInt aResourceId );
       
   341 
       
   342         /**
       
   343         * Sets the current position of the scene array to the element
       
   344         * associated with a particular scene id.
       
   345         * @param aSceneId the id of the scene.
       
   346         * @since 2.8
       
   347         */
       
   348         void SetCurrentPositionToScene( TCamSceneId aSceneId );
       
   349 
       
   350         /**
       
   351         * Called to start the amination
       
   352         * @since 2.8
       
   353         */
       
   354         void StartAnimation();
       
   355 
       
   356         /**
       
   357         * Called when the animation timer expires
       
   358         * @since 2.8
       
   359         * @param aPtr pointer to the object that called the timer
       
   360         * @return Error code
       
   361         */
       
   362         static TInt TimerExpired( TAny* aPtr );
       
   363 
       
   364         /**
       
   365         * Animates the list
       
   366         * @since 2.8
       
   367         */
       
   368         void Animate();
       
   369 
       
   370         /**
       
   371         * Updates the highlight on each call of Animate
       
   372         * @since 2.8
       
   373         * @returns ETrue if the highlight has finished updating
       
   374         */
       
   375         TBool UpdateHighlight();
       
   376 
       
   377         /**
       
   378         * Updates the pen/icons on each call of Animate
       
   379         * @since 2.8
       
   380         */
       
   381         void UpdateAnimationData();
       
   382 
       
   383         /**
       
   384         * Draws the text on each call of Animate
       
   385         * @since 2.8
       
   386         * @param aText  The text to draw
       
   387         * @param aFont  The font to use for drawing
       
   388         * @param aBaseline  The baseline of the text
       
   389         * @param aFadeOut Whether text is fading in/out
       
   390         */
       
   391         void DrawText( const TDesC& aText, const CAknLayoutFont* aFont, 
       
   392                        TInt aBaseline, TBool aFadeOut ) const;
       
   393 
       
   394         /**
       
   395         * Draws the icons on each call of Animate
       
   396         * @since 2.8
       
   397         * @param aFadeOut whether the icon to draw is fading in/out
       
   398         */
       
   399         void DrawIcon( TBool aFadeOut );
       
   400 
       
   401         /**
       
   402         * Draws the highlight on each call of Animate
       
   403         * @since 2.8
       
   404         */
       
   405         void DrawHighlight() const;
       
   406 
       
   407         /**
       
   408         * Draws the list onto an off screen bitmap for
       
   409         * scrolling purposes
       
   410         * @since 2.8
       
   411         */
       
   412         void DrawListL();
       
   413 
       
   414         /**
       
   415         * Animates the list when scrolling occurs
       
   416         * @since 2.8
       
   417         * @return ETrue if the scrolling has completed
       
   418         */
       
   419         TBool ScrollList();
       
   420 
       
   421         /**
       
   422         * Moves the highlight position ready for animating
       
   423         * @since 2.8
       
   424         */
       
   425         void MoveHighlight();
       
   426 
       
   427     private: // data
       
   428 
       
   429         // Array containing all pointers to all scene items
       
   430         RPointerArray<CCamSceneSettingItem> iSettingItemArray;
       
   431         // Arrays to store the layout data for the list
       
   432         // large icon positions
       
   433         RArray<TAknLayoutRect> iHighlightIcons;
       
   434         // default icon positions
       
   435         RArray<TAknLayoutRect> iNormalIcons;
       
   436         // displaced icon positions
       
   437         RArray<TAknLayoutRect> iDisplacedIcons;
       
   438         // highlight positions
       
   439         RArray<TAknLayoutRect> iHighlightArray;
       
   440         // highlighted title positions
       
   441         RArray<TAknLayoutText> iHighlightTitles;
       
   442         // highlighted decsription positions
       
   443         RArray<TAknLayoutText> iHighlightDescriptions;
       
   444         // default title positions
       
   445         RArray<TAknLayoutText> iNormalTitles;
       
   446         // displaced title positions
       
   447         RArray<TAknLayoutText> iDisplacedTitles;
       
   448         // current highlight position
       
   449         TInt iCurrentArrayPosition;
       
   450         // previous highlight position
       
   451         TInt iPreviousArrayPosition;
       
   452         // position in array of item at the top of screen
       
   453         TInt iTopDisplayPosition;
       
   454         // number of icons to display on screen at any time
       
   455         TInt iNumberOfIconsToDisplay;
       
   456         // the capture mode
       
   457         TCamCameraMode iMode;
       
   458         // Specifies whether or not the scene list is for 
       
   459         // the user base scenes
       
   460         TBool iUserBaseScenes;
       
   461         // An animation timer object
       
   462         CPeriodic*     iAnimTimer;
       
   463         // Animation Data
       
   464         TCamAnimationData iAnimData;
       
   465         // the scrollbar frame
       
   466         CEikScrollBarFrame* iScrollFrame;
       
   467         // the model to use for the scrollbar
       
   468         TAknDoubleSpanScrollBarModel ivModel;
       
   469         // the position of the scrollbar
       
   470         TAknLayoutRect iScrollLayout;
       
   471 
       
   472     };
       
   473 
       
   474 #endif // CAMSCENESETTINGCONTAINER_H
       
   475 
       
   476 // End of File