Dali 3D User Interface Engine
property-notification-impl.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 
18 // CLASS HEADER
20 
21 // INTERNAL INCLUDES
32 
34 
35 namespace Dali
36 {
37 
38 namespace Internal
39 {
40 
42  int componentIndex,
43  const Dali::PropertyCondition& condition)
44 {
46 
47  UpdateManager& updateManager = tls.GetUpdateManager();
48 
49  StagePtr stage = Stage::GetCurrent();
50  if( stage )
51  {
52  PropertyNotificationManager& propertyNotificationManager = stage->GetPropertyNotificationManager();
53  PropertyNotificationPtr propertyNotification = new PropertyNotification(updateManager,
54  propertyNotificationManager,
55  target,
56  componentIndex,
57  condition);
58  return propertyNotification;
59  }
60  else
61  {
62  return NULL;
63  }
64 }
65 
67  PropertyNotificationManager& propertyNotificationManager,
68  Property& target,
69  int componentIndex,
70  const Dali::PropertyCondition& condition )
71 : mUpdateManager( updateManager ),
72  mPropertyNotification( NULL ),
73  mPropertyNotificationManager( propertyNotificationManager ),
74  mObjectPropertyIndex( target.propertyIndex ),
75  mPropertyType( Property::NONE ),
76  mComponentIndex( componentIndex ),
77  mCondition( condition ),
78  mNotifyMode( Dali::PropertyNotification::NotifyOnTrue ),
79  mNotifyResult( false )
80 {
81  const Internal::PropertyCondition& conditionImpl = GetImplementation( condition );
82 
83  Dali::Vector<float>::SizeType count = conditionImpl.arguments.Count();
84  for( Dali::Vector<float>::SizeType index = 0; index < count; ++index )
85  {
86  mRawConditionArgs.PushBack( conditionImpl.arguments[ index ] );
87  }
88 
89  // Observe target object and create/destroy notification scene object accordingly.
90  mObject = dynamic_cast<Object*>( &GetImplementation(target.object) );
91  if ( mObject )
92  {
94 
95  int internalComponentIndex = mObject->GetPropertyComponentIndex(mObjectPropertyIndex);
96  if( internalComponentIndex != Property::INVALID_COMPONENT_INDEX )
97  {
98  // override the one passed in
99  mComponentIndex = internalComponentIndex;
100  }
102  {
104  if( type == Property::VECTOR2
105  || type == Property::VECTOR3
106  || type == Property::VECTOR4 )
107  {
109  }
110  }
111 
112  // Check if target scene-object already present, and if so create our notification
113  // scene-object
115  if (object)
116  {
118  }
119  }
120 
121  // Connect to the property notification manager
123 }
124 
126 {
127  Disable();
128 
129  // Guard to disallow use of PropertyNotificationManager after Core has been destroyed
130  if ( Stage::IsInstalled() )
131  {
132  // Disconnect from the property notification manager
134  }
135 }
136 
138 {
139  return mNotifySignal;
140 }
141 
143 {
144  Dali::PropertyNotification source(this);
145 
146  mNotifySignal.Emit( source );
147 }
148 
150 {
152 }
153 
155 {
156  // Guard to allow handle destruction after Core has been destroyed
157  if ( Stage::IsInstalled() )
158  {
159  // Stop scene-graph from monitoring the target's properties.
161  }
162 }
163 
165 {
166  mNotifyResult = result;
167 }
168 
170 {
171  return mCondition;
172 }
173 
175 {
176  Dali::Handle handle(mObject);
177 
178  return handle;
179 }
180 
182 {
183  return mObjectPropertyIndex;
184 }
185 
187 {
188  mNotifyMode = mode;
190  {
192  }
193 }
194 
196 {
197  return mNotifyMode;
198 }
199 
201 {
202  return mNotifyResult;
203 }
204 
206 {
207  return sceneObject && sceneObject == mPropertyNotification;
208 }
209 
211 {
212  // this method can be called from constructor and on stage connection
213  if( !mPropertyNotification )
214  {
215  // Create a new PropertyNotification, temporarily owned
222  mNotifyMode );
223  // Keep a const pointer to the PropertyNotification.
224  mPropertyNotification = propertyNotification;
225 
226  // Transfer scene object ownership to the update manager through a message
227  AddPropertyNotificationMessage( mUpdateManager, propertyNotification );
228  }
229 }
230 
232 {
233  if ( mPropertyNotification != NULL )
234  {
235  // Remove PropertyNotification using a message to the update manager
237  mPropertyNotification = NULL;
238  }
239 }
240 
241 } // namespace Internal
242 
243 } // namespace Dali
Dali Docs Home
Read more about Dali