camerauis/activepalette/Inc/ActivePalette2HUI.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:  AP implementation using HUITK*
       
    15 */
       
    16 
       
    17 
       
    18 /**
       
    19  * @file ActivePalette2HUI.h
       
    20  * AP implementation using HUITK
       
    21  */
       
    22  
       
    23 
       
    24 #ifndef _ACTIVE_PALETTE_2_HUI_H
       
    25 #define _ACTIVE_PALETTE_2_HUI_H
       
    26 
       
    27 #include <e32std.h>
       
    28 #include <uiacceltk/HuiControl.h>
       
    29 #include <activepalette2ui.h>
       
    30 #include <activepalette2itemvisible.h>
       
    31 #include <activepalette2navigationkeys.h>
       
    32 
       
    33 #include "ActivePalette2ModelObserver.h"
       
    34 
       
    35 class CHuiEnv;
       
    36 class CHuiLayout;
       
    37 class CHuiImageVisual;
       
    38 class CHuiMeshVisual;
       
    39 class CHuiTextVisual;
       
    40 class CHuiTexture;
       
    41 class TActivePalette2EventData;
       
    42 class MActivePalette2Observer;
       
    43 class CActivePalette2Item;
       
    44 class CActivePalette2Model;
       
    45 
       
    46 /**
       
    47  * 3D renderer for Active Palette 2.
       
    48  */
       
    49 class CActivePalette2HUI : public CHuiControl, 
       
    50                               public MActivePalette2UI,
       
    51                               public MActivePalette2ModelObserver,
       
    52                               public MActivePalette2TooltipDescriptiveObserver,
       
    53                               public MActivePalette2FocusDescriptiveObserver,
       
    54                               public MActivePalette2ItemScrollDescriptiveObserver,
       
    55                               public MActivePalette2AppearanceDescriptiveObserver
       
    56     {
       
    57 public:  
       
    58 /// @name Object creation & deletion
       
    59 //@{
       
    60 
       
    61     /**
       
    62      * 2-stage construction
       
    63      * @param aEnv The Hui environment the control should be created in
       
    64      * @return The newly-created object
       
    65      */
       
    66     static CActivePalette2HUI* NewL(CHuiEnv& aEnv);
       
    67     
       
    68     /**
       
    69      * Destructor
       
    70      */
       
    71     ~CActivePalette2HUI();
       
    72 //@}
       
    73 
       
    74 private:
       
    75 /// @name Object creation helpers
       
    76 //@{
       
    77     /**
       
    78      * Constructor
       
    79      * @param aEnv The Hui environment the control should be created in
       
    80      */
       
    81     CActivePalette2HUI(CHuiEnv& aEnv);
       
    82 
       
    83     /**
       
    84      * Second-stage construction
       
    85      */
       
    86     void ConstructL();
       
    87 
       
    88 //@}
       
    89 
       
    90 public:  
       
    91 /// @name From CHuiControl
       
    92 //@{
       
    93     virtual TBool OfferEventL(const THuiEvent& aEvent);
       
    94     virtual void VisualLayoutUpdated(CHuiVisual &aVisual);
       
    95 //@}
       
    96 
       
    97 public:  
       
    98 /// @name From MActivePalette2UI
       
    99 //@{
       
   100 	virtual TInt InstallItemL(const TActivePalette2ItemVisible& aItemVisible, 
       
   101 						const TUid& aPluginUid, 
       
   102 						const TDesC8& aCustomDataDes);
       
   103 	virtual TInt InstallItemL(const TActivePalette2ItemVisible& aItemVisible,
       
   104 						const TUid& aPluginUid, 
       
   105 						TInt aCustomDataInt = 0);
       
   106 	virtual TInt InstallItemL(const TActivePalette2ItemVisible& aItemVisible,
       
   107 						const TUid& aPluginUid, 
       
   108 						TInt aCustomDataInt, 
       
   109 						const TDesC8& aCustomDataDes);
       
   110 	virtual TInt RemoveItem(TInt aItemId);
       
   111 	virtual TInt SetItemVisibility(TInt aItemId, TBool aIsVisible);
       
   112 	virtual TInt GetItemVisibility(TInt aItemId, TBool &aIsVisible) const;
       
   113     virtual TInt GetItemList(RArray<TActivePalette2ItemVisible>& aItemVisibleList) const;
       
   114     virtual TInt SetItemList(const RArray<TActivePalette2ItemVisible>& aItemVisibleList);
       
   115 	virtual TInt SendMessage(TInt aItemId, TInt aMessageId, const TDesC8& aDataDes);
       
   116 	virtual TInt SendMessage(TInt aItemId, TInt aMessageId, TInt aDataInt);
       
   117 	virtual TInt GetCurrentItem(TInt& aItemId) const;
       
   118 	virtual TInt SetCurrentItem(TInt aItemId);
       
   119     virtual TInt SetPaletteVisibility(TBool aVisible, TBool aAnimated, TInt aDelayedStartMilliseconds = 0);
       
   120     virtual TInt SetPaletteVisibilityAnimationDuration(TInt aTimeInMilliseconds);
       
   121     virtual TInt GetPaletteVisibilityAnimationDuration(TInt& aTimeInMilliseconds) const;
       
   122 	virtual void LocateTo(const TPoint& aTopLeft);
       
   123 	virtual TPoint Location() const;
       
   124     virtual CCoeControl* CoeControl();
       
   125     virtual CHuiControl* HuiControl();
       
   126     virtual void SetGc(CBitmapContext* aGc = NULL);
       
   127     virtual void RenderActivePalette(const TRect& aRect) const;
       
   128     virtual void SetObserver(MActivePalette2Observer* aObserver);
       
   129     virtual TInt GetAvailablePlugins(RArray<TUid>& aPluginList) const;
       
   130     virtual void SetNavigationKeys(const TActivePalette2NavigationKeys& aNavigationKeys);
       
   131 //@}    
       
   132 
       
   133 public: 
       
   134 /// @name From MActivePalette2ModelObserver
       
   135 //@{
       
   136     virtual TInt TooltipUpdated();
       
   137     virtual void ItemsUpdated();
       
   138     virtual void ItemAnimated(TInt aScreenPos, CActivePalette2Item* aItem, TInt aAnimFrame);
       
   139     virtual void ItemAnimationComplete(TInt aScreenPos, CActivePalette2Item* aItem);
       
   140     virtual void PaletteAppearingUpdated();
       
   141 	virtual MActivePalette2Observer* APObserver() const;
       
   142     virtual void ShowTooltipUpdated();
       
   143 //@}    
       
   144 
       
   145 public: 
       
   146 /// @name From MActivePalette2TooltipDescriptiveObserver
       
   147 //@{
       
   148     virtual void AnimateTooltip(TBool aToShow, TInt aTimeInMilliseconds);
       
   149 //@}
       
   150 
       
   151 public: 
       
   152 /// @name From MActivePalette2FocusDescriptiveObserver
       
   153 //@{
       
   154     virtual void AnimateFocus(TInt aCurrentPos, TInt aTargetPos, TInt aTimeInMilliseconds);
       
   155 //@}
       
   156 
       
   157 public: 
       
   158 /// @name From MActivePalette2ItemScrollDescriptiveObserver
       
   159 //@{
       
   160     virtual void AnimateItemScroll(TInt aDirection, TInt aTimeInMilliseconds);
       
   161 //@}
       
   162     
       
   163 public: 
       
   164 /// @name From MActivePalette2AppearanceDescriptiveObserver
       
   165 //@{
       
   166     virtual void AnimateAppearance(TBool aVisible, TInt aTimeInMilliseconds);
       
   167     virtual TInt GuessCurrentAppearanceFrame();
       
   168 //@}
       
   169 
       
   170 private: 
       
   171 /// @name New functions
       
   172 //@{
       
   173     /**
       
   174      * Renders the main section of the palette. It repositions all objects within it's layout,
       
   175      * and updates all textures.
       
   176      */
       
   177     void Render();
       
   178 
       
   179     /**
       
   180      * Returns the current screen position of the AP.
       
   181      * @return The screen position of the AP
       
   182      */                      
       
   183     TPoint PalettePosition() const;
       
   184 
       
   185     /**
       
   186      * Updates state when a focus-change animation is completed
       
   187      * @return 0 to signal that further callbacks are unnecessary, 1 otherwise
       
   188      */
       
   189     TInt AnimateFocusTimerComplete();
       
   190 
       
   191     /**
       
   192      * Updates state when a palette-appearance animation is completed
       
   193      * @return 0 to signal that further callbacks are unnecessary, 1 otherwise
       
   194      */
       
   195     TInt AnimateAppearanceTimerComplete();
       
   196 
       
   197     /**
       
   198      * Updates state when a item-scroll animation is completed
       
   199      * @return 0 to signal that further callbacks are unnecessary, 1 otherwise
       
   200      */
       
   201     TInt AnimateItemScrollTimerComplete();
       
   202 
       
   203     /**
       
   204      * Updates state when a tooltip animation is completed
       
   205      * @return 0 to signal that further callbacks are unnecessary, 1 otherwise
       
   206      */
       
   207     TInt AnimateTooltipTimerComplete();
       
   208 
       
   209     /**
       
   210      * Returns the palette offset for an item at the given screen position
       
   211      * @param aScreenPos The screen postion
       
   212      * @return The item offset
       
   213      */
       
   214     TPoint ItemPosition(TInt aScreenPos) const;
       
   215     
       
   216     /**
       
   217      * The offset for the area of the palette that contains the top scroll arrow
       
   218      * @return The offset
       
   219      */
       
   220     TPoint TopScrollPanePosition() const;
       
   221     
       
   222     /**
       
   223      * The offset for the area of the palette that contains the bottom scroll arrow
       
   224      * @return The offset
       
   225      */
       
   226     TPoint BottomScrollPanePosition() const;
       
   227     
       
   228     /**
       
   229      * The overall size of the palette
       
   230      * @return The size
       
   231      */
       
   232     TSize PaletteSize() const;
       
   233     
       
   234     /**
       
   235      * Returns the current offset to be applied to all items due to item-scrolling
       
   236      * @return The item scroll offset
       
   237      */
       
   238     TPoint CurrentScrollOffset() const;
       
   239 
       
   240     /**
       
   241      * Set the correct opacities for the top & bottom items during an item-scroll animation
       
   242      */
       
   243     void ItemsScrolledSetItemOpacities();
       
   244     
       
   245     /**
       
   246      * Updates the position and opacity of the focus ring, with immediate effect
       
   247      */
       
   248     void UpdateFocus();
       
   249 
       
   250     /**
       
   251      * Updates iScreenSize, iTopLeftCorner based on current screen size 
       
   252      */
       
   253     void UpdateTopLeftCornerWithScreenSize();
       
   254 //@}
       
   255 
       
   256 /// @name New functions
       
   257 //@{
       
   258     /**
       
   259      * Timer callback for focus-change animation
       
   260      * @param aPtr Pointer to object that started the timer
       
   261      * @return 0 to signal that further callbacks are unnecessary, 1 otherwise
       
   262      */
       
   263     static TInt AnimateFocusTimerCallback(TAny* aPtr);
       
   264 
       
   265     /**
       
   266      * Timer callback for palette-appearance animation
       
   267      * @param aPtr Pointer to object that started the timer
       
   268      * @return 0 to signal that further callbacks are unnecessary, 1 otherwise
       
   269      */
       
   270     static TInt AnimateAppearanceTimerCallback(TAny* aPtr);
       
   271 
       
   272     /**
       
   273      * Timer callback for item-scroll animation
       
   274      * @param aPtr Pointer to object that started the timer
       
   275      * @return 0 to signal that further callbacks are unnecessary, 1 otherwise
       
   276      */
       
   277     static TInt AnimateItemScrollTimerCallback(TAny* aPtr);
       
   278     
       
   279     /**
       
   280      * Timer callback for tooltip animation
       
   281      * @param aPtr Pointer to object that started the timer
       
   282      * @return 0 to signal that further callbacks are unnecessary, 1 otherwise
       
   283      */
       
   284     static TInt AnimateTooltipTimerCallback(TAny* aPtr);
       
   285 
       
   286 //@}
       
   287 
       
   288 private: // data
       
   289     /// The model used
       
   290     CActivePalette2Model* iModel;
       
   291     
       
   292     /// The observer to use for callbacks
       
   293     MActivePalette2Observer* iObserver;
       
   294 
       
   295     /// The keys to respond to in OfferEventL
       
   296     TActivePalette2NavigationKeys iNavigationKeys;
       
   297 
       
   298     /// Where the AP should be when fully shown
       
   299     TPoint iTopLeftCorner;    
       
   300     
       
   301 
       
   302     /// The full-screen layout - to get VisualLayoutUpdated on 
       
   303     /// screen orientation change
       
   304     CHuiLayout*      iFullScreenLayout;
       
   305     
       
   306     /// The palette layout
       
   307     CHuiLayout*      iPaletteLayout;
       
   308 
       
   309     /// The top section background layout
       
   310     CHuiLayout*      iBackgroundTopSectionLayout;
       
   311     /// The top section background visual
       
   312     CHuiImageVisual* iBackgroundTopSectionVisual;
       
   313     /// The top section background texture
       
   314     CHuiTexture*     iBackgroundTopSectionTexture;
       
   315 
       
   316     /// The mid section background layout
       
   317     CHuiLayout*      iBackgroundMidSectionLayout;
       
   318     /// The mid section background visual
       
   319     CHuiImageVisual* iBackgroundMidSectionVisual;
       
   320     /// The mid section background texture
       
   321     CHuiTexture*     iBackgroundMidSectionTexture;
       
   322 
       
   323     /// The bottom section background layout
       
   324     CHuiLayout*      iBackgroundBottomSectionLayout;
       
   325     /// The bottom section background visual
       
   326     CHuiImageVisual* iBackgroundBottomSectionVisual;
       
   327     /// The bottom section background texture
       
   328     CHuiTexture*     iBackgroundBottomSectionTexture;
       
   329 
       
   330     /// The top-arrow layout
       
   331     CHuiLayout*      iTopScrollLayout;
       
   332     /// The top-arrow visual
       
   333     CHuiImageVisual* iTopScrollVisual;
       
   334     /// The top-arrow texture
       
   335     CHuiTexture*     iTopScrollTexture;
       
   336 
       
   337     /// The bottom-arrow layout    
       
   338     CHuiLayout*      iBottomScrollLayout;
       
   339     /// The bottom-arrow visual
       
   340     CHuiImageVisual* iBottomScrollVisual;
       
   341     /// The bottom-arrow texture
       
   342     CHuiTexture*     iBottomScrollTexture;
       
   343 
       
   344     /// The focus ring layout
       
   345     CHuiLayout*      iFocusRingLayout;
       
   346     /// The focus ring texture
       
   347     CHuiTexture*     iFocusRingTexture;
       
   348     /// The focus ring visual
       
   349     CHuiImageVisual* iFocusRingVisual;
       
   350 
       
   351     /// The layouts for the items
       
   352     RPointerArray<CHuiLayout>      iItemLayout;
       
   353     /// The visuals for the items
       
   354     RPointerArray<CHuiImageVisual> iItemVisual;
       
   355     /// The textures for the items
       
   356     RPointerArray<CHuiTexture>     iItemTexture;
       
   357 
       
   358     /// The tooltip layout
       
   359     CHuiLayout*      iTooltipLayout;
       
   360     
       
   361     /// The tooltip text layout
       
   362     CHuiLayout*      iTooltipTextLayout;
       
   363     /// The tooltip text visual
       
   364     CHuiTextVisual*  iTooltipTextVisual;
       
   365 
       
   366     /// The nose section tooltip background layout
       
   367     CHuiLayout*      iTooltipBackgroundNoseLayout;
       
   368     /// The nose section tooltip background visual
       
   369     CHuiImageVisual* iTooltipBackgroundNoseVisual;
       
   370     /// The nose section tooltip background texture
       
   371     CHuiTexture*     iTooltipBackgroundNoseTexture;
       
   372 
       
   373     /// The body section tooltip background layout
       
   374     CHuiLayout*      iTooltipBackgroundBodyLayout;
       
   375     /// The body section tooltip background visual
       
   376     CHuiImageVisual* iTooltipBackgroundBodyVisual;
       
   377     /// The body section tooltip background texture
       
   378     CHuiTexture*     iTooltipBackgroundBodyTexture;
       
   379 
       
   380 
       
   381     /// A general purpose timer. Used for synchronizing with animations.
       
   382     CPeriodic* iGeneralTimer;
       
   383     
       
   384     /// Stores the current screen size.
       
   385 	TSize iScreenSize;
       
   386     };
       
   387 
       
   388 
       
   389 #endif // _ACTIVE_PALETTE_2_HUI_H
       
   390