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>
36 PropertyNotification* PropertyNotification::New(ProxyObject& proxy,
37 Property::Index propertyIndex,
38 Property::Type propertyType,
40 ConditionType condition,
41 RawArgumentContainer& arguments,
42 NotifyMode notifyMode)
44 return new PropertyNotification( proxy, propertyIndex, propertyType, componentIndex, condition, arguments, notifyMode );
48 PropertyNotification::PropertyNotification(ProxyObject& proxy,
49 Property::Index propertyIndex,
50 Property::Type propertyType,
52 ConditionType condition,
53 RawArgumentContainer& arguments,
54 NotifyMode notifyMode)
56 mPropertyIndex(propertyIndex),
57 mPropertyType(propertyType),
59 mComponentIndex(componentIndex),
60 mConditionType(condition),
61 mArguments(arguments),
63 mNotifyMode( Dali::PropertyNotification::Disabled )
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 )
126 mNotifyMode = notifyMode;
129 bool PropertyNotification::Check( BufferIndex bufferIndex )
131 bool notifyRequired = false;
132 bool currentValid = false;
134 if ( Property::INVALID_COMPONENT_INDEX != mComponentIndex )
136 // Evaluate Condition
137 const PropertyInputComponentAccessor component( mProperty, mComponentIndex );
138 const PropertyInputIndexer< PropertyInputComponentAccessor > input( bufferIndex, &component );
139 currentValid = mConditionFunction(input, mArguments);
143 // Evaluate Condition
144 const PropertyInputIndexer< PropertyInputImpl > input( bufferIndex, mProperty );
145 currentValid = mConditionFunction(input, mArguments);
148 if( mValid != currentValid
149 || (currentValid && ((mConditionType == PropertyCondition::Step)
150 || (mConditionType == PropertyCondition::VariableStep))) )
152 mValid = currentValid;
153 // means don't notify so notifyRequired stays false
154 switch( mNotifyMode )
156 case Dali::PropertyNotification::Disabled:
158 // notify never, already initialized to false
161 case Dali::PropertyNotification::NotifyOnTrue:
163 notifyRequired = mValid; // notify if value is true
166 case Dali::PropertyNotification::NotifyOnFalse:
168 notifyRequired = !mValid; // notify when its false
171 case Dali::PropertyNotification::NotifyOnChanged:
173 notifyRequired = true; // notify whenever changed
179 return notifyRequired;
182 bool PropertyNotification::GetValidity() const
187 } // namespace SceneGraph
189 } // namespace Internal