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 const 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 const 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::False:
91 mConditionFunction = PropertyNotification::EvalFalse;
96 DALI_ASSERT_ALWAYS(false && "Unrecognized ConditionType");
101 mProperty = mProxy->GetSceneObjectInputProperty( mPropertyIndex );
102 int internalComponentIndex = mProxy->GetPropertyComponentIndex(mPropertyIndex);
103 if( internalComponentIndex != Property::INVALID_COMPONENT_INDEX )
105 // override the one passed in
106 mComponentIndex = internalComponentIndex;
110 PropertyNotification::~PropertyNotification()
114 bool PropertyNotification::EvalFalse( const Dali::PropertyInput& value, const RawArgumentContainer& arg )
119 void PropertyNotification::SetNotifyMode( NotifyMode notifyMode )
123 case Dali::PropertyNotification::Disabled:
125 mNotifyValidity[0] = false;
126 mNotifyValidity[1] = false;
129 case Dali::PropertyNotification::NotifyOnTrue:
131 mNotifyValidity[0] = false;
132 mNotifyValidity[1] = true;
135 case Dali::PropertyNotification::NotifyOnFalse:
137 mNotifyValidity[0] = true;
138 mNotifyValidity[1] = false;
141 case Dali::PropertyNotification::NotifyOnChanged:
143 mNotifyValidity[0] = true;
144 mNotifyValidity[1] = true;
150 bool PropertyNotification::Check( BufferIndex bufferIndex )
152 bool validityChanged = false;
153 bool currentValid = false;
155 if ( Property::INVALID_COMPONENT_INDEX != mComponentIndex )
157 // Evaluate Condition
158 const PropertyInputComponentAccessor component( mProperty, mComponentIndex );
159 const PropertyInputIndexer< PropertyInputComponentAccessor > input( bufferIndex, &component );
160 currentValid = mConditionFunction(input, mArguments);
164 // Evaluate Condition
165 const PropertyInputIndexer< PropertyInputImpl > input( bufferIndex, mProperty );
166 currentValid = mConditionFunction(input, mArguments);
169 if( mValid != currentValid )
171 mValid = currentValid;
172 validityChanged = mNotifyValidity[currentValid];
175 return validityChanged;
178 bool PropertyNotification::GetValidity() const
183 } // namespace SceneGraph
185 } // namespace Internal