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 DALI_ASSERT_ALWAYS(false && "Unrecognized ConditionType");
111 mProperty = mProxy->GetSceneObjectInputProperty( mPropertyIndex );
112 int internalComponentIndex = mProxy->GetPropertyComponentIndex(mPropertyIndex);
113 if( internalComponentIndex != Property::INVALID_COMPONENT_INDEX )
115 // override the one passed in
116 mComponentIndex = internalComponentIndex;
120 PropertyNotification::~PropertyNotification()
124 bool PropertyNotification::EvalFalse( const Dali::PropertyInput& value, RawArgumentContainer& arg )
129 void PropertyNotification::SetNotifyMode( NotifyMode notifyMode )
133 case Dali::PropertyNotification::Disabled:
135 mNotifyValidity[0] = false;
136 mNotifyValidity[1] = false;
139 case Dali::PropertyNotification::NotifyOnTrue:
141 mNotifyValidity[0] = false;
142 mNotifyValidity[1] = true;
145 case Dali::PropertyNotification::NotifyOnFalse:
147 mNotifyValidity[0] = true;
148 mNotifyValidity[1] = false;
151 case Dali::PropertyNotification::NotifyOnChanged:
153 mNotifyValidity[0] = true;
154 mNotifyValidity[1] = true;
160 bool PropertyNotification::Check( BufferIndex bufferIndex )
162 bool notifyRequired = false;
163 bool currentValid = false;
165 if ( Property::INVALID_COMPONENT_INDEX != mComponentIndex )
167 // Evaluate Condition
168 const PropertyInputComponentAccessor component( mProperty, mComponentIndex );
169 const PropertyInputIndexer< PropertyInputComponentAccessor > input( bufferIndex, &component );
170 currentValid = mConditionFunction(input, mArguments);
174 // Evaluate Condition
175 const PropertyInputIndexer< PropertyInputImpl > input( bufferIndex, mProperty );
176 currentValid = mConditionFunction(input, mArguments);
179 if( mValid != currentValid
180 || (currentValid && ((mConditionType == PropertyCondition::Step)
181 || (mConditionType == PropertyCondition::VariableStep))) )
183 mValid = currentValid;
184 notifyRequired = mNotifyValidity[currentValid];
187 return notifyRequired;
190 bool PropertyNotification::GetValidity() const
195 } // namespace SceneGraph
197 } // namespace Internal