1 #ifndef DALI_INTERNAL_FEEDBACK_STYLE_H
2 #define DALI_INTERNAL_FEEDBACK_STYLE_H
5 * Copyright (c) 2021 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.
22 #include <dali/devel-api/adaptor-framework/feedback-player.h>
23 #include <dali/public-api/adaptor-framework/style-change.h>
24 #include <dali/public-api/object/base-handle.h>
25 #include <dali/public-api/signals/connection-tracker.h>
26 #include <dali/public-api/signals/slot-delegate.h>
30 #include <dali-toolkit/internal/feedback/feedback-ids.h>
38 struct FeedbackStyleInfo;
39 struct SignalFeedbackInfo;
42 * Plays feedback effects for Dali-Toolkit UI Controls.
44 * This functionality relies on an adaptor plugin.
45 * (And will have no effect if this is not loaded)
48 class FeedbackStyle : public ConnectionTracker
62 * Called to start playing feedback effects.
67 * Called to stop playing feedback effects.
72 * Callback function to play a feedback effect when a signal is emitted for an object
73 * Plays feedback effect.
74 * @param [in] type The Object type
75 * @param [in] signalName The name of the signal
77 void PlayFeedback(const std::string& type, const std::string& signalName);
80 * Connects feedback to signals for the newly created object
81 * @param [in] object Handle to the newly created object
83 void ObjectCreated(BaseHandle object);
86 * Style changed so reload the theme file
87 * @param [in] userDefinedThemePath Theme filename path
88 * @param [in] styleChange The type of style change
90 void StyleChanged(const std::string& userDefinedThemePath, StyleChange::Type styleChange);
94 * Helper to retrieve styleInfo from mStyleInfoLut
95 * @param type A string described a type of object
96 * @return The style information for the given object
98 const FeedbackStyleInfo& GetStyleInfo(const std::string& type) const;
101 * Callback function for Dali::Toolkit::PushButton::SignalPressed signal
102 * Plays feedback effect.
103 * @param [in] effect The feedback effect to play
105 bool LoadTheme(const std::string& data);
108 * Loads a string representation the theme.
109 * @param [in] data A string represenation of the theme.
110 * @param [in] format The string representation format ie JSON.
112 void LoadFromString(const std::string& data);
115 * Helper to store signal information.
116 * @param [in] styleInfo The information will be stored here.
117 * @param [in] signalInfo The information to add.
119 void AddSignalInfo(FeedbackStyleInfo& styleInfo, SignalFeedbackInfo&& signalInfo);
122 * Map a pattern string to feedback pattern ID.
123 * @param [in] pattern The pattern string.
124 * @return A feedback pattern ID.
126 FeedbackPattern GetFeedbackPattern(const std::string& pattern);
129 * Plays a feedback effect
130 * @param [in] type The feedback type haptic or sound
131 * @param [in] effect The feedback effect to play
133 void PlayEffect(FeedbackType type, FeedbackPattern effect);
136 * Plays a haptic or sound effect file
137 * @param [in] type The feedback type haptic or sound
138 * @param [in] file The path to the file containing the effect
140 void PlayFile(FeedbackType type, const std::string& file);
143 Dali::FeedbackPlayer mFeedback;
145 std::map<const std::string, FeedbackPattern> mFeedbackPatternLut; ///< Used to convert feedback pattern strings into enumerated values
146 std::map<const std::string, FeedbackStyleInfo> mStyleInfoLut; ///< Converts key strings into style information
149 } // namespace Internal
151 } // namespace Toolkit
155 #endif // DALI_INTERNAL_FEEDBACK_STYLE_H