photosgallery/viewframework/visuallistmanager/inc/glxvisualiconmanager.h
changeset 0 4e91876724a2
equal deleted inserted replaced
-1:000000000000 0:4e91876724a2
       
     1 /*
       
     2 * Copyright (c) 2008-2009 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:    Icon manager for visuals
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 /**
       
    22  * @internal reviewed 31/07/2007 by Rowland Cook
       
    23  */
       
    24  
       
    25 
       
    26 #ifndef C_GLXVISUALICONMANAGER_H
       
    27 #define C_GLXVISUALICONMANAGER_H
       
    28 
       
    29 #include <e32base.h>
       
    30 
       
    31 #include "glxiconmanager.h"
       
    32 #include <mglxanimationobserver.h>
       
    33 #include "mglxvisualobjectstatusobserver.h"
       
    34 #include <alf/alftexture.h>
       
    35 #include <glxmedia.h>
       
    36 
       
    37 // FORWARD DECLARES
       
    38 struct TIconInfo;
       
    39 class CAlfVisual;
       
    40 class TGlxMediaId;
       
    41 class CAlfTexture;
       
    42 class CGlxTextureManager;
       
    43 
       
    44 /**
       
    45  *  CGlxVisualIconManager
       
    46  * 
       
    47  *  Icon manager for visuals
       
    48  *  Handles adding default or broken icon if required.
       
    49  *  If thumbnail not present look for icon attribute
       
    50  *  @author M Byrne
       
    51  *	@lib glxvisuallistmanager 
       
    52  */
       
    53 NONSHARABLE_CLASS( CGlxVisualIconManager ) : public CGlxIconManager,
       
    54         public MGlxAnimationObserver, public MGlxVisualObjectStatusObserver
       
    55 	{
       
    56 	public:
       
    57 	    /**
       
    58 	      * Static constructor
       
    59 	      * @param aMediaList reference to media list
       
    60 	      * @param aVisualList reference to associated visual list
       
    61 	      * @return pointer to CGlxVisualIconManager instance
       
    62 	      */
       
    63 		IMPORT_C static CGlxVisualIconManager* NewL(MGlxMediaList& aMediaList,
       
    64 		                                            MGlxVisualList& aVisualList);
       
    65 
       
    66 		/**
       
    67 		 * Destructor
       
    68 		 */	
       
    69 		IMPORT_C ~CGlxVisualIconManager();
       
    70 	
       
    71 		/**
       
    72 		 * Trigger the image-loading animation
       
    73 		 * @param aItemIndex Index of item to animate
       
    74 		 */
       
    75 	    IMPORT_C void AnimateImageLoadedL(TInt aItemIndex);
       
    76 
       
    77 	public: // from MGlxAnimationObserver
       
    78 		virtual void AnimationComplete(MGlxAnimation* aAnimation);
       
    79 
       
    80     private:    // From MGlxVisualObjectStatusObserver
       
    81         void VisualStatusChangedL( CGlxVisualObject& aObject,
       
    82                                 TInt aListIndex, TBool aHasThumbnail );
       
    83         void ThumbnailLoadedL( CGlxVisualObject& aObject );
       
    84 
       
    85 	private:
       
    86 	    /**
       
    87 	      * Identifiers for default and broken icons
       
    88 	      */
       
    89 	      enum TGlxVisualIcon
       
    90 	        {
       
    91 	        EDefaultIcon,
       
    92 	        EBrokenIcon,
       
    93 	        EEmptyIcon,
       
    94 	        EBlackBrush
       
    95 	        };
       
    96 		
       
    97 	private:
       
    98 	    /**
       
    99 	      * Constructor
       
   100 	      * @param aMediaList refernce to media list
       
   101 	      * @param aVisualList reference to associated visual list
       
   102 	      */
       
   103 	    CGlxVisualIconManager(
       
   104 	        CGlxTextureManager& aTextureManager,
       
   105 	        MGlxMediaList& aMediaList, 
       
   106 	        MGlxVisualList& aVisualList );
       
   107 		void ConstructL();
       
   108 		
       
   109 		/**
       
   110 		  * Check if thumbnail attribute is present for specifed vis.
       
   111 		  * If not add icon if present or add default icon
       
   112 		  * @param aIndex index of item in media list
       
   113 		  */ 
       
   114 		void CheckThumbnailAttributesL( TInt aIndex );
       
   115 
       
   116 		/**
       
   117 		 * Trigger the image-loading animation
       
   118 		 * @param aItemVisual Visual of item to animate
       
   119 		 */
       
   120 	    void AnimateImageLoadedL(CAlfVisual* aItemVisual);
       
   121 	    /**
       
   122 	     * Helper function used be HandleError
       
   123 	     * @param aError the error code to handle.
       
   124 	     */
       
   125 	    void DoHandleErrorL( TInt aError );
       
   126 
       
   127         /**
       
   128          * Select the icon to be used for a visual.
       
   129          * @param aIndex Index of item in media list
       
   130          * @return Pointer to an icon texture.
       
   131          */
       
   132         const CAlfTexture* SelectIconTextureL( TInt aIndex );
       
   133 
       
   134         /**
       
   135          * Helper method to compare two icons
       
   136          */
       
   137         static TBool MatchIcon( const TIconInfo& aIcon1,
       
   138                                 const TIconInfo& aIcon2 );
       
   139         
       
   140         /**
       
   141          * Helper function to determine if an item is a DRM protected video.
       
   142          * @param aItem, the item to test
       
   143          * @return ETrue if the item is a DRM protected video, EFalse otherwise
       
   144          */
       
   145      	TBool IsDrmVideoItem( const TGlxMedia& aItem );
       
   146 
       
   147 	private:
       
   148 		/** @see MGlxVisualListObserver::HandleVisualAddedL */
       
   149 		void HandleVisualAddedL( CAlfVisual* aVisual, TInt aIndex, MGlxVisualList* aList );
       
   150 	    
       
   151 	    /** @see MGlxMediaListObserver::HandleError */
       
   152 	    void HandleError( TInt aError );
       
   153 
       
   154 	private:
       
   155         /// @ref texture manager
       
   156 	    CGlxTextureManager& iTextureManager;
       
   157 	    
       
   158 	    // array of thumbnail icons added via icon attribute
       
   159 	    RArray<TIconInfo> iThumbnailIcons;
       
   160 
       
   161 		/// White texture for image-loading "flash" effect
       
   162 	    CAlfTexture* iWhiteTexture;
       
   163 	    
       
   164 	    /// List of current animations, maintained in address order
       
   165 	    RPointerArray<MGlxAnimation> iAnimations;
       
   166 
       
   167         // texture for default icon overlay not owned
       
   168 	    CAlfTexture* iDefaultIconTexture;
       
   169 	    
       
   170 	    // texture for broken icon overlay not owned
       
   171 	    CAlfTexture* iBrokenIconTexture;
       
   172 	    
       
   173 	    // texture for empty icon overlay not owned
       
   174 	    CAlfTexture* iEmptyIconTexture;
       
   175 	    
       
   176 	    // array of icon textures (textures not owned)
       
   177 	    RPointerArray< CAlfTexture > iIconTextureArray;
       
   178 	};
       
   179 	
       
   180 #endif // C_GLXVISUALICONMANAGER_H