2 * Copyright (c) 2016 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/object-impl.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(Object& object,
37 Property::Index propertyIndex,
38 Property::Type propertyType,
40 ConditionType condition,
41 RawArgumentContainer& arguments,
42 NotifyMode notifyMode)
44 return new PropertyNotification( object, propertyIndex, propertyType, componentIndex, condition, arguments, notifyMode );
48 PropertyNotification::PropertyNotification(Object& object,
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 ),
64 mConditionFunction(NULL)
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 = mObject->GetSceneObjectInputProperty( mPropertyIndex );
108 int internalComponentIndex = mObject->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 )
127 mNotifyMode = notifyMode;
130 bool PropertyNotification::Check( BufferIndex bufferIndex )
132 bool notifyRequired = false;
133 bool currentValid = false;
135 if ( Property::INVALID_COMPONENT_INDEX != mComponentIndex )
137 // Evaluate Condition
138 const PropertyInputAccessor component( mProperty, mComponentIndex );
139 const PropertyInputIndexer< PropertyInputAccessor > input( bufferIndex, &component );
140 currentValid = mConditionFunction(input, mArguments);
144 // Evaluate Condition
145 const PropertyInputIndexer< PropertyInputImpl > input( bufferIndex, mProperty );
146 currentValid = mConditionFunction(input, mArguments);
149 if( mValid != currentValid
150 || (currentValid && ((mConditionType == PropertyCondition::Step)
151 || (mConditionType == PropertyCondition::VariableStep))) )
153 mValid = currentValid;
154 // means don't notify so notifyRequired stays false
155 switch( mNotifyMode )
157 case Dali::PropertyNotification::Disabled:
159 // notify never, already initialized to false
162 case Dali::PropertyNotification::NotifyOnTrue:
164 notifyRequired = mValid; // notify if value is true
167 case Dali::PropertyNotification::NotifyOnFalse:
169 notifyRequired = !mValid; // notify when its false
172 case Dali::PropertyNotification::NotifyOnChanged:
174 notifyRequired = true; // notify whenever changed
180 return notifyRequired;
183 bool PropertyNotification::GetValidity() const
188 } // namespace SceneGraph
190 } // namespace Internal