ginebra2/KineticHelper.h
branchGCC_SURGE
changeset 8 2e16851ffecd
parent 5 0f2326c2a325
equal deleted inserted replaced
2:bf4420e9fa4d 8:2e16851ffecd
     1 /*
     1 /*
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     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 *
     4 *
     9 * Initial Contributors:
     5 * This program is free software: you can redistribute it and/or modify
    10 * Nokia Corporation - initial contribution.
     6 * it under the terms of the GNU Lesser General Public License as published by
       
     7 * the Free Software Foundation, version 2.1 of the License.
    11 *
     8 *
    12 * Contributors:
     9 * This program is distributed in the hope that it will be useful,
       
    10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    12 * GNU Lesser General Public License for more details.
    13 *
    13 *
    14 * Description: 
    14 * You should have received a copy of the GNU Lesser General Public License
       
    15 * along with this program.  If not,
       
    16 * see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/".
       
    17 *
       
    18 * Description:
    15 *
    19 *
    16 */
    20 */
    17 
       
    18 
    21 
    19 #ifndef __KINETIC_HELPER_H__
    22 #ifndef __KINETIC_HELPER_H__
    20 #define __KINETIC_HELPER_H__
    23 #define __KINETIC_HELPER_H__
    21 
    24 
    22 #include <QObject>
    25 #include <QObject>
    31 
    34 
    32 class KineticScrollable
    35 class KineticScrollable
    33 {
    36 {
    34 public:
    37 public:
    35     virtual void scrollTo(QPoint& pos) = 0;
    38     virtual void scrollTo(QPoint& pos) = 0;
    36     
    39 
    37     virtual QPoint getScrollPosition() = 0;
    40     virtual QPoint getScrollPosition() = 0;
    38     
    41 
    39     virtual QPoint getInitialPosition() = 0;
    42     virtual QPoint getInitialPosition() = 0;
    40     
    43 
    41     virtual QPointF getInitialSpeed() = 0;
    44     virtual QPointF getInitialSpeed() = 0;
    42 };
    45 };
    43 
    46 
    44 
    47 
    45 
    48 
    48     Q_OBJECT
    51     Q_OBJECT
    49 
    52 
    50 public:
    53 public:
    51     KineticHelper(KineticScrollable* scrollable, qreal decel = DECELERATION, int kineticTimeout = KINETIC_TIMEOUT);
    54     KineticHelper(KineticScrollable* scrollable, qreal decel = DECELERATION, int kineticTimeout = KINETIC_TIMEOUT);
    52     ~KineticHelper();
    55     ~KineticHelper();
    53     
    56 
    54     void setDeceleration(qreal decel) { m_decel = decel; }
    57     void setDeceleration(qreal decel) { m_decel = decel; }
    55     void setKineticTimeout(int timeout) { m_kineticTimeout = timeout; }
    58     void setKineticTimeout(int timeout) { m_kineticTimeout = timeout; }
    56     void stopScrolling();
    59     void stopScrolling();
    57     void startScrolling();
    60     void startScrolling();
    58     bool isScrolling();
    61     bool isScrolling();
    59 private slots:    
    62 private slots:
    60     void kineticScroll();
    63     void kineticScroll();
    61 private:
    64 private:
    62     KineticScrollable* m_scrollable;
    65     KineticScrollable* m_scrollable;
    63     QPointF            m_initialSpeed;
    66     QPointF            m_initialSpeed;
    64     QPoint             m_initialPos;
    67     QPoint             m_initialPos;