1 #ifndef DALI_PROPERTY_NOTIFICATION_H
2 #define DALI_PROPERTY_NOTIFICATION_H
5 * Copyright (c) 2020 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/public-api/object/base-handle.h>
23 #include <dali/public-api/object/property-conditions.h>
24 #include <dali/public-api/object/property-notification-declarations.h>
25 #include <dali/public-api/object/property.h>
30 * @addtogroup dali_core_object
34 namespace Internal DALI_INTERNAL
36 class PropertyNotification;
40 * @brief This is used to issue a notification upon a condition of the property being met.
42 * For example checking if Actor::POSITION_X > 100.0.
44 * @see Dali::PropertyCondition
46 class DALI_CORE_API PropertyNotification : public BaseHandle
50 * @brief Enumeration for description of how to check condition.
55 DISABLED, ///< Don't notify, regardless of result of Condition @SINCE_1_9.28
56 NOTIFY_ON_TRUE, ///< Notify whenever condition changes from false to true. @SINCE_1_9.28
57 NOTIFY_ON_FALSE, ///< Notify whenever condition changes from true to false. @SINCE_1_9.28
58 NOTIFY_ON_CHANGED ///< Notify whenever condition changes (false to true, and true to false) @SINCE_1_9.28
63 * @brief Creates an uninitialized PropertyNotification; this can be initialized with PropertyNotification::New().
65 * Calling member functions with an uninitialized Dali::Object is not allowed.
68 PropertyNotification();
71 * @brief Downcasts a handle to PropertyNotification handle.
73 * If handle points to a PropertyNotification object, the downcast
74 * produces valid handle. If not, the returned handle is left
78 * @param[in] handle to An object
79 * @return handle to a PropertyNotification object or an uninitialized handle
81 static PropertyNotification DownCast(BaseHandle handle);
86 * This is non-virtual since derived Handle types must not contain data or virtual methods.
89 ~PropertyNotification();
92 * @brief This copy constructor is required for (smart) pointer semantics.
95 * @param[in] handle A reference to the copied handle
97 PropertyNotification(const PropertyNotification& handle);
100 * @brief This assignment operator is required for (smart) pointer semantics.
103 * @param[in] rhs A reference to the copied handle
104 * @return A reference to this
106 PropertyNotification& operator=(const PropertyNotification& rhs);
109 * @brief Move constructor.
112 * @param[in] rhs A reference to the moved handle
114 PropertyNotification(PropertyNotification&& rhs);
117 * @brief Move assignment operator.
120 * @param[in] rhs A reference to the moved handle
121 * @return A reference to this handle
123 PropertyNotification& operator=(PropertyNotification&& rhs);
126 * @brief Gets the condition of this notification.
129 * @return The condition is returned
131 PropertyCondition GetCondition();
134 * @brief Gets the condition of this notification.
137 * @return The condition is returned
139 const PropertyCondition& GetCondition() const;
142 * @brief Gets the target handle that this notification is observing.
144 * @return The target handle
146 Dali::Handle GetTarget() const;
149 * @brief Gets the target handle's property index that this notification
153 * @return The target property
155 Property::Index GetTargetProperty() const;
158 * @brief Sets the Notification mode.
160 * This determines how the property
161 * notification should respond to the result of a condition.
164 * @param[in] mode Notification mode (Default is PropertyNotification::NOTIFY_ON_TRUE)
166 void SetNotifyMode(NotifyMode mode);
169 * @brief Retrieves the current Notification mode.
172 * @return Notification mode
174 NotifyMode GetNotifyMode();
177 * @brief Gets the result of the last condition check that caused a signal emit,
178 * useful when using NOTIFY_ON_CHANGED mode and need to know what it changed to.
181 * @return whether condition result that triggered last emit was true or false
183 bool GetNotifyResult() const;
186 * @brief Connects to this signal to be notified when the notification has occurred.
189 * @return A signal object to Connect() with
191 PropertyNotifySignalType& NotifySignal();
193 public: // Not intended for use by Application developers
196 * @brief This constructor is used by Dali New() methods.
199 * @param[in] propertyNotification A pointer to a newly allocated Dali resource
201 explicit DALI_INTERNAL PropertyNotification(Internal::PropertyNotification* propertyNotification);
210 #endif // DALI_PROPERTY_NOTIFICATION_H