ginebra2/ContentToolbarChromeItem.h
changeset 0 1450b09d0cfd
child 3 0954f5dd2cd0
child 5 0f2326c2a325
equal deleted inserted replaced
-1:000000000000 0:1450b09d0cfd
       
     1 /*
       
     2 * Copyright (c) 2010 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: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef __GINEBRA_CONTENTTOOLBARCHROMEITEM_H
       
    20 #define __GINEBRA_CONTENTTOOLBARCHROMEITEM_H
       
    21 
       
    22 #include <QtGui>
       
    23 #include "ToolbarChromeItem.h"
       
    24 
       
    25 class QTimeLine;
       
    26 class QTimer;
       
    27 
       
    28 namespace GVA {
       
    29 
       
    30   class ToolbarFadeAnimator: public QObject
       
    31   {
       
    32 
       
    33     Q_OBJECT
       
    34 
       
    35     public:
       
    36 
       
    37       ToolbarFadeAnimator();
       
    38       ~ToolbarFadeAnimator();
       
    39       void start(bool visible);
       
    40       void stop();
       
    41 
       
    42 
       
    43     private slots:
       
    44       void valueChange(qreal step);
       
    45 
       
    46     Q_SIGNALS:
       
    47       void updateVisibility(qreal step);
       
    48       void finished();
       
    49 
       
    50     private:
       
    51       QTimeLine *m_timeLine;
       
    52       
       
    53   };
       
    54 
       
    55   class ContentToolbarChromeItem : public ToolbarChromeItem
       
    56   {
       
    57     Q_OBJECT
       
    58 
       
    59 
       
    60 
       
    61     enum  ContentToolbarState {
       
    62 
       
    63       CONTENT_TOOLBAR_STATE_FULL, 
       
    64       CONTENT_TOOLBAR_STATE_PARTIAL, 
       
    65       CONTENT_TOOLBAR_STATE_ANIM_TO_PARTIAL, 
       
    66       CONTENT_TOOLBAR_STATE_ANIM_TO_FULL, 
       
    67       CONTENT_TOOLBAR_STATE_INVALID 
       
    68     };
       
    69 
       
    70     enum ContentToolbarInactivityTimerState {
       
    71 
       
    72       CONTENT_TOOLBAR_INACTIVITY_TIMER_NONE,
       
    73       CONTENT_TOOLBAR_INACTIVITY_TIMER_ALLOWED
       
    74 
       
    75     };
       
    76 /*
       
    77     typedef void (ContentToolbarChromeItem::*EnterFunctionType)(bool);
       
    78     typedef void (ContentToolbarChromeItem::*ExitFunctionType)();
       
    79 
       
    80     struct ContentToolbarState_t {
       
    81     
       
    82       EnterFunctionType enterFunc;
       
    83       ExitFunctionType exitFunc;
       
    84 
       
    85     };
       
    86 
       
    87 */
       
    88     public:
       
    89       ContentToolbarChromeItem(QGraphicsItem* parent = 0);
       
    90       virtual ~ContentToolbarChromeItem();
       
    91       virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* opt, QWidget* widget);
       
    92       virtual void setSnippet(WebChromeContainerSnippet * snippet);
       
    93 
       
    94     protected:
       
    95       virtual void resizeEvent(QGraphicsSceneResizeEvent * ev);
       
    96   
       
    97   
       
    98     private slots:
       
    99       void onChromeComplete(); 
       
   100       void onLoadStarted(); 
       
   101       void onLoadFinished(bool); 
       
   102       void onInactivityTimer();
       
   103       void onAnimFinished();
       
   104       void onUpdateVisibility(qreal);
       
   105       void onSnippetMouseEvent( QEvent::Type type);
       
   106       void onWebViewMouseEvents( QEvent::Type type);
       
   107       void onSnippetShow();
       
   108       void onSnippetHide();
       
   109       void onMVCloseComplete();
       
   110 
       
   111     private:
       
   112       void handleMousePress();
       
   113       void handleMouseRelease();
       
   114       void addFullBackground();
       
   115       void changeState( ContentToolbarState state, bool animate = false);
       
   116       void onStateEntry(ContentToolbarState state, bool animate);
       
   117       void onStateExit(ContentToolbarState state);
       
   118       void resetInactivityTimer();
       
   119       bool mvSnippetVisible();
       
   120 
       
   121 
       
   122       //void initStates(); 
       
   123 
       
   124       // State Enter and Exit functions
       
   125       void  stateEnterFull(bool);
       
   126       void  stateEnterPartial(bool animate=false);
       
   127       void  stateEnterAnimToPartial(bool animate =false);
       
   128       void  stateEnterAnimToFull(bool animate =false);
       
   129 
       
   130       ToolbarFadeAnimator * m_animator;
       
   131       QPainterPath* m_background;
       
   132       ChromeSnippet* m_middleSnippet;
       
   133       QTimer* m_inactivityTimer;
       
   134       qreal m_bgopacity;
       
   135       ContentToolbarState m_state;
       
   136       ContentToolbarInactivityTimerState m_inactiveTimerState;
       
   137     
       
   138       //ContentToolbarState_t m_states[10];
       
   139       
       
   140 
       
   141   };
       
   142 
       
   143 } // end of namespace GVA
       
   144 
       
   145 #endif // __GINEBRA_CONTENTTOOLBARCHROMEITEM_H