1 #ifndef DALI_INTERNAL_PROPERTY_NOTIFICATION_H
2 #define DALI_INTERNAL_PROPERTY_NOTIFICATION_H
5 * Copyright (c) 2019 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/common/dali-vector.h>
23 #include <dali/public-api/object/ref-object.h>
24 #include <dali/public-api/object/property-notification.h>
25 #include <dali/internal/event/common/property-conditions-impl.h>
30 class PropertyCondition;
37 class PropertyNotification;
42 class PropertyNotification;
44 class PropertyNotificationManager;
46 using PropertyNotificationPtr = IntrusivePtr<PropertyNotification>;
49 * PropertyNotification is a proxy for a SceneGraph::PropertyNotification object.
50 * The UpdateManager owns the PropertyNotification object, but the lifetime of the PropertyNotification is
51 * indirectly controlled by the PropertyNotification.
53 class PropertyNotification : public BaseObject
56 using NotifyMode = Dali::PropertyNotification::NotifyMode;
57 using ConditionType = PropertyCondition::Type;
60 * RawArgumentContainer provides fast direct access to arguments for condition evaluation.
62 using RawArgumentContainer = Dali::Vector<float>;
65 * Create a new PropertyNotification object.
66 * @param[in] target The target object to inspect
67 * @param[in] componentIndex Index to the component of a complex property such as a Vector
68 * @param[in] condition The condition for this notification.
69 * @return A smart-pointer to the newly allocated PropertyNotification.
71 static PropertyNotificationPtr New(Property& target,
73 const Dali::PropertyCondition& condition);
78 * @copydoc Dali::PropertyNotification::NotifySignal()
80 Dali::PropertyNotifySignalType& NotifySignal();
83 * Emit the Notify signal
85 void EmitSignalNotify();
88 * Enables PropertyNotification
93 * Disables PropertyNotification
98 * Sets the result from the property condition test for use by applications that connect to the notification signal
100 * @param[in] result The result of the property condition test
102 void SetNotifyResult(bool result);
105 * @copydoc Dali::PropertyNotification::GetCondition
107 const Dali::PropertyCondition& GetCondition() const;
110 * @copydoc Dali::PropertyNotification::GetTarget
112 Dali::Handle GetTarget() const;
115 * @copydoc Dali::PropertyNotification::GetTargetProperty
117 Property::Index GetTargetProperty() const;
120 * @copydoc Dali::PropertyNotification::SetNotifyMode
122 void SetNotifyMode( NotifyMode mode );
125 * @copydoc Dali::PropertyNotification::GetNotifyMode
127 NotifyMode GetNotifyMode();
130 * @copydoc Dali::PropertyNotification::GetNotifyResult
132 bool GetNotifyResult() const;
135 * Compare the passed sceneObject to the one created by this instance
136 * @param[in] sceneObject The SceneGraph::PropertyNotification pointer to compare
137 * @return true if sceneObject is the same as the one created by this instance
139 bool CompareSceneObject( const SceneGraph::PropertyNotification* sceneObject );
144 * Construct a new PropertyNotification.
145 * @param[in] updateManager The UpdateManager associated with this PropertyNotification.
146 * @param[in] propertyNotificationManager The property notification manager object.
147 * @param[in] target The target property.
148 * @param[in] componentIndex Index to the component of a complex property such as a Vector
149 * @param[in] condition The condition for this notification.
151 PropertyNotification(SceneGraph::UpdateManager& updateManager,
152 PropertyNotificationManager& propertyNotificationManager,
155 const Dali::PropertyCondition& condition);
158 * Helper to create a scene-graph PropertyNotification
160 void CreateSceneObject();
163 * Helper to destroy a scene-graph PropertyNotification
165 void DestroySceneObject();
168 * A reference counted object may only be deleted by calling Unreference()
170 virtual ~PropertyNotification();
175 PropertyNotification(const PropertyNotification&);
178 PropertyNotification& operator=(const PropertyNotification& rhs);
182 SceneGraph::UpdateManager& mUpdateManager;
183 const SceneGraph::PropertyNotification* mPropertyNotification;
185 Dali::PropertyNotifySignalType mNotifySignal;
189 PropertyNotificationManager& mPropertyNotificationManager; ///< Reference to the property notification manager
190 Object* mObject; ///< Target object, not owned by PropertyNotification.
191 Property::Index mObjectPropertyIndex; ///< Target object's property index of interest.
192 Property::Type mPropertyType; ///< The type of property to evaluate
193 int mComponentIndex; ///< Index to a specific component of a complex property such as a Vector
194 Dali::PropertyCondition mCondition; ///< The PropertyCondition handle.
195 RawArgumentContainer mRawConditionArgs; ///< The Raw Condition args. (float type)
196 NotifyMode mNotifyMode; ///< The current notification mode.
197 bool mNotifyResult; ///< The result of the last condition check that caused a signal emit
198 bool mCompare; ///< The flag of comparing previous property's raw value and current.
201 } // namespace Internal
203 // Helpers for public-api forwarding methods
205 inline Internal::PropertyNotification& GetImplementation(Dali::PropertyNotification& pub)
207 DALI_ASSERT_ALWAYS( pub && "PropertyNotification handle is empty" );
209 BaseObject& handle = pub.GetBaseObject();
211 return static_cast<Internal::PropertyNotification&>(handle);
214 inline const Internal::PropertyNotification& GetImplementation(const Dali::PropertyNotification& pub)
216 DALI_ASSERT_ALWAYS( pub && "PropertyNotification handle is empty" );
218 const BaseObject& handle = pub.GetBaseObject();
220 return static_cast<const Internal::PropertyNotification&>(handle);
225 #endif // DALI_INTERNAL_PROPERTY_NOTIFICATION_H