1 #ifndef __DALI_INTERNAL_FEEDBACK_STYLE_H__
2 #define __DALI_INTERNAL_FEEDBACK_STYLE_H__
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
23 #include <dali/public-api/object/base-handle.h>
24 #include <dali/devel-api/adaptor-framework/feedback-player.h>
25 #include <dali/public-api/signals/connection-tracker.h>
26 #include <dali/public-api/adaptor-framework/style-change.h>
27 #include <dali/public-api/signals/slot-delegate.h>
30 #include <dali-toolkit/internal/feedback/feedback-ids.h>
41 struct FeedbackStyleInfo;
42 struct SignalFeedbackInfo;
45 * Plays feedback effects for Dali-Toolkit UI Controls.
47 * This functionality relies on an adaptor plugin.
48 * (And will have no effect if this is not loaded)
51 class FeedbackStyle : public ConnectionTracker
66 * Called to start playing feedback effects.
71 * Called to stop playing feedback effects.
76 * Callback function to play a feedback effect when a signal is emitted for an object
77 * Plays feedback effect.
78 * @param [in] type The Object type
79 * @param [in] signalName The name of the signal
81 void PlayFeedback(const std::string& type, const std::string& signalName);
84 * Connects feedback to signals for the newly created object
85 * @param [in] object Handle to the newly created object
87 void ObjectCreated( BaseHandle object );
90 * Style changed so reload the theme file
91 * @param [in] userDefinedThemePath Theme filename path
92 * @param [in] styleChange The type of style change
94 void StyleChanged(const std::string& userDefinedThemePath, StyleChange::Type styleChange);
99 * Helper to retrieve styleInfo from mStyleInfoLut
100 * @param type A string described a type of object
101 * @return The style information for the given object
103 const FeedbackStyleInfo& GetStyleInfo( const std::string& type) const;
106 * Callback function for Dali::Toolkit::PushButton::SignalPressed signal
107 * Plays feedback effect.
108 * @param [in] effect The feedback effect to play
110 bool LoadTheme(const std::string& data);
113 * Loads a string representation the theme.
114 * @param [in] data A string represenation of the theme.
115 * @param [in] format The string representation format ie JSON.
117 void LoadFromString( const std::string& data );
120 * Helper to store signal information.
121 * @param [in] styleInfo The information will be stored here.
122 * @param [in] signalInfo The information to add.
124 void AddSignalInfo( FeedbackStyleInfo& styleInfo, SignalFeedbackInfo signalInfo );
127 * Map a pattern string to feedback pattern ID.
128 * @param [in] pattern The pattern string.
129 * @return A feedback pattern ID.
131 FeedbackPattern GetFeedbackPattern( const std::string& pattern );
134 * Plays a feedback effect
135 * @param [in] type The feedback type haptic or sound
136 * @param [in] effect The feedback effect to play
138 void PlayEffect(FeedbackType type, FeedbackPattern effect);
141 * Plays a haptic or sound effect file
142 * @param [in] type The feedback type haptic or sound
143 * @param [in] file The path to the file containing the effect
145 void PlayFile(FeedbackType type, const std::string& file);
148 Dali::FeedbackPlayer mFeedback;
150 std::map<const std::string, FeedbackPattern> mFeedbackPatternLut; ///< Used to convert feedback pattern strings into enumerated values
151 std::map<const std::string, FeedbackStyleInfo> mStyleInfoLut; ///< Converts key strings into style information
153 SlotDelegate< FeedbackStyle > mConnections; ///< Maintains the connections to the Object registry.
156 } // namespace Toolkit
158 } // namespace Internal
162 #endif // __DALI_INTERNAL_FEEDBACK_STYLE_H__