44 @beta |
44 @beta |
45 @hbfeedback |
45 @hbfeedback |
46 |
46 |
47 \class HbInstantFeedback |
47 \class HbInstantFeedback |
48 |
48 |
49 \brief Class for instant feedback effects. |
49 \brief The HbInstantFeedback class is used for setting and playing |
50 |
50 instant feedback effects from custom widgets. |
51 Instant feedbacks are used to initiate short, fire&forget type of feedback effects. |
51 |
52 Effects are used as a feedback indication while the user is interacting with the device. |
52 Instant feedback requests are used for initiating short, fire-and-forget |
53 */ |
53 type of feedback effects as a response to short user interactions, |
54 |
54 such as clicking a button or selecting an item on a list. You can |
55 /*! |
55 use the class HbInstantFeedback to ask the feedback framework to play |
56 \fn void HbInstantFeedback::setInstantEffect(HbFeedback::InstantEffect effect) |
56 a selected instant effect, by giving HbInstantFeedback a parameter |
57 |
57 of type HbFeedback::InstantEffect. The type HbFeedback::InstantEffect |
58 Sets the instant effect of the feedback object. This effect will be played when calling |
58 has predefined instant effects for many widget types, such as buttons, |
59 the play() function. |
59 checkboxes, sliders, and so on. |
60 |
60 |
|
61 When you call play() from your widget, HbInstantFeedback calls the internal |
|
62 feedback framework. If effects are enabled in the current application, |
|
63 the effect will be played. Applications can disable effects with the class |
|
64 HbFeedbackSettings, when effects are not wanted. |
|
65 |
|
66 If your custom widget derives from one of the standard %Hb widgets, it |
|
67 probably has some default feedback behaviour defined, and you should |
|
68 rely on the base class widget for triggering the feedback effects through |
|
69 the HbWidgetFeedback class. Note that if you choose to use this class, |
|
70 HbInstantFeedback, to play effects directly, you may end up getting |
|
71 feedback effects twice, both through your call to HbInstantFeedback and |
|
72 through the base class widget feedback mechanism. |
|
73 |
|
74 If your custom widget derives directly from HbWidget, and not through |
|
75 any other %Hb widget, HbInstantFeedback provides you with an easy way |
|
76 to play instant feedback effects. Just call the static method |
|
77 HbInstantFeedback::play(HbFeedback::InstantEffect effect) to play the |
|
78 effect. Alternatively, you can instantiate an HbInstantFeedback object |
|
79 first and set the effect to be played, before calling play(). |
|
80 |
|
81 |
|
82 |
|
83 \sa HbFeedback::InstantEffect, HbContinuousFeedback, HbWidgetFeedback |
|
84 */ |
|
85 |
|
86 /*! |
|
87 Sets the instant effect to be played when calling play(). |
|
88 |
61 \sa instantEffect() |
89 \sa instantEffect() |
62 */ |
90 */ |
63 |
|
64 void HbInstantFeedback::setInstantEffect(HbFeedback::InstantEffect effect) |
91 void HbInstantFeedback::setInstantEffect(HbFeedback::InstantEffect effect) |
65 { |
92 { |
66 d->cEffect = effect; |
93 d->cEffect = effect; |
67 } |
94 } |
68 |
95 |
69 /*! |
96 /*! |
70 \fn void HbFeedback::InstantEffect HbInstantFeedback::instantEffect() const |
97 Returns the currently set instant effect. The instant effect is |
71 |
98 the feedback effect to be played when calling play(). |
72 Returns the instant effect of the instant feedback object. |
99 |
73 |
|
74 \sa setInstantEffect() |
100 \sa setInstantEffect() |
75 */ |
101 */ |
76 |
|
77 HbFeedback::InstantEffect HbInstantFeedback::instantEffect() const |
102 HbFeedback::InstantEffect HbInstantFeedback::instantEffect() const |
78 { |
103 { |
79 return d->cEffect; |
104 return d->cEffect; |
80 } |
105 } |
81 |
106 |
82 /*! |
107 /*! |
83 \fn bool HbInstantFeedback::isValid() const |
108 Returns \c true if an instant effect (other than HbFeedback::None) has been |
84 |
109 defined for this object. |
85 Instant feedback is valid if a proper instant effect (not HbFeedback::None) has been |
110 */ |
86 defined for the feedback. |
|
87 */ |
|
88 |
|
89 bool HbInstantFeedback::isValid() const |
111 bool HbInstantFeedback::isValid() const |
90 { |
112 { |
91 switch(d->cEffect) { |
113 switch(d->cEffect) { |
92 case HbFeedback::None: |
114 case HbFeedback::None: |
93 return false; |
115 return false; |
139 } |
160 } |
140 } |
161 } |
141 |
162 |
142 /*! |
163 /*! |
143 Plays the given instant feedback effect. |
164 Plays the given instant feedback effect. |
|
165 |
|
166 \sa HbFeedback::InstantEffect |
144 */ |
167 */ |
145 void HbInstantFeedback::play(HbFeedback::InstantEffect effect) |
168 void HbInstantFeedback::play(HbFeedback::InstantEffect effect) |
146 { |
169 { |
147 HbFeedbackPlayer* player = HbFeedbackPlayer::instance(); |
170 HbFeedbackPlayer* player = HbFeedbackPlayer::instance(); |
148 if (player) { |
171 if (player) { |
149 player->playInstantFeedback(effect); |
172 player->playInstantFeedback(effect); |
150 } |
173 } |
151 } |
174 } |
152 |
175 |
153 /*! |
176 /*! |
154 Assigns a copy of the feedback \a feedback to this feedback, and returns a |
177 Assigns a copy of \a feedback to this object, and returns a |
155 reference to it. |
178 reference to it. |
156 */ |
179 */ |
157 HbInstantFeedback &HbInstantFeedback::operator=(const HbInstantFeedback & feedback) |
180 HbInstantFeedback &HbInstantFeedback::operator=(const HbInstantFeedback & feedback) |
158 { |
181 { |
159 HbAbstractFeedback::operator =(feedback); |
182 HbAbstractFeedback::operator =(feedback); |
160 setInstantEffect(feedback.instantEffect()); |
183 setInstantEffect(feedback.instantEffect()); |
161 return *this; |
184 return *this; |
162 } |
185 } |
163 |
186 |
164 /*! |
187 /*! |
165 Returns true if this feedback has the same parameters as the feedback |
188 Returns \c true if this object has the same parameters as \a feedback, |
166 \a feedback, otherwise returns false. |
189 otherwise returns \c false. |
167 */ |
190 */ |
168 bool HbInstantFeedback::operator==(const HbInstantFeedback &feedback) const |
191 bool HbInstantFeedback::operator==(const HbInstantFeedback &feedback) const |
169 { |
192 { |
170 return (rect() == feedback.rect() |
193 return (rect() == feedback.rect() |
171 && window() == feedback.window() |
194 && window() == feedback.window() |
172 && d->cEffect == feedback.instantEffect()); |
195 && d->cEffect == feedback.instantEffect()); |
173 } |
196 } |
174 |
197 |
175 /*! |
198 /*! |
176 Returns true if this feedback has different parameters than the feedback |
199 Returns \c true if this object has different parameters from \a feedback, |
177 \a feedback, otherwise returns false. |
200 otherwise returns \c false. |
178 */ |
201 */ |
179 bool HbInstantFeedback::operator!=(const HbInstantFeedback &feedback) const |
202 bool HbInstantFeedback::operator!=(const HbInstantFeedback &feedback) const |
180 { |
203 { |
181 return !(*this == feedback); |
204 return !(*this == feedback); |
182 } |
205 } |