camerauis/activepalette/Inc/ActivePalette2Model.h
branchRCL_3
changeset 54 bac7acad7cb3
parent 0 1ddebce53859
equal deleted inserted replaced
53:61bc0f252b2b 54: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:  Active Palette model*
       
    15 */
       
    16 
       
    17 
       
    18 /**
       
    19  * @file ActivePalette2Model.h
       
    20  * Active Palette model
       
    21  */
       
    22 
       
    23 #ifndef _ACTIVE_PALETTE_2_MODEL_H
       
    24 #define _ACTIVE_PALETTE_2_MODEL_H
       
    25 
       
    26 //  INCLUDES
       
    27 #include <e32std.h>
       
    28 
       
    29 #include <activepalette2ui.h>
       
    30 #include "CActivePalettePluginBase.h"
       
    31 #include "ActivePalette2Cfg.h"
       
    32 #include "activepalette2configuration.h"
       
    33 
       
    34 // FORWARD DECLARATIONS
       
    35 class CActivePalette2Item;
       
    36 class CActivePalette2IDHolder;
       
    37 class TActivePalette2EventData;
       
    38 class MActivePalette2Observer;
       
    39 class TActivePalette2ItemVisible;
       
    40 class MActivePalette2ModelObserver;
       
    41 class MActivePalette2TooltipTimerObserver;
       
    42 class MActivePalette2FocusTimerObserver;
       
    43 class MActivePalette2ItemScrollTimerObserver;
       
    44 class MActivePalette2AppearanceTimerObserver;
       
    45 class MActivePalette2TooltipDescriptiveObserver;
       
    46 class MActivePalette2FocusDescriptiveObserver;
       
    47 class MActivePalette2ItemScrollDescriptiveObserver;
       
    48 class MActivePalette2AppearanceDescriptiveObserver;
       
    49 
       
    50 /**
       
    51  * The type of user input detected.
       
    52  * @see CActivePalette2Model::ProcessInputEvent()
       
    53  */
       
    54 enum TActivePalette2InputEvent {
       
    55     EAP2InputUp,     ///< User pressed up
       
    56     EAP2InputDown,   ///< User pressed down
       
    57     EAP2InputSelect  ///< User selected
       
    58 };
       
    59 
       
    60 // CLASS DECLARATIONS
       
    61 
       
    62 
       
    63 /**
       
    64  * Describes the type of callback the renderer would like for all animations
       
    65  * @see CActivePalette2Model::NewL()
       
    66  */
       
    67 class TRendererCallBacks
       
    68     {
       
    69 public:
       
    70     /**
       
    71      * Constructor
       
    72      * By default, all categories are set to TRendererCallBackApiType::ERendererCallBackApiTypeTimer
       
    73      */
       
    74     TRendererCallBacks();
       
    75 
       
    76     MActivePalette2TooltipTimerObserver*            iTooltipTimer;
       
    77     MActivePalette2FocusTimerObserver*              iFocusTimer;
       
    78     MActivePalette2ItemScrollTimerObserver*         iItemScrollTimer;
       
    79     MActivePalette2AppearanceTimerObserver*         iAppearanceTimer;
       
    80     MActivePalette2TooltipDescriptiveObserver*      iTooltipDescriptive;
       
    81     MActivePalette2FocusDescriptiveObserver*        iFocusDescriptive;
       
    82     MActivePalette2ItemScrollDescriptiveObserver*   iItemScrollDescriptive;
       
    83     MActivePalette2AppearanceDescriptiveObserver*   iAppearanceDescriptive;
       
    84     };
       
    85 
       
    86 
       
    87 /**
       
    88  * Active Palette model. Contains all internal logic of the AP.
       
    89  */
       
    90 class CActivePalette2Model : public CBase, public MActivePalette2UI
       
    91     {
       
    92 public:
       
    93 /// @name Object construction & deletion
       
    94 //@{
       
    95     /**
       
    96      * Destructor
       
    97      */
       
    98 	virtual ~CActivePalette2Model();
       
    99 	
       
   100 	
       
   101     /**
       
   102      * 2 phase construction
       
   103      * @param aModelObserver A reference to the observer
       
   104      * @param aItemSize      The size of the item icons
       
   105      * @param aCallbacks     The callback styles to use
       
   106      * @param aConfiguration The runtime configuration provider. Can be NULL.
       
   107      * @return The newly-constructed object
       
   108      */
       
   109 	static CActivePalette2Model* NewL( 
       
   110 	  MActivePalette2ModelObserver& aModelObserver,
       
   111 		TSize                         aItemSize, 
       
   112 		const TRendererCallBacks&     aCallbacks,
       
   113 		CActivePalette2Configuration* aConfiguration = NULL );
       
   114 
       
   115 //@}
       
   116 
       
   117 public:
       
   118 /// @name From MActivePalette2UI
       
   119 //@{
       
   120 	virtual TInt InstallItemL(const TActivePalette2ItemVisible& aItemVisible, 
       
   121 						const TUid& aPluginUid, 
       
   122 						const TDesC8& aCustomDataDes);
       
   123 	virtual TInt InstallItemL(const TActivePalette2ItemVisible& aItemVisible,
       
   124 						const TUid& aPluginUid, 
       
   125 						TInt aCustomDataInt = 0);
       
   126 	virtual TInt InstallItemL(const TActivePalette2ItemVisible& aItemVisible,
       
   127 						const TUid& aPluginUid, 
       
   128 						TInt aCustomDataInt, 
       
   129 						const TDesC8& aCustomDataDes);
       
   130 	virtual TInt RemoveItem(TInt aItemId);
       
   131 	virtual TInt SetItemVisibility(TInt aItemId, TBool aIsVisible);
       
   132 	virtual TInt GetItemVisibility(TInt aItemId, TBool &aIsVisible) const;
       
   133     virtual TInt GetItemList(RArray<TActivePalette2ItemVisible>& aItemVisibleList) const;
       
   134     virtual TInt SetItemList(const RArray<TActivePalette2ItemVisible>& aItemVisibleList);
       
   135 	virtual TInt SendMessage(TInt aItemId, TInt aMessageId, const TDesC8& aDataDes);
       
   136 	virtual TInt SendMessage(TInt aItemId, TInt aMessageId, TInt aDataInt);
       
   137 	virtual TInt GetCurrentItem(TInt& aItemId) const;
       
   138 	virtual TInt SetCurrentItem(TInt aItemId);
       
   139     virtual TInt SetPaletteVisibility(TBool aVisible, TBool aAnimated, TInt aDelayedStartMilliseconds = 0);
       
   140     virtual TInt SetPaletteVisibilityAnimationDuration(TInt aTimeInMilliseconds);
       
   141     virtual TInt GetPaletteVisibilityAnimationDuration(TInt& aTimeInMilliseconds) const;
       
   142     virtual TInt GetAvailablePlugins(RArray<TUid>& aPluginList) const;
       
   143 	virtual void LocateTo(const TPoint& aTopLeft);
       
   144 	virtual TPoint Location() const;
       
   145     virtual CCoeControl* CoeControl();
       
   146     virtual CHuiControl* HuiControl();
       
   147     virtual void SetGc(CBitmapContext* aGc = NULL);
       
   148     virtual void RenderActivePalette(const TRect& aRect) const;
       
   149     virtual void SetObserver(MActivePalette2Observer* aObserver);
       
   150     virtual void SetNavigationKeys(const TActivePalette2NavigationKeys& aNavigationKeys);
       
   151 //@}
       
   152 
       
   153 
       
   154 public:
       
   155 /// @name Renderer interrogation
       
   156 //@{
       
   157     /**
       
   158      * Returns the number of items on-screen
       
   159      * @return The number of items on-screen
       
   160      */
       
   161     TInt CountItemsOnScreen(void);
       
   162     
       
   163     /**
       
   164      * Whether to show the top scroll indicator
       
   165      * @return Whether to show the top scroll indicator
       
   166      */
       
   167     TBool ShowTopScrollIndicator(void);
       
   168     
       
   169     /**
       
   170      * Whether to show the bottom scroll indicator
       
   171      * @return Whether to show the bottom scroll indicator
       
   172      */
       
   173     TBool ShowBottomScrollIndicator(void);
       
   174     
       
   175     /**
       
   176      * Gets the item at the given screen position
       
   177      * @return The item at that position
       
   178      */
       
   179     CActivePalette2Item* ItemFromScreenPos(TInt aScreenPos);
       
   180 
       
   181     /**
       
   182      * The current tooltip text
       
   183      * @return The current tooltip text
       
   184      */
       
   185     TDesC* TooltipText();
       
   186     
       
   187     /**
       
   188      * Whether any tooltip should be currently shown
       
   189      * @return Whether any tooltip should be currently shown
       
   190      */
       
   191     TBool ShowTooltip();
       
   192     
       
   193     /**
       
   194      * The current tooltip frame.
       
   195      * The entire animation will consist of frames 0 to TooltipTotalFrames(), and may be played backwards
       
   196      * as well as forwards.
       
   197      * @return Current frame of tooltip animation to show
       
   198      */
       
   199     TInt TooltipCurrentFrame();
       
   200     
       
   201     /**
       
   202      * Total number of frames in a complete tooltip animation
       
   203      * @return Total frames
       
   204      */
       
   205     TInt TooltipTotalFrames();
       
   206     
       
   207     /**
       
   208      * The screen position of the item showing a tooltip
       
   209      * @return The Screen pos
       
   210      */
       
   211     TInt TooltipScreenPosition();
       
   212 
       
   213     /**
       
   214      * The currently focused item
       
   215      * @return The focused item
       
   216      */
       
   217     TInt FocusedItem();
       
   218 
       
   219     /**
       
   220      * The current focus offset.
       
   221      * The entire animation will consist of frames 0 to FocusCurrentTotalOffsetFrames(), and may be played backwards
       
   222      * as well as forwards.
       
   223      * The focus ring's position should be the position of FocusedItem() + this offset, correctly scaled
       
   224      * @return Current offset of focus ring animation to show
       
   225      */
       
   226     TInt FocusCurrentOffset();
       
   227 
       
   228     /**
       
   229      * Total number of frames in a complete focus-change animation
       
   230      * @return Total frames
       
   231      */
       
   232     TInt FocusCurrentTotalOffsetFrames();
       
   233 
       
   234     /**
       
   235      * The current item scroll offset.
       
   236      * The entire animation will consist of frames 0 to ItemScrollTotalFrames(), and may be played backwards
       
   237      * as well as forwards.
       
   238      * The top item's offset should be moved upwards an amount calculated from this offset.
       
   239      * @return Current offset of item scroll animation to show
       
   240      */
       
   241     TInt ItemScrollOffset();
       
   242 
       
   243     /**
       
   244      * Total number of frames in a complete item-scroll animation
       
   245      * @return Total frames
       
   246      */
       
   247     TInt ItemScrollTotalFrames();
       
   248 
       
   249     /**
       
   250      * Whether the palette is open for user input or not
       
   251      * @return Whether user input is accepted
       
   252      */
       
   253     TBool PaletteActive();
       
   254 
       
   255     /**
       
   256      * The current appearance frame.
       
   257      * The entire animation will consist of frames 0 to PaletteAppearingTotalFrames(), and may be played backwards
       
   258      * as well as forwards.
       
   259      * @return Current frame of appearance animation to show
       
   260      */
       
   261     TInt PaletteAppearingCurrentFrame();        
       
   262 
       
   263     /**
       
   264      * Total number of frames in a complete appearance animation
       
   265      * @return Total frames
       
   266      */
       
   267     TInt PaletteAppearingTotalFrames();        
       
   268 
       
   269     /**
       
   270      * The current item's animation info
       
   271      * @return The current item's animation info
       
   272      */
       
   273     CActivePalettePluginBase::TPluginAnimationInfo ItemAnimInfo();
       
   274 //@}
       
   275 
       
   276 public:
       
   277 /// @name User input
       
   278 //@{
       
   279     /**
       
   280      * Process a user input event
       
   281      * @param aEvent The event to process
       
   282      * @return Whether the input has been consumed
       
   283      */
       
   284     TBool ProcessInputEvent(TActivePalette2InputEvent aEvent);
       
   285 //@}
       
   286 
       
   287 public:
       
   288 /// @name Descriptive callbacks
       
   289 //@{
       
   290     /**
       
   291      * Signal that the focus-change animation has completed
       
   292      */
       
   293     void AnimateFocusRendererComplete();
       
   294 
       
   295     /**
       
   296      * Signal that the palette-appearance animation has completed
       
   297      */
       
   298     void AnimateAppearanceRendererComplete();
       
   299 
       
   300     /**
       
   301      * Signal that the item-scroll animation has completed
       
   302      */
       
   303     void AnimateItemScrollRendererComplete();
       
   304 
       
   305     /**
       
   306      * Signal that the tooltip animation has completed
       
   307      */
       
   308     void AnimateTooltipRendererComplete();
       
   309 //@}
       
   310 
       
   311 public:
       
   312 /// @name Item collaboration
       
   313 //@{    
       
   314     /**
       
   315      * Returns the model observer
       
   316      * @return A reference to the model observer
       
   317      */
       
   318 	MActivePalette2ModelObserver& Observer(void) const;
       
   319 
       
   320     /**
       
   321      * Returns the item icon dimensions
       
   322      * @return The item size
       
   323      */
       
   324     TSize ItemSize();
       
   325 
       
   326     /**
       
   327      * Item selection
       
   328      * @param aItem A reference to the item
       
   329      * @param aResult The result value
       
   330      * @param aDataDes Data descriptor
       
   331      * @param aDataInt Data integer
       
   332      */ 
       
   333 	void NotifyItemComplete(const CActivePalette2Item& aItem,
       
   334 	                                TInt aResult,
       
   335 	                                const TDesC8& aDataDes,
       
   336 	                                TInt aDataInt);
       
   337 
       
   338     /**
       
   339      * Message arrived
       
   340      * @param aItem A reference to the item
       
   341      * @param aResult The result value
       
   342      * @param aMessageID The message ID
       
   343      * @param aDataDes Data descriptor
       
   344      * @param aDataInt Data integer
       
   345      */ 
       
   346 	void NotifyMessage(const CActivePalette2Item& aItem,
       
   347 	                           const TInt aResult,
       
   348 	                           const TInt aMessageID,
       
   349 	                           const TDesC8& aDataDes,
       
   350 	                           TInt aDataInt);
       
   351 
       
   352     /**
       
   353      * Graphics changes
       
   354      * @param aItem A reference to the item
       
   355      * @param aIsIconChanged Indicates if the icon has changed
       
   356      * @param aIsTooltipChanged Indicates if the toolip text has chaned
       
   357      */ 
       
   358 	void NotifyGraphicsChanged(const CActivePalette2Item& aItem,
       
   359 	                                   const TBool aIsIconChanged,
       
   360 	                                   const TBool aIsTooltipChanged);
       
   361 //@}
       
   362     	
       
   363     
       
   364 private:
       
   365 /// @name Object construction helpers
       
   366 //@{
       
   367     /**
       
   368      * Constructor
       
   369      */
       
   370 	CActivePalette2Model( MActivePalette2ModelObserver& aModelObserver,
       
   371 						            TSize                         aItemSize, 
       
   372 						            const TRendererCallBacks&     aCallbacks,
       
   373 						            CActivePalette2Configuration* aConfiguration );
       
   374 						
       
   375     /**
       
   376      * Leaving constructor
       
   377      */
       
   378 	void ConstructL(void);
       
   379 //@}
       
   380 
       
   381 
       
   382 private:
       
   383 /// @name Item manipulation
       
   384 //@{
       
   385     /**
       
   386      * Returns an item from a given ID
       
   387      * @param aItemId The item ID to be found
       
   388      * @return A pointer to the item
       
   389      */
       
   390 	CActivePalette2Item* FindItem(TInt aItemId) const;
       
   391 
       
   392     /**
       
   393      * Handles the selection of an item
       
   394      * @param aItemIndex The item ID
       
   395      */
       
   396 	void HandleItemSelected(TInt aItemIndex);
       
   397 	
       
   398     /**
       
   399      * Installs an item
       
   400      * @param aItemId The item's ID
       
   401      * @param aVisible Whether the item is installed as visible
       
   402      * @param aPluginUid The UID of the plugin to handle this item
       
   403      * @param aCustomDataDes Custom data descriptor for the plugin
       
   404      * @param aCustomDataInt Custom data integer for the plugin
       
   405      * @return System-wide error code
       
   406      */
       
   407 	TInt DoInstallItemL(TInt aItemId,
       
   408                         TBool aVisible,
       
   409                         const TUid& aPluginUid,
       
   410                         const TDesC8& aCustomDataDes,
       
   411                         TInt aCustomDataInt);
       
   412 	                                 
       
   413     /**
       
   414      * Sends a message to the plugin handling the specified item
       
   415      * @param aItemId The item's ID
       
   416      * @param aMessageID The ID of the message to send
       
   417      * @param aDataDes Custom data descriptor for the plugin
       
   418      * @param aDataInt Custom data integer for the plugin
       
   419      * @return System-wide error code
       
   420      */
       
   421 	TInt DispatchMessage(TInt aItemId,
       
   422 	                     TInt aMessageID,
       
   423 	                     const TDesC8& aDataDes,
       
   424 	                     TInt aDataInt);
       
   425 
       
   426     /**
       
   427      * Initialize the model's state
       
   428      */
       
   429     void InitialiseConstraints(void);
       
   430     
       
   431     /**
       
   432      * Ensure that the model's state is self-consistent and valid.
       
   433      * Call this after the item or visibility array is changed. May resize the palette, scroll it,
       
   434      * move the focus to a valid item.
       
   435      */
       
   436     void EnforceConstraints(void);
       
   437 
       
   438     /**
       
   439      * Finds the next visible item index, including aStartingItem.
       
   440      * @return The next visible item, or KInvalidItemIndex if none found
       
   441      */
       
   442     TInt FindVisibleItem(TInt aStartingItem);
       
   443     
       
   444     /**
       
   445      * Finds the previous visible item index, including aStartingItem.
       
   446      * @return The previous visible item, or KInvalidItemIndex if none found
       
   447      */
       
   448     TInt PreviousVisibleItem(TInt aStartingItem);
       
   449     
       
   450     /**
       
   451      * Returns the total number of visible items
       
   452      * @return The total number of visible items
       
   453      */
       
   454     TInt CountVisibleItems(TInt aStartingItem);
       
   455     
       
   456     /**
       
   457      * Returns the item index of the given screen position
       
   458      * @param aScreenPos The screen position
       
   459      * @return The item index, or KInvalidItemIndex if none
       
   460      */
       
   461     TInt ItemIndexFromScreenPos(TInt aScreenPos);
       
   462     
       
   463     /**
       
   464      * Given an item index, work out where it is on screen
       
   465      * @param aItem The item index
       
   466      * @return The screen pos
       
   467      */
       
   468     TInt ScreenPosFromItemIndex(TInt aItem);
       
   469     
       
   470     /**
       
   471      * Given an item ID, work out the item index
       
   472      * @param aItemId The item ID
       
   473      * @return The item index, or KInvalidItemIndex
       
   474      */
       
   475     TInt ItemIndexFromId(const TInt aItemId) const;
       
   476     
       
   477     /**
       
   478      * The item index of the lowermost item on-screen.
       
   479      * @return The item index
       
   480      */
       
   481     TInt BottomItemOnScreen(void);
       
   482     
       
   483     /**
       
   484      * Call whenever the items or visibility arrays are updated
       
   485      */
       
   486     void ItemsUpdated();
       
   487 
       
   488     /**
       
   489      * Returns whether a given item index is valid or not
       
   490      * @return Item index validity
       
   491      */
       
   492     TBool ValidItemIndex(TInt aItemIndex) const;
       
   493 //@}
       
   494 	
       
   495 
       
   496 private:
       
   497 /// @name Tooltips
       
   498 //@{
       
   499     /**
       
   500      * Tooltip animation state
       
   501      */
       
   502 	enum TTooltipState
       
   503 	    {
       
   504 		ETooltipInvalid,  ///< Invalid state
       
   505 		ETooltipNone = 2, ///< Tooltip hidden
       
   506 		ETooltipSteady,   ///< Tooltip fully shown
       
   507 		ETooltipRise,     ///< Tooltip appearing
       
   508 		ETooltipSet       ///< Tooltip disappearing
       
   509 	    };
       
   510 
       
   511     /** 
       
   512      * Removes the tooltip
       
   513      */
       
   514 	void RemoveTooltip();
       
   515 	
       
   516 	/**
       
   517 	 * Start a new tooltip animation
       
   518 	 */
       
   519     void CompelTooltip();
       
   520 
       
   521     /** 
       
   522      * Begin the steady animation phase (where the tooltip is fully visible)
       
   523      * @return Error code
       
   524      */
       
   525 	TInt TooltipSteadyAniAction();
       
   526 
       
   527     /** 
       
   528      * Begin the rising animation phase (where the tooltip slides out)
       
   529      * @return Error code
       
   530      */
       
   531 	TInt TooltipRiseAniAction();
       
   532 
       
   533     /** 
       
   534      * Begin the rising animation phase (where the tooltip slides in)
       
   535      * @return Error code
       
   536      */
       
   537 	TInt TooltipDisappearAniAction();
       
   538 
       
   539     /** 
       
   540      * Sets the tooltip's state
       
   541      * @param aState New state
       
   542      */
       
   543 	void TooltipSetState(TTooltipState aState);
       
   544 
       
   545     /** 
       
   546      * Called on tooltip timer tick
       
   547      * @param aPtr Pointer to object that started the timer
       
   548      * @return 0 to signal that further callbacks are unnecessary, 1 otherwise
       
   549      */
       
   550 	static TInt TooltipTimerCallback(TAny * aPtr);
       
   551 
       
   552 private:
       
   553     /// Current tooltip animation state
       
   554 	TTooltipState   				iTooltipState;
       
   555 	
       
   556 	/// Tooltip animation timer. Owned
       
   557 	CPeriodic*						iTooltipTimer;
       
   558 
       
   559     /// Total number of frames in animation
       
   560     TInt iTooltipTotalFrames;
       
   561     /// Current animation frame
       
   562     TInt iTooltipCurrentFrame;
       
   563     /// Whether the tooltip is currently being shown or not
       
   564     TBool iShowTooltip;
       
   565     /// Screen position of the tooltip
       
   566     TInt iTooltipPos;
       
   567 //@}	
       
   568 
       
   569     
       
   570 private:
       
   571 /// @name Animation functions
       
   572 //@{
       
   573     /**
       
   574      * The current animation state of the palette
       
   575      */
       
   576 	enum TPaletteAnimState
       
   577 	    {
       
   578 		EPaletteAnimIdle,           ///< No animation
       
   579 		EPaletteAnimItemScroll,     ///< Item scroll
       
   580 		EPaletteAnimFocusChange,    ///< Focus change
       
   581 		EPaletteAnimItemAnim,       ///< Item animation
       
   582 		EPaletteAnimAppearing       ///< Whole-palette appearance
       
   583 	    };
       
   584 
       
   585     /**
       
   586      * Set current animation state. Stops previous animation (if necessary) and starts new animation (if necessary)
       
   587      * @param aNewState The new animation state
       
   588      */
       
   589     void SetAnimState(TPaletteAnimState aNewState);
       
   590 
       
   591     /**
       
   592      * If any animations are taking place that involves individual items (item-scroll, item-anim, focus-change),
       
   593      * this completes them immediately.
       
   594      */
       
   595     void CompleteAnyItemBasedAnimations();
       
   596 
       
   597     /**
       
   598      * Start a change focus item.
       
   599      * Uses iFocusedItem and iFocusChangeTargetItem to work out what the animation should be
       
   600      */
       
   601     void ChangeFocus();
       
   602 
       
   603     /**
       
   604      * Begin the scroll-items animation
       
   605      * @param aDirection +1 to move the items downwards, -1 to move them upwards
       
   606      */
       
   607     void ScrollItems(TInt aDirection);
       
   608 
       
   609     /** 
       
   610      * Called on focus-change timer tick
       
   611      * @param aPtr Pointer to object that started the timer
       
   612      * @return 0 to signal that further callbacks are unnecessary, 1 otherwise
       
   613      */
       
   614 	static TInt FocusChangeTimerCallback(TAny * aPtr);
       
   615 	
       
   616 	/**
       
   617 	 * Perform action for focus-change animation timer tick.
       
   618      * @return 0 to signal that further callbacks are unnecessary, 1 otherwise
       
   619      */
       
   620     TInt FocusChangeAction();
       
   621     
       
   622     /**
       
   623      * Called when focus-change animation has completed
       
   624      */
       
   625     void FocusChangeComplete();
       
   626     
       
   627     /** 
       
   628      * Called on item-scroll timer tick
       
   629      * @param aPtr Pointer to object that started the timer
       
   630      * @return 0 to signal that further callbacks are unnecessary, 1 otherwise
       
   631      */
       
   632 	static TInt ItemScrollTimerCallback(TAny * aPtr);
       
   633 
       
   634 	/**
       
   635 	 * Perform action for item-scroll animation timer tick.
       
   636      * @return 0 to signal that further callbacks are unnecessary, 1 otherwise
       
   637      */
       
   638     TInt ItemScrollAction();
       
   639 
       
   640     /**
       
   641      * Called when item-scroll animation has completed
       
   642      */
       
   643     void ItemScrollComplete();
       
   644     
       
   645     /**
       
   646      * Called when item-animation is starting
       
   647      */
       
   648     void StartItemAnimation();
       
   649     
       
   650     /** 
       
   651      * Called on item-animation timer tick
       
   652      * @param aPtr Pointer to object that started the timer
       
   653      * @return 0 to signal that further callbacks are unnecessary, 1 otherwise
       
   654      */
       
   655     static TInt ItemAnimTimerCallback(TAny* aPtr);
       
   656 
       
   657 	/**
       
   658 	 * Perform action for item-animation animation timer tick.
       
   659      * @return 0 to signal that further callbacks are unnecessary, 1 otherwise
       
   660      */
       
   661     TInt ItemAnimAction();
       
   662 
       
   663     /**
       
   664      * Called when item-animation animation has completed
       
   665      */
       
   666     void ItemAnimationComplete();
       
   667     
       
   668     /** 
       
   669      * Called on palette-appearance timer tick
       
   670      * @param aPtr Pointer to object that started the timer
       
   671      * @return 0 to signal that further callbacks are unnecessary, 1 otherwise
       
   672      */
       
   673     static TInt PaletteAnimTimerCallback(TAny* aPtr);
       
   674 
       
   675 	/**
       
   676 	 * Perform action for palette-appearance animation timer tick.
       
   677      * @return 0 to signal that further callbacks are unnecessary, 1 otherwise
       
   678      */
       
   679     TInt PaletteAnimAction();
       
   680 
       
   681     /**
       
   682      * Called when palette-appearance animation has completed
       
   683      */
       
   684     void PaletteAnimComplete();
       
   685 
       
   686     /**
       
   687      * Called whenever a new item gains focus
       
   688      */
       
   689     void FocusedItemUpdated();
       
   690 //@}
       
   691 
       
   692     /**
       
   693      * Prepares a TActivePalette2EventData object
       
   694      * @param aItem The item the event concerns
       
   695      * @param aResult The result of the event
       
   696      * @return The initialized TActivePalette2EventData object
       
   697      */
       
   698     TActivePalette2EventData PrepareEventData(const CActivePalette2Item& aItem, TInt aResult);
       
   699 
       
   700     /**
       
   701      * Appends a plugin's UID to an array, if the plugin can be found on the device.
       
   702      * @param aPluginList The array to append to
       
   703      * @param aDllUid The UID to add if found
       
   704      * @param aDllFileName The filename of the DLL to look for
       
   705      */
       
   706     void AppendPluginIdIfAvailable(RArray<TUid>& aPluginList, const TUid aDllUid, const TFileName aDllFileName) const;
       
   707 
       
   708 private:
       
   709 /// @name Item information
       
   710 //@{
       
   711     /// The currently installed items
       
   712     RPointerArray<CActivePalette2Item> iItemsArray;
       
   713     /// The visibility of each installed item.
       
   714     RArray<TBool> iVisibilityArray;
       
   715     /// The index of the top item on the screen
       
   716     TInt iTopItemOnScreen;
       
   717     /// How many items are currently on the screen
       
   718     TInt iNoItemsOnScreen;
       
   719     /// The total number of visible items
       
   720     TInt iNoVisibleItems;
       
   721     /// Currently focused item index
       
   722     TInt iFocusedItem;
       
   723     /// Previously focused item ID
       
   724     TInt iPreviousItemID;
       
   725     /// Currently focused item ID
       
   726     TInt iFocusedItemID;
       
   727 //@}
       
   728 
       
   729 private:
       
   730 /// @name Animation information
       
   731 //@{
       
   732     /// Timer for focus-change animation. Owned
       
   733 	CPeriodic* iFocusChangeTimer;
       
   734 	/// The item index being moved to
       
   735     TInt iFocusChangeTargetItem;
       
   736     /// The velocity of the focus-change animation
       
   737     TInt iFocusChangeDirection;
       
   738     /// The current focus-change frame
       
   739     TInt iFocusedCurrentOffset;
       
   740     
       
   741     /// Timer for item-scroll animation. Owned
       
   742 	CPeriodic* iItemScrollTimer;
       
   743     /// The velocity of the item-scroll animation
       
   744     TInt iItemScrollDirection;              
       
   745     /// The current item-scroll frame
       
   746     TInt iItemScrollCurrentOffset;
       
   747 
       
   748     /// The item being animated    
       
   749     CActivePalette2Item* iAniItem;
       
   750     /// The screen position of the item being animated
       
   751     TInt iAniItemScreenPos;
       
   752     /// The animation info for the animated item
       
   753 	CActivePalettePluginBase::TPluginAnimationInfo iAniItemInfo;
       
   754     /// The item animation timer. Owned.    
       
   755 	CPeriodic* iItemAnimTimer;			
       
   756 	/// The current item animation frame number
       
   757     TInt iAnimationFrame;
       
   758 
       
   759     /// The current appearance animation frame
       
   760     TInt iPaletteMoveCurrentOffset;
       
   761     /// The total number of appearance animation frames
       
   762     TInt iPaletteMoveOffsetTotalFrames;
       
   763     /// The velocity of the appearance animation 
       
   764     TInt iPaletteMoveAnimationDirection;
       
   765     /// The timer for the appearance animation. Owned
       
   766 	CPeriodic* iPaletteMoveTimer;
       
   767 	/// The duration of the appearance animation, in milliseconds
       
   768     TInt iPaletteMoveAnimationDuration; 
       
   769 
       
   770     /// The current animation state
       
   771     TPaletteAnimState iAnimState;
       
   772 //@}
       
   773 
       
   774 private:
       
   775 /// @name Cached information, for speed
       
   776 //@{
       
   777     /// The indices of the items shown on-screen
       
   778     TInt iOnScreenItemIndex[NAP2Cfg::KMaxNofItemsInView + 1];
       
   779     
       
   780     /// Whether the top scroll arrow should be shown
       
   781     TBool iShowTopScrollArrow;
       
   782     
       
   783     /// Whether the bottom scroll arrow should be shown
       
   784     TBool iShowBottomScrollArrow;
       
   785 //@}
       
   786 
       
   787 private:
       
   788     /// The callback styles requested
       
   789     TRendererCallBacks iCallbacks;
       
   790     
       
   791     /// The model observer (renderer)
       
   792 	MActivePalette2ModelObserver& iModelObserver;
       
   793 
       
   794   //  Configuration provider	
       
   795 	//CActivePalette2Configuration& iConfiguration;
       
   796 	
       
   797 	/// The dimensions of each item's icon
       
   798 	TSize 		 iItemSize;
       
   799 
       
   800 	// Tooltip details
       
   801 	TActivePalette2TooltipConfig iTooltipConfig;
       
   802 };
       
   803 
       
   804 #endif // _ACTIVE_PALETTE_2_MODEL_H
       
   805 
       
   806 // End of File