/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
END_TEST;
}
+int UtcDaliPropertyValueGetVector2fromVector3P(void)
+{
+ Property::Value value( Vector3(1.f,2.f,3.f) );
+ Vector2 result;
+ DALI_TEST_EQUALS( Vector2(1.0f,2.0f), value.Get< Vector2 >(), TEST_LOCATION );
+ DALI_TEST_EQUALS( true, value.Get( result ), TEST_LOCATION );
+ DALI_TEST_EQUALS( Vector2(1.0f,2.0f), result, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliPropertyValueGetVector2fromVector4P(void)
+{
+ Property::Value value( Vector4(1.f,2.f,3.f,4.f) );
+ Vector2 result;
+ DALI_TEST_EQUALS( Vector2(1.0f,2.0f), value.Get< Vector2 >(), TEST_LOCATION );
+ DALI_TEST_EQUALS( true, value.Get( result ), TEST_LOCATION );
+ DALI_TEST_EQUALS( Vector2(1.0f,2.0f), result, TEST_LOCATION );
+ END_TEST;
+}
+
int UtcDaliPropertyValueGetVector2N(void)
{
Property::Value value;
END_TEST;
}
+int UtcDaliPropertyValueGetVector3FromVector2P(void)
+{
+ Property::Value value( Vector2(1.0f,2.0f) );
+ Vector3 result(99.f,88.f,77.f);
+ DALI_TEST_EQUALS( Vector3(1.0f,2.0f,0.f), value.Get< Vector3 >(), TEST_LOCATION );
+ DALI_TEST_EQUALS( true, value.Get( result ), TEST_LOCATION );
+ DALI_TEST_EQUALS( Vector3(1.0f,2.0f,0.f), result, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliPropertyValueGetVector3FromVector4P(void)
+{
+ Property::Value value( Vector4(4.f,3.f,2.f,1.f) );
+ Vector3 result;
+ DALI_TEST_EQUALS( Vector3(4.f,3.f,2.f), value.Get< Vector3 >(), TEST_LOCATION );
+ DALI_TEST_EQUALS( true, value.Get( result ), TEST_LOCATION );
+ DALI_TEST_EQUALS( Vector3(4.f,3.f,2.f), result, TEST_LOCATION );
+ END_TEST;
+}
+
int UtcDaliPropertyValueGetVector3N(void)
{
Property::Value value;
END_TEST;
}
+int UtcDaliPropertyValueGetVector4FromVector2P(void)
+{
+ Property::Value value( Vector2(-1.f,-3.f) );
+ Vector4 result(99.f,88.f,77.f,66.f);
+ DALI_TEST_EQUALS( Vector4(-1.f,-3.f,0.f,0.f), value.Get< Vector4 >(), TEST_LOCATION );
+ DALI_TEST_EQUALS( true, value.Get( result ), TEST_LOCATION );
+ DALI_TEST_EQUALS( Vector4(-1.f,-3.f,0.f,0.f), result, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliPropertyValueGetVector4FromVector3P(void)
+{
+ Property::Value value( Vector3(1.f,2.f,-1.f) );
+ Vector4 result(99.f,88.f,77.f,66.f);
+ DALI_TEST_EQUALS( Vector4(1.f,2.f,-1.f,0.f), value.Get< Vector4 >(), TEST_LOCATION );
+ DALI_TEST_EQUALS( true, value.Get( result ), TEST_LOCATION );
+ DALI_TEST_EQUALS( Vector4(1.f,2.f,-1.f,0.f), result, TEST_LOCATION );
+ END_TEST;
+}
+
int UtcDaliPropertyValueGetVector4N(void)
{
Property::Value value;
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
DALI_TEST_EQUALS(v0.y, 2.0f, 0.001f, TEST_LOCATION);
DALI_TEST_EQUALS(v0.z, 0.0f, 0.001f, TEST_LOCATION);
DALI_TEST_EQUALS(v0.z, 0.0f, 0.001f, TEST_LOCATION);
+ v0.w = v0.z = 99.f;
+ v0 = vec2;
+ DALI_TEST_EQUALS(v0.x, 1.0f, 0.001f, TEST_LOCATION);
+ DALI_TEST_EQUALS(v0.y, 2.0f, 0.001f, TEST_LOCATION);
+ DALI_TEST_EQUALS(v0.z, 0.0f, 0.001f, TEST_LOCATION);
+ DALI_TEST_EQUALS(v0.z, 0.0f, 0.001f, TEST_LOCATION);
+
END_TEST;
}
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Vector4& Vector4::operator=(const Vector2& vec2 )
{
- // only set x and y
x = vec2.x;
y = vec2.y;
+ z = 0.0f;
+ w = 0.0f;
return *this;
}
Vector4& Vector4::operator=(const Vector3& vec3 )
{
- // only set x, y and z
x = vec3.x;
y = vec3.y;
z = vec3.z;
+ w = 0.0f;
return *this;
}
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
bool Property::Value::Get( Vector2& vectorValue ) const
{
bool converted = false;
- if( mImpl && (mImpl->type == VECTOR2) ) // type cannot change in mImpl so vector is allocated
+ if( mImpl )
{
- vectorValue = *(mImpl->vector2Value);
- converted = true;
+ // type cannot change in mImpl so vector is allocated
+ if( mImpl->type == VECTOR2 || mImpl->type == VECTOR3 || mImpl->type == VECTOR4 )
+ {
+ vectorValue = *(mImpl->vector2Value); // if Vector3 or 4 only x and y are assigned
+ converted = true;
+ }
}
return converted;
}
bool Property::Value::Get( Vector3& vectorValue ) const
{
bool converted = false;
- if( mImpl && (mImpl->type == VECTOR3) ) // type cannot change in mImpl so vector is allocated
+ if( mImpl )
{
- vectorValue = *(mImpl->vector3Value);
- converted = true;
+ // type cannot change in mImpl so vector is allocated
+ if ( mImpl->type == VECTOR3 || mImpl->type == VECTOR4 )
+ {
+ vectorValue = *(mImpl->vector3Value); // if Vector4 only x,y,z are assigned
+ converted = true;
+ }
+ else if( mImpl->type == VECTOR2 )
+ {
+ vectorValue = *(mImpl->vector2Value);
+ converted = true;
+ }
}
return converted;
}
bool Property::Value::Get( Vector4& vectorValue ) const
{
bool converted = false;
- if( mImpl && (mImpl->type == VECTOR4) ) // type cannot change in mImpl so vector is allocated
+ if( mImpl )
{
- vectorValue = *(mImpl->vector4Value);
- converted = true;
+ if( mImpl->type == VECTOR4 ) // type cannot change in mImpl so vector is allocated
+ {
+ vectorValue = *(mImpl->vector4Value);
+ converted = true;
+ }
+ else if( mImpl->type == VECTOR2 )
+ {
+ vectorValue = *(mImpl->vector2Value);
+ converted = true;
+ }
+ else if( mImpl->type == VECTOR3 )
+ {
+ vectorValue = *(mImpl->vector3Value);
+ converted = true;
+ }
}
return converted;
}
#define __DALI_PROPERTY_VALUE_H__
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* @SINCE_1_0.0
* @param [out] boolValue On return, a boolean value.
* @return true if the value is successfully retrieved, false if the type is not convertible
- * @pre GetType() returns Property::BOOLEAN.
+ * @pre GetType() is a type convertible to bool.
*/
bool Get( bool& boolValue ) const;
* @SINCE_1_0.0
* @param [out] floatValue On return, a floating-point value.
* @return true if the value is successfully retrieved, false if the type is not convertible
- * @pre GetType() returns Property::FLOAT.
+ * @pre GetType() is a type convertible to float.
*/
bool Get( float& floatValue ) const;
* @SINCE_1_0.0
* @param [out] integerValue On return, an integer value.
* @return true if the value is successfully retrieved, false if the type is not convertible
- * @pre GetType() returns Property::INTEGER.
+ * @pre GetType() is a type convertible to int.
*/
bool Get( int& integerValue ) const;
* @SINCE_1_0.0
* @param [out] rect On return, an integer rectangle.
* @return true if the value is successfully retrieved, false if the type is not convertible
- * @pre GetType() returns Property::RECTANGLE.
+ * @pre GetType() is a type convertible to Rect<int>.
*/
bool Get( Rect<int>& rect ) const;
* @SINCE_1_0.0
* @param [out] vectorValue On return, a vector value.
* @return true if the value is successfully retrieved, false if the type is not convertible
- * @pre GetType() returns Property::VECTOR2.
+ * @pre GetType() is a type convertible to Vector2.
*/
bool Get( Vector2& vectorValue ) const;
* @SINCE_1_0.0
* @param [out] vectorValue On return, a vector value.
* @return true if the value is successfully retrieved, false if the type is not convertible
- * @pre GetType() returns Property::VECTOR3.
+ * @pre GetType() is a type convertible to Vector3.
*/
bool Get( Vector3& vectorValue ) const;
* @SINCE_1_0.0
* @param [out] vectorValue On return, a vector value.
* @return true if the value is successfully retrieved, false if the type is not convertible
- * @pre GetType() returns Property::VECTOR4.
+ * @pre GetType() is a type convertible to Vector4.
*/
bool Get( Vector4& vectorValue ) const;
* @SINCE_1_0.0
* @param [out] matrixValue On return, a matrix3 value.
* @return true if the value is successfully retrieved, false if the type is not convertible
- * @pre GetType() returns Property::MATRIX3.
+ * @pre GetType() is a type convertible to Matrix3.
*/
bool Get( Matrix3& matrixValue ) const;
* @SINCE_1_0.0
* @param [out] matrixValue On return, a matrix value.
* @return true if the value is successfully retrieved, false if the type is not convertible
- * @pre GetType() returns Property::MATRIX.
+ * @pre GetType() is a type convertible to Matrix.
*/
bool Get( Matrix& matrixValue ) const;
* @SINCE_1_0.0
* @param [out] angleAxisValue On return, a angle-axis value.
* @return true if the value is successfully retrieved, false if the type is not convertible
- * @pre GetType() returns Property::ROTATION.
+ * @pre GetType() is a type convertible to AngleAxis.
*/
bool Get( AngleAxis& angleAxisValue ) const;
* @SINCE_1_0.0
* @param [out] quaternionValue On return, a quaternion value.
* @return true if the value is successfully retrieved, false if the type is not convertible
- * @pre GetType() returns Property::ROTATION.
+ * @pre GetType() is a type convertible to Quaternion.
*/
bool Get( Quaternion& quaternionValue ) const;
* @SINCE_1_0.0
* @param [out] stringValue A string.
* @return true if the value is successfully retrieved, false if the type is not convertible
- * @pre GetType() returns Property::STRING.
+ * @pre GetType() is a type convertible to string.
*/
bool Get( std::string& stringValue ) const;