qstmgesturelib/qstmgestureengine.h
changeset 0 1450b09d0cfd
child 16 3c88a81ff781
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 *
       
     5 * This program is free software: you can redistribute it and/or modify
       
     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.
       
     8 * 
       
     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 *
       
    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:
       
    19 *
       
    20 */
       
    21 
       
    22 #ifndef QSTMGESTUREENGINE_H_
       
    23 #define QSTMGESTUREENGINE_H_
       
    24 
       
    25 #include "qstmgestureengine_if.h"
       
    26 #include "qstmuievent_if.h"
       
    27 #include "qstmgesturedefs.h"
       
    28 
       
    29 namespace qstmGesture
       
    30 {
       
    31 
       
    32 /*!
       
    33  * QStm_GestureEngine handles the processing of the UI events.
       
    34  * It acts as a stmUiEventEngine::MUiEventObserver to receive the UI events.
       
    35  * The gesture recognisers are stored in a list, and at each HandleUiEventL the
       
    36  * list of gesture recognisers is processed.  The first one to return EGestureActive
       
    37  * from the recognise method "owns" the gesture.  If some other recogniser owned it
       
    38  * previously, its release method is called. Gesture recogniser can also lock the gesture
       
    39  * by returning ELockToThisGesture. Then only that gesture recogniser will be called
       
    40  * until release is detected or the recogniser returns something else than ELockToThisGesture.
       
    41  */
       
    42 class QStm_GestureEngine : public QObject, 
       
    43                            public QStm_GestureEngineIf, 
       
    44                            public qstmUiEventEngine::QStm_UiEventObserverIf
       
    45 {
       
    46 public:
       
    47     QStm_GestureEngine();
       
    48     virtual ~QStm_GestureEngine();
       
    49 
       
    50     /*!
       
    51      *  add gesture to the end of the list of gestures
       
    52      */
       
    53     virtual bool addGesture(const QStm_GestureRecogniserIf* newGesture) ;
       
    54     /*!
       
    55      * inset a gesture to the specific position
       
    56      */
       
    57     virtual bool insertGesture(const QStm_GestureRecogniserIf* newGesture, int position = 0);
       
    58 
       
    59     virtual int findGesture(const QStm_GestureRecogniserIf* newGesture, int startPos = 0) const;
       
    60     virtual int findGestureReverse(const QStm_GestureRecogniserIf* gesture, int startPos) const;
       
    61     virtual int findGesture(QStm_GestureUid uid, int startPos = 0) const;
       
    62     virtual int findGestureReverse(QStm_GestureUid aUid, int startPos) const;
       
    63     virtual int gestureCount() const;
       
    64     /*!
       
    65      * remove a gesture from the list
       
    66      */
       
    67     virtual bool removeGesture(const QStm_GestureRecogniserIf* oldGesture) ;
       
    68     /*!
       
    69      * get the number of non-empty event streams.
       
    70      * Event streams correspond UI events generated by one touch pointer (=finger).
       
    71      * The low level state machine handles the necessary filtering etc.
       
    72      * so that it is safe to remove the event stream after UI Release event has been processed.
       
    73      */
       
    74     virtual int activeStreamCount() const ;
       
    75     /*!
       
    76      * get the UI events of stream X
       
    77      * \param indexOfActiveStream defines which active stream is used.
       
    78      * Note that QStm_UiEventIf contains all the events from down up to the current event.
       
    79      * Assumption: the UI events contain the target "window handle", i.e.
       
    80      * the gesture recognition needs to be aware of all possible windows of the application.
       
    81      */
       
    82     virtual const qstmUiEventEngine::QStm_UiEventIf* getUiEvents(int indexOfActiveStream) const ;
       
    83     /*!
       
    84      * enable/disable logging
       
    85      */
       
    86     virtual void enableLogging(bool loggingEnabled) {m_loggingEnabled = loggingEnabled;} ;
       
    87     /*!
       
    88      * The qstmUiEventEngine::QStm_UiEventObserverIf interface
       
    89      */
       
    90     virtual void handleUiEvent( const qstmUiEventEngine::QStm_UiEventIf& event ) ;
       
    91     
       
    92     QStm_GestureRecogniserIf* gestureAt(int idx) { return m_gestures[idx] ; }
       
    93     
       
    94 private:
       
    95     /*!
       
    96      * The list of available gesture recognisers
       
    97      */
       
    98     QList<QStm_GestureRecogniserIf*>  m_gestures;
       
    99     /*!
       
   100      * Is 5 UI event streams enough?  Jos tulee Torvisen voittaja?
       
   101      * We need to store only the latest event since the interface has
       
   102      * methods to walk trough the events. The current (sept 2009) 9.2 seems to have dual-touch support
       
   103      */
       
   104     const qstmUiEventEngine::QStm_UiEventIf* m_uiEventStream[qstmUiEventEngine::KMaxNumberOfPointers] ;
       
   105 
       
   106     void storeUiEvent(const qstmUiEventEngine::QStm_UiEventIf& event) ;
       
   107     void walkTroughGestures() ;
       
   108     void updateUiEvents() ;
       
   109     int m_numOfActiveStreams ;
       
   110     int m_currentGestureOwner ;
       
   111     int m_currentLockedGesture ;
       
   112     bool m_loggingEnabled ;
       
   113 };
       
   114 
       
   115 }
       
   116 
       
   117 
       
   118 
       
   119 #endif /* QSTMGESTUREENGINE_H_ */