1 #ifndef DALI_INTERNAL_PROPERTY_NOTIFICATION_H
2 #define DALI_INTERNAL_PROPERTY_NOTIFICATION_H
5 * Copyright (c) 2023 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/internal/event/common/notifier-interface.h> ///< for NotifierInterface::NotifyId
23 #include <dali/internal/event/common/property-conditions-impl.h>
24 #include <dali/public-api/common/dali-vector.h>
25 #include <dali/public-api/object/property-notification.h>
26 #include <dali/public-api/object/ref-object.h>
30 class PropertyCondition;
36 class PropertyNotification;
38 } // namespace SceneGraph
41 class PropertyNotification;
43 class PropertyNotificationManager;
45 using PropertyNotificationPtr = IntrusivePtr<PropertyNotification>;
48 * PropertyNotification is a proxy for a SceneGraph::PropertyNotification object.
49 * The UpdateManager owns the PropertyNotification object, but the lifetime of the PropertyNotification is
50 * indirectly controlled by the PropertyNotification.
52 class PropertyNotification : public BaseObject
55 using NotifyMode = Dali::PropertyNotification::NotifyMode;
56 using ConditionType = PropertyCondition::Type;
59 * RawArgumentContainer provides fast direct access to arguments for condition evaluation.
61 using RawArgumentContainer = Dali::Vector<float>;
64 * Create a new PropertyNotification object.
65 * @param[in] target The target object to inspect
66 * @param[in] componentIndex Index to the component of a complex property such as a Vector
67 * @param[in] condition The condition for this notification.
68 * @return A smart-pointer to the newly allocated PropertyNotification.
70 static PropertyNotificationPtr New(Property& target,
72 const Dali::PropertyCondition& condition);
76 * @copydoc Dali::PropertyNotification::NotifySignal()
78 Dali::PropertyNotifySignalType& NotifySignal();
81 * Emit the Notify signal
83 void EmitSignalNotify();
86 * Enables PropertyNotification
91 * Disables PropertyNotification
96 * Sets the result from the property condition test for use by applications that connect to the notification signal
98 * @param[in] result The result of the property condition test
100 void SetNotifyResult(bool result);
103 * @copydoc Dali::PropertyNotification::GetCondition
105 const Dali::PropertyCondition& GetCondition() const;
108 * @copydoc Dali::PropertyNotification::GetTarget
110 Dali::Handle GetTarget() const;
113 * @copydoc Dali::PropertyNotification::GetTargetProperty
115 Property::Index GetTargetProperty() const;
118 * @copydoc Dali::PropertyNotification::SetNotifyMode
120 void SetNotifyMode(NotifyMode mode);
123 * @copydoc Dali::PropertyNotification::GetNotifyMode
125 NotifyMode GetNotifyMode();
128 * @copydoc Dali::PropertyNotification::GetNotifyResult
130 bool GetNotifyResult() const;
133 * Compare the passed NotifyId to the one created by this instance
134 * @param[in] notifyId The SceneGraph::PropertyNotification's notify id to compare
135 * @return true if notifyId is the same as the one created by this instance
137 bool CompareSceneObjectNotifyId(NotifierInterface::NotifyId notifyId) const;
141 * Construct a new PropertyNotification.
142 * @param[in] updateManager The UpdateManager associated with this PropertyNotification.
143 * @param[in] propertyNotificationManager The property notification manager object.
144 * @param[in] target The target property.
145 * @param[in] componentIndex Index to the component of a complex property such as a Vector
146 * @param[in] condition The condition for this notification.
148 PropertyNotification(SceneGraph::UpdateManager& updateManager,
149 PropertyNotificationManager& propertyNotificationManager,
152 const Dali::PropertyCondition& condition);
155 * Helper to create a scene-graph PropertyNotification
157 void CreateSceneObject();
160 * Helper to destroy a scene-graph PropertyNotification
162 void DestroySceneObject();
165 * A reference counted object may only be deleted by calling Unreference()
167 ~PropertyNotification() override;
171 PropertyNotification(const PropertyNotification&);
174 PropertyNotification& operator=(const PropertyNotification& rhs);
177 SceneGraph::UpdateManager& mUpdateManager;
178 const SceneGraph::PropertyNotification* mPropertyNotification;
180 Dali::PropertyNotifySignalType mNotifySignal;
183 PropertyNotificationManager& mPropertyNotificationManager; ///< Reference to the property notification manager
184 Object* mObject; ///< Target object, not owned by PropertyNotification.
185 Property::Index mObjectPropertyIndex; ///< Target object's property index of interest.
186 Property::Type mPropertyType; ///< The type of property to evaluate
187 int mComponentIndex; ///< Index to a specific component of a complex property such as a Vector
188 Dali::PropertyCondition mCondition; ///< The PropertyCondition handle.
189 RawArgumentContainer mRawConditionArgs; ///< The Raw Condition args. (float type)
190 NotifyMode mNotifyMode; ///< The current notification mode.
191 bool mNotifyResult; ///< The result of the last condition check that caused a signal emit
192 bool mCompare; ///< The flag of comparing previous property's raw value and current.
195 } // namespace Internal
197 // Helpers for public-api forwarding methods
199 inline Internal::PropertyNotification& GetImplementation(Dali::PropertyNotification& pub)
201 DALI_ASSERT_ALWAYS(pub && "PropertyNotification handle is empty");
203 BaseObject& handle = pub.GetBaseObject();
205 return static_cast<Internal::PropertyNotification&>(handle);
208 inline const Internal::PropertyNotification& GetImplementation(const Dali::PropertyNotification& pub)
210 DALI_ASSERT_ALWAYS(pub && "PropertyNotification handle is empty");
212 const BaseObject& handle = pub.GetBaseObject();
214 return static_cast<const Internal::PropertyNotification&>(handle);
219 #endif // DALI_INTERNAL_PROPERTY_NOTIFICATION_H