[dali_1.0.15] Merge branch 'tizen'
[platform/core/uifw/dali-core.git] / dali / public-api / object / property-notification.h
1 #ifndef __DALI_PROPERTY_NOTIFICATION_H__
2 #define __DALI_PROPERTY_NOTIFICATION_H__
3
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #include <dali/public-api/object/base-handle.h>
23 #include <dali/public-api/object/property-notification-declarations.h>
24 #include <dali/public-api/object/property-conditions.h>
25 #include <dali/public-api/object/property.h>
26
27 namespace Dali
28 {
29
30 namespace Internal DALI_INTERNAL
31 {
32 class PropertyNotification;
33 }
34
35 /**
36  * @brief This is used to issue a notification upon a condition of the property being met.
37  *
38  * For example checking if Actor::POSITION_X > 100.0.
39  * @see Dali::PropertyCondition
40  */
41 class DALI_IMPORT_API PropertyNotification : public BaseHandle
42 {
43 public:
44   /**
45    * @brief Enumeration to describe how to check condition
46    */
47   enum NotifyMode
48   {
49     Disabled,                             ///< Don't notify, regardless of result of Condition
50     NotifyOnTrue,                         ///< Notify whenever condition changes from false to true.
51     NotifyOnFalse,                        ///< Notify whenever condition changes from true to false.
52     NotifyOnChanged                       ///< Notify whenever condition changes (false to true, and true to false)
53   };
54
55 public:
56
57   /**
58    * @brief Create an uninitialized PropertyNotification; this can be initialized with PropertyNotification::New().
59    *
60    * Calling member functions with an uninitialized Dali::Object is not allowed.
61    */
62   PropertyNotification();
63
64   /**
65    * @brief Downcast an Object handle to PropertyNotification.
66    *
67    * If handle points to an PropertyNotification object the downcast
68    * produces valid handle. If not the returned handle is left
69    * uninitialized.
70    *
71    * @param[in] handle to An object
72    * @return handle to a PropertyNotification object or an uninitialized handle
73    */
74   static PropertyNotification DownCast( BaseHandle handle );
75
76   /**
77    * @brief Destructor
78    *
79    * This is non-virtual since derived Handle types must not contain data or virtual methods.
80    */
81   ~PropertyNotification();
82
83   /**
84    * @brief This copy constructor is required for (smart) pointer semantics.
85    *
86    * @param [in] handle A reference to the copied handle
87    */
88   PropertyNotification(const PropertyNotification& handle);
89
90   /**
91    * @brief This assignment operator is required for (smart) pointer semantics.
92    *
93    * @param [in] rhs  A reference to the copied handle
94    * @return A reference to this
95    */
96   PropertyNotification& operator=(const PropertyNotification& rhs);
97
98   /**
99    * @brief This method is defined to allow assignment of the NULL value,
100    * and will throw an exception if passed any other value.
101    *
102    * Assigning to NULL is an alias for Reset().
103    * @param [in] rhs  A NULL pointer
104    * @return A reference to this handle
105    */
106   PropertyNotification& operator=(BaseHandle::NullType* rhs);
107
108   /**
109    * @brief Get the condition of this notification
110    *
111    * @return The condition is returned
112    */
113   PropertyCondition GetCondition();
114
115   /**
116    * @brief Get the condition of this notification
117    *
118    * @return The condition is returned
119    */
120   const PropertyCondition& GetCondition() const;
121
122   /**
123    * @brief Get the target handle that this notification is observing.
124    */
125   Dali::Handle GetTarget() const;
126
127   /**
128    * @brief Get the target handle's property index that this notification
129    * is observing.
130    *
131    * @return The target property.
132    */
133   Property::Index GetTargetProperty() const;
134
135   /**
136    * @brief Sets the Notification mode. This determines how the property
137    * notification should respond to the result of a condition.
138    *
139    * @param[in] mode Notification mode (Default is PropertyNotification::NotifyOnTrue)
140    */
141   void SetNotifyMode( NotifyMode mode );
142
143   /**
144    * @brief Retrieves the current Notification mode.
145    *
146    * @return Notification mode.
147    */
148   NotifyMode GetNotifyMode();
149
150   /**
151    * @brief Gets the result of the last condition check that caused a signal emit,
152    * useful when using NotifyOnChanged mode and need to know what it changed to.
153    *
154    * @return whether condition result that triggered last emit was true or false
155    */
156   bool GetNotifyResult() const;
157
158   /**
159    * @brief Connect to this signal to be notified when the notification has occurred.
160    *
161    * @return A signal object to Connect() with.
162    */
163   PropertyNotifySignalV2& NotifySignal();
164
165 public: // Not intended for use by Application developers
166
167   /**
168    * @brief This constructor is used by Dali New() methods.
169    *
170    * @param [in] propertyNotification A pointer to a newly allocated Dali resource
171    */
172   explicit DALI_INTERNAL PropertyNotification(Internal::PropertyNotification* propertyNotification);
173 };
174
175 } // namespace Dali
176
177 #endif // __DALI_PROPERTY_NOTIFICATION_H__