1 #ifndef __DALI_PROPERTY_INPUT_ACCESSOR_H__
2 #define __DALI_PROPERTY_INPUT_ACCESSOR_H__
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/public-api/object/property-types.h>
23 #include <dali/internal/event/common/property-input-impl.h>
31 class PropertyInputAccessor
36 * Create the PropertyInputAccessor.
38 PropertyInputAccessor()
45 * Create the PropertyInputAccessor.
47 PropertyInputAccessor( const PropertyInputImpl* input, int componentIndex )
49 mComponentIndex( componentIndex )
54 * Copy from a PropertyInputAccessor
56 PropertyInputAccessor( const PropertyInputAccessor& accessor )
57 : mInput( accessor.mInput ),
58 mComponentIndex( accessor.mComponentIndex )
63 * Copy from a PropertyInputAccessor
65 PropertyInputAccessor& operator=(const PropertyInputAccessor& accessor)
67 mInput = accessor.mInput;
68 mComponentIndex = accessor.mComponentIndex;
73 * Set the property input.
75 void SetInput( const PropertyInputImpl& input, int componentIndex )
78 mComponentIndex = componentIndex;
82 * Retrieve the property input.
84 const PropertyInputImpl* GetInput() const
90 * @copydoc Dali::Internal::PropertyInputImpl::GetType()
92 Property::Type GetType() const
94 return mInput->GetType();
98 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputBoolean()
100 const bool& GetConstraintInputBoolean( BufferIndex updateBufferIndex ) const
102 return mInput->GetConstraintInputBoolean( updateBufferIndex );
106 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputFloat()
108 const float& GetConstraintInputFloat( BufferIndex updateBufferIndex ) const
110 // Invalid index is ok
111 if ( mComponentIndex < 0 )
113 // Not a Vector3 or Vector4 component, expecting float type
114 return mInput->GetConstraintInputFloat( updateBufferIndex );
116 else if ( PropertyTypes::Get< Vector3 >() == mInput->GetType() )
118 if ( 0 == mComponentIndex )
120 return mInput->GetConstraintInputVector3( updateBufferIndex ).x;
122 else if ( 1 == mComponentIndex )
124 return mInput->GetConstraintInputVector3( updateBufferIndex ).y;
127 DALI_ASSERT_DEBUG( 2 == mComponentIndex && "Invalid Vector3 component index" );
128 return mInput->GetConstraintInputVector3( updateBufferIndex ).z;
132 if ( 0 == mComponentIndex )
134 return mInput->GetConstraintInputVector4( updateBufferIndex ).x;
136 else if ( 1 == mComponentIndex )
138 return mInput->GetConstraintInputVector4( updateBufferIndex ).y;
140 else if ( 2 == mComponentIndex )
142 return mInput->GetConstraintInputVector4( updateBufferIndex ).y;
145 DALI_ASSERT_DEBUG( 3 == mComponentIndex && "Invalid Vector4 component index" );
146 return mInput->GetConstraintInputVector4( updateBufferIndex ).w;
150 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputInteger() const
152 const int& GetConstraintInputInteger( BufferIndex updateBufferIndex ) const
154 return mInput->GetConstraintInputInteger( updateBufferIndex );
158 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputVector2()
160 const Vector2& GetConstraintInputVector2( BufferIndex updateBufferIndex ) const
162 return mInput->GetConstraintInputVector2( updateBufferIndex );
166 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputVector3()
168 const Vector3& GetConstraintInputVector3( BufferIndex updateBufferIndex ) const
170 return mInput->GetConstraintInputVector3( updateBufferIndex );
174 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputVector4()
176 const Vector4& GetConstraintInputVector4( BufferIndex updateBufferIndex ) const
178 return mInput->GetConstraintInputVector4( updateBufferIndex );
182 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputQuaternion()
184 const Quaternion& GetConstraintInputQuaternion( BufferIndex updateBufferIndex ) const
186 return mInput->GetConstraintInputQuaternion( updateBufferIndex );
190 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputMatrix3()
192 const Matrix3& GetConstraintInputMatrix3( BufferIndex updateBufferIndex ) const
194 return mInput->GetConstraintInputMatrix3( updateBufferIndex );
198 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputMatrix()
200 const Matrix& GetConstraintInputMatrix( BufferIndex updateBufferIndex ) const
202 return mInput->GetConstraintInputMatrix( updateBufferIndex );
207 const PropertyInputImpl* mInput;
211 } // namespace Internal
215 #endif // __DALI_PROPERTY_INPUT_ACCESSOR_H__