src/hbcore/feedback/hbfeedbackengine.cpp
changeset 2 06ff229162e9
parent 0 16d8024aca5e
child 21 4633027730f5
child 34 ed14f46c0e55
equal deleted inserted replaced
1:f7ac710697a9 2:06ff229162e9
    33 /*!
    33 /*!
    34     @beta
    34     @beta
    35     @hbcore
    35     @hbcore
    36     \class HbFeedbackEngine
    36     \class HbFeedbackEngine
    37     
    37     
    38     \brief Base class for implementing haptic, sound and visual feedback effects, 
    38     \brief Base class for implementing engines for different kinds of feedback effects.
    39     user action loggers and screenreaders. 
       
    40     
    39     
    41     The feedback engine receives interaction information from HbFeedbackManager as
    40     The feedback engine receives interaction information from HbFeedbackManager as interaction and continuous 
    42     interaction and continuous interaction events. All events are received in method event() and forwarded to the
    41     interaction events. All events are received in method event() and forwarded to the corresponding virtual 
    43     corresponding virtual methods overridden by various engine implementations. Interaction information
    42     methods overridden by various engine implementations.
    44     is received by methods pressed(), released(), clicked(), keyRepeated(), longPressed(), draggedOver(), flicked(),
    43     
    45     popupOpened(), popupClosed(), boundaryReached(), rotated90Degrees(), selectionChanged().
    44     Instant interaction information is received by methods pressed(), released(), clicked(), keyRepeated(), 
       
    45     longPressed(), draggedOver(), flicked(), popupOpened(), popupClosed(), boundaryReached(), rotated90Degrees(), 
       
    46     selectionChanged() and multitouchActivated().
       
    47     
    46     Continuous interaction information is received by methods continuousTriggered() and continuousStopped().
    48     Continuous interaction information is received by methods continuousTriggered() and continuousStopped().
    47 
    49 
    48     \sa HbNameSpace, HbFeedbackManager, HbFeedbackPlugin
    50     \sa HbNameSpace, HbFeedbackManager, HbFeedbackPlugin
    49 */
    51 */
    50 
    52 
    57     QPointer<HbFeedbackManager> m_manager;
    59     QPointer<HbFeedbackManager> m_manager;
    58     HbInstantInteractionEvent* currentEvent;
    60     HbInstantInteractionEvent* currentEvent;
    59 };
    61 };
    60 
    62 
    61 /*!
    63 /*!
    62     Constructs HbFeedbackEngine. If you don't pass HbFeedbackManager
    64     Constructor.
    63     during construction, you need to provide it by calling setManager().
       
    64 
       
    65 */
    65 */
    66 HbFeedbackEngine::HbFeedbackEngine() : d(new HbFeedbackEnginePrivate())
    66 HbFeedbackEngine::HbFeedbackEngine() : d(new HbFeedbackEnginePrivate())
    67 {
    67 {
    68 }
    68 }
    69 
    69 
    70 /*!
    70 /*!
    71     Constructs the engine with required feedback manager.
    71     Constructs the engine with required feedback manager. If the HbFeedbackManager object is not provided during construction,
    72 
    72     it needs to be provided by calling setManager().
    73     \param manager feedback manager which passes interaction information to the engine
    73 
       
    74     \param manager feedback manager object which passes interaction information to the engine
    74 */
    75 */
    75 HbFeedbackEngine::HbFeedbackEngine(HbFeedbackManager* manager) : d(new HbFeedbackEnginePrivate())
    76 HbFeedbackEngine::HbFeedbackEngine(HbFeedbackManager* manager) : d(new HbFeedbackEnginePrivate())
    76 {
    77 {
    77     setManager(manager);
    78     setManager(manager);
    78 }
    79 }
    79 
    80 
    80 /*!
    81 /*!
    81     Destructor
    82     Destructor.
    82 */
    83 */
    83 HbFeedbackEngine::~HbFeedbackEngine()
    84 HbFeedbackEngine::~HbFeedbackEngine()
    84 {
    85 {
    85     if (d->m_manager) {
    86     if (d->m_manager) {
    86         d->m_manager->setReceivesInteractions(this, false);
    87         d->m_manager->setReceivesInteractions(this, false);
   114 {
   115 {
   115     return d->m_manager;
   116     return d->m_manager;
   116 }
   117 }
   117 
   118 
   118 /*!
   119 /*!
   119     Enables the engine. When enabled, events received in method event() are forwarded to appropriate
   120     Enables the engine. When enabled, events received in method event() are forwarded to corresponding
   120     virtual callback functions that different feedback engines can override.
   121     virtual callback functions that different feedback engines can override.
   121 
   122 
   122     \param enabled sets the engine status either enabled or disabled
   123     \param enabled sets the engine status either enabled or disabled
   123 */
   124 */
   124 void HbFeedbackEngine::setReceivesInteractions(bool enabled)
   125 void HbFeedbackEngine::setReceivesInteractions(bool enabled)
   138 {
   139 {
   139     return d->m_manager && d->m_manager->receivesInteractions(this);
   140     return d->m_manager && d->m_manager->receivesInteractions(this);
   140 }
   141 }
   141 
   142 
   142 /*!
   143 /*!
   143     All events received by the QObject-based class come trough method event()
   144     All events received by the QObject-based class come trough method event() and are forwarded to 
   144     and are forwarded to the protected virtual methods corresponding to the interactions and gestures.
   145     the virtual methods corresponding to the interactions.
   145 
   146 
   146     \param e the interaction event
   147     \param e the interaction event
   147 */
   148 */
   148 bool HbFeedbackEngine::event(QEvent* e)
   149 bool HbFeedbackEngine::event(QEvent* e)
   149 {
   150 {
   185     can be used to differentiate situations where same interaction can cause
   186     can be used to differentiate situations where same interaction can cause
   186     multiple different feedback effects depending on widget state.
   187     multiple different feedback effects depending on widget state.
   187 
   188 
   188     Always returns zero when called outside the scope of triggered callbacks.
   189     Always returns zero when called outside the scope of triggered callbacks.
   189 
   190 
   190     \return extra specifier to interaction
   191     \return extra modifier to the interaction
   191 */
   192 */
   192 
   193 
   193 Hb::InteractionModifiers HbFeedbackEngine::modifiers()
   194 Hb::InteractionModifiers HbFeedbackEngine::modifiers()
   194 {
   195 {
   195     Hb::InteractionModifiers modifiers(0);
   196     Hb::InteractionModifiers modifiers(0);
   204     Base class implementation forwards interaction information to dedicated interaction methods,
   205     Base class implementation forwards interaction information to dedicated interaction methods,
   205     remember to call HbFeedbackEngine::triggered() if you want to use the dedicated methods.
   206     remember to call HbFeedbackEngine::triggered() if you want to use the dedicated methods.
   206 
   207 
   207     \param widget widget being interacted with
   208     \param widget widget being interacted with
   208     \param interaction the interaction
   209     \param interaction the interaction
   209     \param modifiers extra specifiers to the interaction
   210     \param modifiers extra modifiers to the interaction
   210 */
   211 */
   211 void HbFeedbackEngine::triggered(const HbWidget *widget, Hb::InstantInteraction interaction, Hb::InteractionModifiers modifiers)
   212 void HbFeedbackEngine::triggered(const HbWidget *widget, Hb::InstantInteraction interaction, Hb::InteractionModifiers modifiers)
   212 {
   213 {
   213     Q_UNUSED(modifiers);
   214     Q_UNUSED(modifiers);
   214     switch(interaction) {
   215     switch(interaction) {
   314 }
   315 }
   315 
   316 
   316 /*!
   317 /*!
   317     Called when the engine receives a click event from the feedback manager.
   318     Called when the engine receives a click event from the feedback manager.
   318 
   319 
   319     \param widget being handled.
   320     \param widget being interacted with
   320 */
   321 */
   321 void HbFeedbackEngine::clicked(const HbWidget *widget)
   322 void HbFeedbackEngine::clicked(const HbWidget *widget)
   322 {
   323 {
   323     Q_UNUSED(widget);
   324     Q_UNUSED(widget);
   324 }
   325 }
   386     Q_UNUSED(widget);
   387     Q_UNUSED(widget);
   387 }
   388 }
   388 
   389 
   389 /*!
   390 /*!
   390     Called when the engine receives a "boundary reached" event from the feedback manager.
   391     Called when the engine receives a "boundary reached" event from the feedback manager.
   391     Boundary reached event should be initiated whenever user flicks, swipes, scrolls and 
   392     Boundary reached event should be initiated whenever user flicks or pans so that the 
   392     pans reach the border of the scroll area.
   393     boundary of the scroll area is reached.
   393 
   394 
   394     \param widget the widget being interacted with
   395     \param widget the widget being interacted with
   395 */
   396 */
   396 void HbFeedbackEngine::boundaryReached(const HbWidget *widget)
   397 void HbFeedbackEngine::boundaryReached(const HbWidget *widget)
   397 {
   398 {
   398     Q_UNUSED(widget);
   399     Q_UNUSED(widget);
   399 }
   400 }
   400 
   401 
   401 /*!
   402 /*!
   402     Called when the engine receives a "rotate step" event from the feedback manager.
   403     Called when the engine receives a "rotated 90 degrees" event from the feedback manager.
   403 
   404 
   404     \param widget the widget being interacted with
   405     \param widget the widget being interacted with
   405 */
   406 */
   406 void HbFeedbackEngine::rotated90Degrees(const HbWidget *widget)
   407 void HbFeedbackEngine::rotated90Degrees(const HbWidget *widget)
   407 {
   408 {
   442     Q_UNUSED(delta);
   443     Q_UNUSED(delta);
   443 }
   444 }
   444 
   445 
   445 /*!
   446 /*!
   446     Called when the engine receives a "continuous interaction stop" event from the feedback manager.
   447     Called when the engine receives a "continuous interaction stop" event from the feedback manager.
   447     This methods is needed for knowing when to stop continuous feedback effects started by the interaction.
   448     This method indicates when to stop previously started continuous feedback effect.
   448 
   449 
   449     \param widget the widget being interacted with
   450     \param widget the widget being interacted with
   450     \param interaction the interaction in progress
   451     \param interaction the interaction in progress
   451 */
   452 */
   452 void HbFeedbackEngine::continuousStopped(const HbWidget *widget, Hb::ContinuousInteraction interaction)
   453 void HbFeedbackEngine::continuousStopped(const HbWidget *widget, Hb::ContinuousInteraction interaction)
   453 {
   454 {
   454     Q_UNUSED(widget);
   455     Q_UNUSED(widget);
   455     Q_UNUSED(interaction);
   456     Q_UNUSED(interaction);
   456 }
   457 }
   457