author | hgs |
Mon, 18 Oct 2010 18:23:13 +0300 | |
changeset 34 | ed14f46c0e55 |
parent 0 | 16d8024aca5e |
permissions | -rw-r--r-- |
0
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1 |
/**************************************************************************** |
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
2 |
** |
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
3 |
** Copyright (C) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). |
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
4 |
** All rights reserved. |
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
5 |
** Contact: Nokia Corporation (developer.feedback@nokia.com) |
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
6 |
** |
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
7 |
** This file is part of the HbCore module of the UI Extensions for Mobile. |
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
8 |
** |
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
9 |
** GNU Lesser General Public License Usage |
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
10 |
** This file may be used under the terms of the GNU Lesser General Public |
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
11 |
** License version 2.1 as published by the Free Software Foundation and |
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
12 |
** appearing in the file LICENSE.LGPL included in the packaging of this file. |
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
13 |
** Please review the following information to ensure the GNU Lesser General |
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
14 |
** Public License version 2.1 requirements will be met: |
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
15 |
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
16 |
** |
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
17 |
** In addition, as a special exception, Nokia gives you certain additional |
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
18 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
19 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
20 |
** |
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
21 |
** If you have questions regarding the use of this file, please contact |
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
22 |
** Nokia at developer.feedback@nokia.com. |
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
23 |
** |
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
24 |
****************************************************************************/ |
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
25 |
|
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
26 |
#include "hbwidgetfeedback.h" |
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
27 |
#include "hbfeedbackmanager.h" |
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
28 |
|
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
29 |
/*! |
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
30 |
@beta |
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
31 |
@hbcore |
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
32 |
|
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
33 |
\class HbWidgetFeedback |
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
34 |
|
34 | 35 |
\brief The HbWidgetFeedback class provides an interface for widgets |
36 |
to inform the feedback framework about user interactions in order |
|
37 |
to trigger feedback effects. |
|
38 |
||
39 |
The HbWidgetFeedback class is for use in widget implementations. |
|
40 |
It is not relevant when you are simply using existing widgets in |
|
41 |
an application. |
|
42 |
||
43 |
As a widget developer, you may want to give feedback when the user |
|
44 |
interacts with your widget. Audio signals or vibration are examples of |
|
45 |
possible feedback effects. To trigger the feedback effects supported by |
|
46 |
the feedback framework, you must inform the feedback framework about |
|
47 |
the detected user interaction and its specific type. |
|
48 |
||
49 |
Interactions are divided into two main types: |
|
50 |
||
51 |
<ul> |
|
52 |
<li><b>Instant interactions.</b> Short user actions, such as clicking |
|
53 |
a button or changing a selection on a list. A typical feedback effect |
|
54 |
for these interactions is a fire-and-forget type of event, where |
|
55 |
the physical response is played from beginning to end.</li> |
|
56 |
<li><b>Continuous interactions.</b> Longer user actions, such as scrolling |
|
57 |
or dragging. Playing the feedback for these interactions continues until |
|
58 |
explicitly stopped.</li> |
|
59 |
</ul> |
|
60 |
||
61 |
HbWidgetFeedback provides static methods for informing the feedback |
|
62 |
framework about user interactions: |
|
63 |
\link HbWidgetFeedback::triggered() triggered() \endlink for instant interactions, |
|
64 |
and \link HbWidgetFeedback::continuousTriggered() continuousTriggered() \endlink |
|
65 |
and \link HbWidgetFeedback::continuousStopped() continuousStopped() \endlink |
|
66 |
for continuous interactions. Information on the target widget of the interaction |
|
67 |
and the interaction type is passed in the method parameters. The feedback framework |
|
68 |
makes decisions about the actual effects, based on the widget type, situation, |
|
69 |
and specific interaction type. |
|
70 |
||
71 |
A widget should only call interaction methods when the user actually |
|
72 |
interacts with the widget, and not when the widget state changes for some |
|
73 |
other reason. For example, feedback effects are not desirable when |
|
74 |
an application resets widget states by calling the widget API, or when |
|
75 |
a progress bar is moved during a file transfer. |
|
76 |
||
77 |
How you use this class or whether you need to use it at all depends on |
|
78 |
what kind of widget you are developing: |
|
79 |
||
80 |
<b>Standard widgets.</b> If you are developing a standard %Hb widget, |
|
81 |
such as HbPushButton, HbComboBox, and so on, you should use this class, |
|
82 |
%HbWidgetFeedback, for triggering feedback effects upon user interaction. |
|
83 |
See the use case below for details. |
|
84 |
||
85 |
<b>Custom widgets that derive from a standard widget.</b> If you are |
|
86 |
developing a custom widget that derives from one of the standard |
|
87 |
%Hb widgets (such as HbPushButton, HbComboBox, and so on), |
|
88 |
the base class widget most probably has predefined feedback effects, |
|
89 |
and you do not need to do anything. The base class takes care of triggering |
|
90 |
the default effects upon user interaction. |
|
91 |
||
92 |
<b>Custom widgets that derive directly from HbWidget.</b> If your custom |
|
93 |
widget derives directly from HbWidget, and not through any of the standard |
|
94 |
%Hb widgets, you should not use %HbWidgetFeedback. The recommended way |
|
95 |
to define feedback for your widget is to use classes HbInstantFeedback and |
|
96 |
HbContinuousFeedback. |
|
97 |
||
98 |
\section _usecases_hbwidgetfeedback Using HbWidgetFeedback |
|
99 |
||
100 |
\subsection _uc_standardhb_hbwidgetfeedback Supporting feedback effects in a standard widget |
|
101 |
||
102 |
Call the HbWidgetFeedback methods in a standard widget when the user |
|
103 |
interacts with the widget. Choose the correct method according to |
|
104 |
the interaction style: instant or continuous. |
|
105 |
||
106 |
To support instant feedback features in a standard %Hb widget, call |
|
107 |
HbWidgetFeedback::triggered() with a suitable Hb::InstantInteraction |
|
108 |
parameter to specify the interaction type, whenever you detect any |
|
109 |
user interaction that is instant by nature. For example: |
|
110 |
||
111 |
\code |
|
112 |
// The widget has been pressed down and released |
|
113 |
HbWidgetFeedback::triggered(this, Hb::InstantClicked); |
|
114 |
\endcode |
|
115 |
||
116 |
See Hb::InstantInteraction for the list of all predefined instant |
|
117 |
interactions. |
|
118 |
||
119 |
Whenever you detect any of the specified continuous user interactions in |
|
120 |
your standard %Hb widget, or when the continuous interaction ends, call |
|
121 |
either HbWidgetFeedback::continuousTriggered() or HbWidgetFeedback::continuousStopped() |
|
122 |
with the suitable Hb::ContinuousInteraction parameter. For example: |
|
123 |
||
124 |
\code |
|
125 |
// User has started moving the slider handle. |
|
126 |
HbWidgetFeedback::continuousTriggered(this, Hb::ContinuousDragged); |
|
127 |
\endcode |
|
128 |
||
129 |
\code |
|
130 |
// User has stopped moving the slider handle. |
|
131 |
HbWidgetFeedback::continuousStopped(this, Hb::ContinuousDragged); |
|
132 |
\endcode |
|
133 |
||
134 |
See Hb::ContinuousInteraction for the list of all predefined |
|
135 |
continuous interactions. |
|
136 |
||
0
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
137 |
|
34 | 138 |
\sa HbInstantFeedback, HbContinuousFeedback |
0
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
139 |
*/ |
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
140 |
|
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
141 |
/*! |
34 | 142 |
Passes information about an instant interaction from the widget to the |
143 |
feedback manager, which forwards it to all active feedback plugins. |
|
0
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
144 |
|
34 | 145 |
\param widget Target widget of the interaction |
146 |
\param interaction The instant interaction type |
|
147 |
\param modifiers Optional Hb::InteractionModifier flags with more detailed |
|
148 |
information about the interaction |
|
0
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
149 |
*/ |
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
150 |
void HbWidgetFeedback::triggered(const HbWidget *widget, Hb::InstantInteraction interaction, Hb::InteractionModifiers modifiers) |
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
151 |
{ |
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
152 |
HbFeedbackManager* manager = HbFeedbackManager::instance(); |
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
153 |
if (manager) { |
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
154 |
manager->triggered(widget, interaction, modifiers); |
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
155 |
} |
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
156 |
} |
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
157 |
|
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
158 |
/*! |
34 | 159 |
Passes information about a started continuous interaction from the |
160 |
widget to the feedback manager, which forwards it to all active feedback |
|
161 |
plugins. |
|
0
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
162 |
|
34 | 163 |
\param widget Target widget of the interaction |
164 |
\param interaction The continuous interaction type |
|
165 |
\param delta The direction and distance of the interaction |
|
0
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
166 |
*/ |
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
167 |
void HbWidgetFeedback::continuousTriggered(const HbWidget *widget, Hb::ContinuousInteraction interaction, QPointF delta) |
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
168 |
{ |
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
169 |
HbFeedbackManager* manager = HbFeedbackManager::instance(); |
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
170 |
if (manager) { |
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
171 |
manager->continuousTriggered(widget, interaction, delta); |
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
172 |
} |
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
173 |
} |
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
174 |
|
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
175 |
/*! |
34 | 176 |
Passes information about the stopped continuous interaction from the |
177 |
widget to the feedback manager, which forwards it to all active feedback |
|
178 |
plugins. This method is needed for stopping the continuous feedback |
|
0
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
179 |
effects started by the continuous interaction. |
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
180 |
|
34 | 181 |
\param widget Target widget of the interaction |
182 |
\param interaction The continuous interaction type |
|
0
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
183 |
*/ |
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
184 |
void HbWidgetFeedback::continuousStopped(const HbWidget *widget, Hb::ContinuousInteraction interaction) |
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
185 |
{ |
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
186 |
HbFeedbackManager* manager = HbFeedbackManager::instance(); |
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
187 |
if (manager) { |
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
188 |
manager->continuousStopped(widget, interaction); |
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
189 |
} |
16d8024aca5e
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
190 |
} |