1 #ifndef DALI_INTERNAL_PROPERTY_NOTIFICATION_H
2 #define DALI_INTERNAL_PROPERTY_NOTIFICATION_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/internal/event/common/property-conditions-impl.h>
23 #include <dali/public-api/common/dali-vector.h>
24 #include <dali/public-api/object/property-notification.h>
25 #include <dali/public-api/object/ref-object.h>
29 class PropertyCondition;
35 class PropertyNotification;
37 } // namespace SceneGraph
40 class PropertyNotification;
42 class PropertyNotificationManager;
44 using PropertyNotificationPtr = IntrusivePtr<PropertyNotification>;
47 * PropertyNotification is a proxy for a SceneGraph::PropertyNotification object.
48 * The UpdateManager owns the PropertyNotification object, but the lifetime of the PropertyNotification is
49 * indirectly controlled by the PropertyNotification.
51 class PropertyNotification : public BaseObject
54 using NotifyMode = Dali::PropertyNotification::NotifyMode;
55 using ConditionType = PropertyCondition::Type;
58 * RawArgumentContainer provides fast direct access to arguments for condition evaluation.
60 using RawArgumentContainer = Dali::Vector<float>;
63 * Create a new PropertyNotification object.
64 * @param[in] target The target object to inspect
65 * @param[in] componentIndex Index to the component of a complex property such as a Vector
66 * @param[in] condition The condition for this notification.
67 * @return A smart-pointer to the newly allocated PropertyNotification.
69 static PropertyNotificationPtr New(Property& target,
71 const Dali::PropertyCondition& condition);
75 * @copydoc Dali::PropertyNotification::NotifySignal()
77 Dali::PropertyNotifySignalType& NotifySignal();
80 * Emit the Notify signal
82 void EmitSignalNotify();
85 * Enables PropertyNotification
90 * Disables PropertyNotification
95 * Sets the result from the property condition test for use by applications that connect to the notification signal
97 * @param[in] result The result of the property condition test
99 void SetNotifyResult(bool result);
102 * @copydoc Dali::PropertyNotification::GetCondition
104 const Dali::PropertyCondition& GetCondition() const;
107 * @copydoc Dali::PropertyNotification::GetTarget
109 Dali::Handle GetTarget() const;
112 * @copydoc Dali::PropertyNotification::GetTargetProperty
114 Property::Index GetTargetProperty() const;
117 * @copydoc Dali::PropertyNotification::SetNotifyMode
119 void SetNotifyMode(NotifyMode mode);
122 * @copydoc Dali::PropertyNotification::GetNotifyMode
124 NotifyMode GetNotifyMode();
127 * @copydoc Dali::PropertyNotification::GetNotifyResult
129 bool GetNotifyResult() const;
132 * Compare the passed sceneObject to the one created by this instance
133 * @param[in] sceneObject The SceneGraph::PropertyNotification pointer to compare
134 * @return true if sceneObject is the same as the one created by this instance
136 bool CompareSceneObject(const SceneGraph::PropertyNotification* sceneObject);
140 * Construct a new PropertyNotification.
141 * @param[in] updateManager The UpdateManager associated with this PropertyNotification.
142 * @param[in] propertyNotificationManager The property notification manager object.
143 * @param[in] target The target property.
144 * @param[in] componentIndex Index to the component of a complex property such as a Vector
145 * @param[in] condition The condition for this notification.
147 PropertyNotification(SceneGraph::UpdateManager& updateManager,
148 PropertyNotificationManager& propertyNotificationManager,
151 const Dali::PropertyCondition& condition);
154 * Helper to create a scene-graph PropertyNotification
156 void CreateSceneObject();
159 * Helper to destroy a scene-graph PropertyNotification
161 void DestroySceneObject();
164 * A reference counted object may only be deleted by calling Unreference()
166 ~PropertyNotification() override;
170 PropertyNotification(const PropertyNotification&);
173 PropertyNotification& operator=(const PropertyNotification& rhs);
176 SceneGraph::UpdateManager& mUpdateManager;
177 const SceneGraph::PropertyNotification* mPropertyNotification;
179 Dali::PropertyNotifySignalType mNotifySignal;
182 PropertyNotificationManager& mPropertyNotificationManager; ///< Reference to the property notification manager
183 Object* mObject; ///< Target object, not owned by PropertyNotification.
184 Property::Index mObjectPropertyIndex; ///< Target object's property index of interest.
185 Property::Type mPropertyType; ///< The type of property to evaluate
186 int mComponentIndex; ///< Index to a specific component of a complex property such as a Vector
187 Dali::PropertyCondition mCondition; ///< The PropertyCondition handle.
188 RawArgumentContainer mRawConditionArgs; ///< The Raw Condition args. (float type)
189 NotifyMode mNotifyMode; ///< The current notification mode.
190 bool mNotifyResult; ///< The result of the last condition check that caused a signal emit
191 bool mCompare; ///< The flag of comparing previous property's raw value and current.
194 } // namespace Internal
196 // Helpers for public-api forwarding methods
198 inline Internal::PropertyNotification& GetImplementation(Dali::PropertyNotification& pub)
200 DALI_ASSERT_ALWAYS(pub && "PropertyNotification handle is empty");
202 BaseObject& handle = pub.GetBaseObject();
204 return static_cast<Internal::PropertyNotification&>(handle);
207 inline const Internal::PropertyNotification& GetImplementation(const Dali::PropertyNotification& pub)
209 DALI_ASSERT_ALWAYS(pub && "PropertyNotification handle is empty");
211 const BaseObject& handle = pub.GetBaseObject();
213 return static_cast<const Internal::PropertyNotification&>(handle);
218 #endif // DALI_INTERNAL_PROPERTY_NOTIFICATION_H