2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.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
8 // http://floralicense.org/license/
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.
17 #include <dali/internal/event/common/proxy-object.h>
18 #include <dali/internal/event/animation/property-constraint.h>
19 #include <dali/internal/event/animation/property-input-accessor.h>
20 #include <dali/internal/event/animation/property-input-indexer.h>
21 #include <dali/internal/update/common/property-base.h>
22 #include <dali/internal/update/common/property-owner.h>
23 #include <dali/internal/update/common/scene-graph-property-notification.h>
24 #include <dali/internal/update/common/property-condition-functions.h>
37 PropertyNotification* PropertyNotification::New(ProxyObject& proxy,
38 Property::Index propertyIndex,
39 Property::Type propertyType,
41 ConditionType condition,
42 RawArgumentContainer& arguments,
43 NotifyMode notifyMode)
45 return new PropertyNotification( proxy, propertyIndex, propertyType, componentIndex, condition, arguments, notifyMode );
49 PropertyNotification::PropertyNotification(ProxyObject& proxy,
50 Property::Index propertyIndex,
51 Property::Type propertyType,
53 ConditionType condition,
54 RawArgumentContainer& arguments,
55 NotifyMode notifyMode)
57 mPropertyIndex(propertyIndex),
58 mPropertyType(propertyType),
60 mComponentIndex(componentIndex),
61 mConditionType(condition),
62 mArguments(arguments),
65 SetNotifyMode(notifyMode);
67 switch(mConditionType)
69 case PropertyCondition::LessThan:
71 mConditionFunction = LessThan::GetFunction(mPropertyType);
74 case PropertyCondition::GreaterThan:
76 mConditionFunction = GreaterThan::GetFunction(mPropertyType);
79 case PropertyCondition::Inside:
81 mConditionFunction = Inside::GetFunction(mPropertyType);
84 case PropertyCondition::Outside:
86 mConditionFunction = Outside::GetFunction(mPropertyType);
89 case PropertyCondition::Step:
91 mConditionFunction = Step::GetFunction(mPropertyType);
94 case PropertyCondition::VariableStep:
96 mConditionFunction = VariableStep::GetFunction(mPropertyType);
99 case PropertyCondition::False:
101 mConditionFunction = PropertyNotification::EvalFalse;
106 mProperty = mProxy->GetSceneObjectInputProperty( mPropertyIndex );
107 int internalComponentIndex = mProxy->GetPropertyComponentIndex(mPropertyIndex);
108 if( internalComponentIndex != Property::INVALID_COMPONENT_INDEX )
110 // override the one passed in
111 mComponentIndex = internalComponentIndex;
115 PropertyNotification::~PropertyNotification()
119 bool PropertyNotification::EvalFalse( const Dali::PropertyInput& value, RawArgumentContainer& arg )
124 void PropertyNotification::SetNotifyMode( NotifyMode notifyMode )
128 case Dali::PropertyNotification::Disabled:
130 mNotifyValidity[0] = false;
131 mNotifyValidity[1] = false;
134 case Dali::PropertyNotification::NotifyOnTrue:
136 mNotifyValidity[0] = false;
137 mNotifyValidity[1] = true;
140 case Dali::PropertyNotification::NotifyOnFalse:
142 mNotifyValidity[0] = true;
143 mNotifyValidity[1] = false;
146 case Dali::PropertyNotification::NotifyOnChanged:
148 mNotifyValidity[0] = true;
149 mNotifyValidity[1] = true;
155 bool PropertyNotification::Check( BufferIndex bufferIndex )
157 bool notifyRequired = false;
158 bool currentValid = false;
160 if ( Property::INVALID_COMPONENT_INDEX != mComponentIndex )
162 // Evaluate Condition
163 const PropertyInputComponentAccessor component( mProperty, mComponentIndex );
164 const PropertyInputIndexer< PropertyInputComponentAccessor > input( bufferIndex, &component );
165 currentValid = mConditionFunction(input, mArguments);
169 // Evaluate Condition
170 const PropertyInputIndexer< PropertyInputImpl > input( bufferIndex, mProperty );
171 currentValid = mConditionFunction(input, mArguments);
174 if( mValid != currentValid
175 || (currentValid && ((mConditionType == PropertyCondition::Step)
176 || (mConditionType == PropertyCondition::VariableStep))) )
178 mValid = currentValid;
179 notifyRequired = mNotifyValidity[currentValid];
182 return notifyRequired;
185 bool PropertyNotification::GetValidity() const
190 } // namespace SceneGraph
192 } // namespace Internal