2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 #include <dali/internal/event/common/proxy-object.h>
19 #include <dali/internal/event/animation/property-constraint.h>
20 #include <dali/internal/event/animation/property-input-accessor.h>
21 #include <dali/internal/event/animation/property-input-indexer.h>
22 #include <dali/internal/update/common/property-base.h>
23 #include <dali/internal/update/common/property-owner.h>
24 #include <dali/internal/update/common/scene-graph-property-notification.h>
25 #include <dali/internal/update/common/property-condition-functions.h>
38 PropertyNotification* PropertyNotification::New(ProxyObject& proxy,
39 Property::Index propertyIndex,
40 Property::Type propertyType,
42 ConditionType condition,
43 RawArgumentContainer& arguments,
44 NotifyMode notifyMode)
46 return new PropertyNotification( proxy, propertyIndex, propertyType, componentIndex, condition, arguments, notifyMode );
50 PropertyNotification::PropertyNotification(ProxyObject& proxy,
51 Property::Index propertyIndex,
52 Property::Type propertyType,
54 ConditionType condition,
55 RawArgumentContainer& arguments,
56 NotifyMode notifyMode)
58 mPropertyIndex(propertyIndex),
59 mPropertyType(propertyType),
61 mComponentIndex(componentIndex),
62 mConditionType(condition),
63 mArguments(arguments),
66 SetNotifyMode(notifyMode);
68 switch(mConditionType)
70 case PropertyCondition::LessThan:
72 mConditionFunction = LessThan::GetFunction(mPropertyType);
75 case PropertyCondition::GreaterThan:
77 mConditionFunction = GreaterThan::GetFunction(mPropertyType);
80 case PropertyCondition::Inside:
82 mConditionFunction = Inside::GetFunction(mPropertyType);
85 case PropertyCondition::Outside:
87 mConditionFunction = Outside::GetFunction(mPropertyType);
90 case PropertyCondition::Step:
92 mConditionFunction = Step::GetFunction(mPropertyType);
95 case PropertyCondition::VariableStep:
97 mConditionFunction = VariableStep::GetFunction(mPropertyType);
100 case PropertyCondition::False:
102 mConditionFunction = PropertyNotification::EvalFalse;
107 mProperty = mProxy->GetSceneObjectInputProperty( mPropertyIndex );
108 int internalComponentIndex = mProxy->GetPropertyComponentIndex(mPropertyIndex);
109 if( internalComponentIndex != Property::INVALID_COMPONENT_INDEX )
111 // override the one passed in
112 mComponentIndex = internalComponentIndex;
116 PropertyNotification::~PropertyNotification()
120 bool PropertyNotification::EvalFalse( const Dali::PropertyInput& value, RawArgumentContainer& arg )
125 void PropertyNotification::SetNotifyMode( NotifyMode notifyMode )
129 case Dali::PropertyNotification::Disabled:
131 mNotifyValidity[0] = false;
132 mNotifyValidity[1] = false;
135 case Dali::PropertyNotification::NotifyOnTrue:
137 mNotifyValidity[0] = false;
138 mNotifyValidity[1] = true;
141 case Dali::PropertyNotification::NotifyOnFalse:
143 mNotifyValidity[0] = true;
144 mNotifyValidity[1] = false;
147 case Dali::PropertyNotification::NotifyOnChanged:
149 mNotifyValidity[0] = true;
150 mNotifyValidity[1] = true;
156 bool PropertyNotification::Check( BufferIndex bufferIndex )
158 bool notifyRequired = false;
159 bool currentValid = false;
161 if ( Property::INVALID_COMPONENT_INDEX != mComponentIndex )
163 // Evaluate Condition
164 const PropertyInputComponentAccessor component( mProperty, mComponentIndex );
165 const PropertyInputIndexer< PropertyInputComponentAccessor > input( bufferIndex, &component );
166 currentValid = mConditionFunction(input, mArguments);
170 // Evaluate Condition
171 const PropertyInputIndexer< PropertyInputImpl > input( bufferIndex, mProperty );
172 currentValid = mConditionFunction(input, mArguments);
175 if( mValid != currentValid
176 || (currentValid && ((mConditionType == PropertyCondition::Step)
177 || (mConditionType == PropertyCondition::VariableStep))) )
179 mValid = currentValid;
180 notifyRequired = mNotifyValidity[currentValid];
183 return notifyRequired;
186 bool PropertyNotification::GetValidity() const
191 } // namespace SceneGraph
193 } // namespace Internal