1 #ifndef DALI_PROPERTY_INPUT_ACCESSOR_H
2 #define DALI_PROPERTY_INPUT_ACCESSOR_H
5 * Copyright (c) 2021 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/internal/event/common/property-input-impl.h>
23 #include <dali/public-api/object/property-types.h>
29 class PropertyInputAccessor
33 * Create the PropertyInputAccessor.
35 PropertyInputAccessor()
42 * Create the PropertyInputAccessor.
44 PropertyInputAccessor(const PropertyInputImpl* input, int32_t componentIndex)
46 mComponentIndex(componentIndex)
51 * Copy from a PropertyInputAccessor
53 PropertyInputAccessor(const PropertyInputAccessor& accessor) = default;
56 * Copy from a PropertyInputAccessor
58 PropertyInputAccessor& operator=(const PropertyInputAccessor& accessor)
62 mInput = accessor.mInput;
63 mComponentIndex = accessor.mComponentIndex;
69 * Set the property input.
71 void SetInput(const PropertyInputImpl& input, int32_t componentIndex)
74 mComponentIndex = componentIndex;
78 * Retrieve the property input.
80 const PropertyInputImpl* GetInput() const
86 * @copydoc Dali::Internal::PropertyInputImpl::GetType()
88 Property::Type GetType() const
90 return mInput->GetType();
94 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputBoolean()
96 const bool& GetConstraintInputBoolean(BufferIndex updateBufferIndex) const
98 return mInput->GetConstraintInputBoolean(updateBufferIndex);
102 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputInteger() const
104 const int& GetConstraintInputInteger(BufferIndex updateBufferIndex) const
106 DALI_ASSERT_DEBUG(mComponentIndex < 0 && "Did not expect valid component index");
108 return mInput->GetConstraintInputInteger(updateBufferIndex);
112 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputFloat()
114 const float& GetConstraintInputFloat(BufferIndex updateBufferIndex) const
116 // Invalid index is ok
117 if(mComponentIndex < 0)
119 // Not a Vector2, Vector3 or Vector4 component, expecting float type
120 return mInput->GetConstraintInputFloat(updateBufferIndex);
122 else if(PropertyTypes::Get<Vector2>() == mInput->GetType())
124 if(0 == mComponentIndex)
126 return mInput->GetConstraintInputVector2(updateBufferIndex).x;
129 DALI_ASSERT_DEBUG(1 == mComponentIndex && "Invalid Vector2 component index");
130 return mInput->GetConstraintInputVector2(updateBufferIndex).y;
132 else if(PropertyTypes::Get<Vector3>() == mInput->GetType())
134 if(0 == mComponentIndex)
136 return mInput->GetConstraintInputVector3(updateBufferIndex).x;
138 else if(1 == mComponentIndex)
140 return mInput->GetConstraintInputVector3(updateBufferIndex).y;
143 DALI_ASSERT_DEBUG(2 == mComponentIndex && "Invalid Vector3 component index");
144 return mInput->GetConstraintInputVector3(updateBufferIndex).z;
148 if(0 == mComponentIndex)
150 return mInput->GetConstraintInputVector4(updateBufferIndex).x;
152 else if(1 == mComponentIndex)
154 return mInput->GetConstraintInputVector4(updateBufferIndex).y;
156 else if(2 == mComponentIndex)
158 return mInput->GetConstraintInputVector4(updateBufferIndex).z;
161 DALI_ASSERT_DEBUG(3 == mComponentIndex && "Invalid Vector4 component index");
162 return mInput->GetConstraintInputVector4(updateBufferIndex).w;
166 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputVector2()
168 const Vector2& GetConstraintInputVector2(BufferIndex updateBufferIndex) const
170 return mInput->GetConstraintInputVector2(updateBufferIndex);
174 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputVector3()
176 const Vector3& GetConstraintInputVector3(BufferIndex updateBufferIndex) const
178 return mInput->GetConstraintInputVector3(updateBufferIndex);
182 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputVector4()
184 const Vector4& GetConstraintInputVector4(BufferIndex updateBufferIndex) const
186 return mInput->GetConstraintInputVector4(updateBufferIndex);
190 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputQuaternion()
192 const Quaternion& GetConstraintInputQuaternion(BufferIndex updateBufferIndex) const
194 return mInput->GetConstraintInputQuaternion(updateBufferIndex);
198 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputMatrix3()
200 const Matrix3& GetConstraintInputMatrix3(BufferIndex updateBufferIndex) const
202 return mInput->GetConstraintInputMatrix3(updateBufferIndex);
206 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputMatrix()
208 const Matrix& GetConstraintInputMatrix(BufferIndex updateBufferIndex) const
210 return mInput->GetConstraintInputMatrix(updateBufferIndex);
214 const PropertyInputImpl* mInput;
215 int32_t mComponentIndex;
218 } // namespace Internal
222 #endif // DALI_PROPERTY_INPUT_ACCESSOR_H