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),
65 mNotifyMode( Dali::PropertyNotification::Disabled )
67 SetNotifyMode(notifyMode);
69 switch(mConditionType)
71 case PropertyCondition::LessThan:
73 mConditionFunction = LessThan::GetFunction(mPropertyType);
76 case PropertyCondition::GreaterThan:
78 mConditionFunction = GreaterThan::GetFunction(mPropertyType);
81 case PropertyCondition::Inside:
83 mConditionFunction = Inside::GetFunction(mPropertyType);
86 case PropertyCondition::Outside:
88 mConditionFunction = Outside::GetFunction(mPropertyType);
91 case PropertyCondition::Step:
93 mConditionFunction = Step::GetFunction(mPropertyType);
96 case PropertyCondition::VariableStep:
98 mConditionFunction = VariableStep::GetFunction(mPropertyType);
101 case PropertyCondition::False:
103 mConditionFunction = PropertyNotification::EvalFalse;
108 mProperty = mProxy->GetSceneObjectInputProperty( mPropertyIndex );
109 int internalComponentIndex = mProxy->GetPropertyComponentIndex(mPropertyIndex);
110 if( internalComponentIndex != Property::INVALID_COMPONENT_INDEX )
112 // override the one passed in
113 mComponentIndex = internalComponentIndex;
117 PropertyNotification::~PropertyNotification()
121 bool PropertyNotification::EvalFalse( const Dali::PropertyInput& value, RawArgumentContainer& arg )
126 void PropertyNotification::SetNotifyMode( NotifyMode notifyMode )
128 mNotifyMode = notifyMode;
131 bool PropertyNotification::Check( BufferIndex bufferIndex )
133 bool notifyRequired = false;
134 bool currentValid = false;
136 if ( Property::INVALID_COMPONENT_INDEX != mComponentIndex )
138 // Evaluate Condition
139 const PropertyInputComponentAccessor component( mProperty, mComponentIndex );
140 const PropertyInputIndexer< PropertyInputComponentAccessor > input( bufferIndex, &component );
141 currentValid = mConditionFunction(input, mArguments);
145 // Evaluate Condition
146 const PropertyInputIndexer< PropertyInputImpl > input( bufferIndex, mProperty );
147 currentValid = mConditionFunction(input, mArguments);
150 if( mValid != currentValid
151 || (currentValid && ((mConditionType == PropertyCondition::Step)
152 || (mConditionType == PropertyCondition::VariableStep))) )
154 mValid = currentValid;
155 // means don't notify so notifyRequired stays false
156 switch( mNotifyMode )
158 case Dali::PropertyNotification::Disabled:
160 // notify never, already initialized to false
163 case Dali::PropertyNotification::NotifyOnTrue:
165 notifyRequired = mValid; // notify if value is true
168 case Dali::PropertyNotification::NotifyOnFalse:
170 notifyRequired = !mValid; // notify when its false
173 case Dali::PropertyNotification::NotifyOnChanged:
175 notifyRequired = true; // notify whenever changed
181 return notifyRequired;
184 bool PropertyNotification::GetValidity() const
189 } // namespace SceneGraph
191 } // namespace Internal