.Add( Toolkit::DevelVisual::Transform::Property::SIZE, Vector2(1.0f, 1.0f) )
.Add( Toolkit::DevelVisual::Transform::Property::ORIGIN, Toolkit::Align::CENTER )
.Add( Toolkit::DevelVisual::Transform::Property::ANCHOR_POINT, Toolkit::Align::CENTER )
- .Add( Toolkit::DevelVisual::Transform::Property::OFFSET_SIZE_MODE, Vector4::ZERO );
+ .Add( Toolkit::DevelVisual::Transform::Property::OFFSET_POLICY, Vector2( Toolkit::DevelVisual::Transform::Policy::RELATIVE, Toolkit::DevelVisual::Transform::Policy::RELATIVE ) )
+ .Add( Toolkit::DevelVisual::Transform::Property::SIZE_POLICY, Vector2( Toolkit::DevelVisual::Transform::Policy::RELATIVE, Toolkit::DevelVisual::Transform::Policy::RELATIVE ) );
return transformMap;
}
DALI_TEST_CHECK( typeValue->Get<Vector2>() == Vector2(1.0f,1.0f) );
}
{
- Property::Value* typeValue = map->Find( Toolkit::DevelVisual::Transform::Property::OFFSET_SIZE_MODE );
+ Property::Value* typeValue = map->Find( Toolkit::DevelVisual::Transform::Property::OFFSET_POLICY );
DALI_TEST_CHECK( typeValue );
- DALI_TEST_CHECK( typeValue->Get<Vector4>() == Vector4(0.0f,0.0f,0.0f,0.0f) );
+ DALI_TEST_CHECK( typeValue->Get< Vector2 >() == Vector2( Toolkit::DevelVisual::Transform::Policy::RELATIVE, Toolkit::DevelVisual::Transform::Policy::RELATIVE ) );
+ }
+ {
+ Property::Value* typeValue = map->Find( Toolkit::DevelVisual::Transform::Property::SIZE_POLICY );
+ DALI_TEST_CHECK( typeValue );
+ DALI_TEST_CHECK( typeValue->Get< Vector2 >() == Vector2( Toolkit::DevelVisual::Transform::Policy::RELATIVE, Toolkit::DevelVisual::Transform::Policy::RELATIVE ) );
}
{
Property::Value* typeValue = map->Find( Toolkit::DevelVisual::Transform::Property::ORIGIN );
Property::Map transform;
transform.Insert( DevelVisual::Transform::Property::OFFSET, Vector2(10.0f, 10.0f) );
transform.Insert( DevelVisual::Transform::Property::SIZE, Vector2(0.2f, 0.2f) );
- transform.Insert( DevelVisual::Transform::Property::OFFSET_SIZE_MODE, Vector4(1.0f, 1.0f, 0.0f,0.0f) );
+ transform.Insert( DevelVisual::Transform::Property::OFFSET_POLICY, Vector2( Toolkit::DevelVisual::Transform::Policy::ABSOLUTE, Toolkit::DevelVisual::Transform::Policy::ABSOLUTE ) );
transform.Insert( DevelVisual::Transform::Property::ORIGIN, "TOP_BEGIN" );
transform.Insert( DevelVisual::Transform::Property::ANCHOR_POINT, Toolkit::Align::BOTTOM_END );
DALI_TEST_EQUALS( typeValue->Get<Vector2>(), Vector2(0.2f,0.2f), TEST_LOCATION );
}
{
- Property::Value* typeValue = map->Find( Toolkit::DevelVisual::Transform::Property::OFFSET_SIZE_MODE );
+ Property::Value* typeValue = map->Find( Toolkit::DevelVisual::Transform::Property::OFFSET_POLICY );
DALI_TEST_CHECK( typeValue );
- DALI_TEST_EQUALS( typeValue->Get<Vector4>(), Vector4(1.0f,1.0f,0.0f,0.0f), TEST_LOCATION );
+ DALI_TEST_EQUALS( typeValue->Get< Vector2 >(), Vector2( Toolkit::DevelVisual::Transform::Policy::ABSOLUTE, Toolkit::DevelVisual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
+ }
+ {
+ Property::Value* typeValue = map->Find( Toolkit::DevelVisual::Transform::Property::SIZE_POLICY );
+ DALI_TEST_CHECK( typeValue );
+ DALI_TEST_EQUALS( typeValue->Get< Vector2 >(), Vector2( Toolkit::DevelVisual::Transform::Policy::RELATIVE, Toolkit::DevelVisual::Transform::Policy::RELATIVE ), TEST_LOCATION );
}
{
Property::Value* typeValue = map->Find( Toolkit::DevelVisual::Transform::Property::ORIGIN );
transform = DefaultTransform();
transform.Insert( DevelVisual::Transform::Property::OFFSET, Vector2(20.0f, 20.0f) );
transform.Insert( DevelVisual::Transform::Property::SIZE, Vector2(100.0f, 100.0f) );
- transform.Insert( DevelVisual::Transform::Property::OFFSET_SIZE_MODE, Vector4(0.0f, 0.0f, 1.0f,1.0f) );
+ transform.Insert( DevelVisual::Transform::Property::SIZE_POLICY, Vector2( Toolkit::DevelVisual::Transform::Policy::ABSOLUTE, Toolkit::DevelVisual::Transform::Policy::ABSOLUTE ) );
visual.SetTransformAndSize( transform, Vector2(100, 100) );
application.SendNotification();
application.Render(0);
END_TEST;
}
+int UtcDaliVisualTestTransformPoliciesAsStrings(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliVisualTestTransformPoliciesAsStrings: Use a ColorVisual and test the offset and size policies as strings" );
+
+ VisualFactory factory = VisualFactory::Get();
+ Property::Map propertyMap;
+ propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR);
+ propertyMap.Insert(ColorVisual::Property::MIX_COLOR, Color::BLUE);
+ Visual::Base visual = factory.CreateVisual( propertyMap );
+
+ Property::Map transform;
+ transform[ "offsetPolicy" ] = Property::Array().Add( "ABSOLUTE" )
+ .Add( "RELATIVE" );
+ transform[ "sizePolicy" ] = Property::Array().Add( "RELATIVE" )
+ .Add( "ABSOLUTE" );
+ visual.SetTransformAndSize( transform, Vector2(100, 100) );
+
+ Dali::Property::Map visualMap;
+ visual.CreatePropertyMap( visualMap );
+ Property::Value* value = visualMap.Find( Dali::Toolkit::DevelVisual::Property::TRANSFORM );
+ Dali::Property::Map* map = value->GetMap();
+ DALI_TEST_CHECK( map );
+
+ {
+ Property::Value* typeValue = map->Find( Toolkit::DevelVisual::Transform::Property::OFFSET_POLICY );
+ DALI_TEST_CHECK( typeValue );
+ DALI_TEST_EQUALS( typeValue->Get< Vector2 >(), Vector2( Toolkit::DevelVisual::Transform::Policy::ABSOLUTE, Toolkit::DevelVisual::Transform::Policy::RELATIVE ), TEST_LOCATION );
+ }
+ {
+ Property::Value* typeValue = map->Find( Toolkit::DevelVisual::Transform::Property::SIZE_POLICY );
+ DALI_TEST_CHECK( typeValue );
+ DALI_TEST_EQUALS( typeValue->Get< Vector2 >(), Vector2( Toolkit::DevelVisual::Transform::Policy::RELATIVE, Toolkit::DevelVisual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
+ }
+
+ END_TEST;
+}
+
int UtcDaliNPatchVisualCustomShader(void)
{
ToolkitTestApplication application;
Property::Map transformMap;
transformMap["size"] = Vector2( 0.5f, 0.5f ) ;
transformMap["offset"] = Vector2( 20.0f, 0.0f ) ;
- transformMap["offsetSizeMode"] = Vector4( 1.0f, 1.0f, 0.0f, 0.0f );
+ transformMap["offsetPolicy"] = Vector2( DevelVisual::Transform::Policy::ABSOLUTE, DevelVisual::Transform::Policy::ABSOLUTE );
transformMap["anchorPoint"] = Align::CENTER;
transformMap["origin"] = Align::CENTER;
properties[DevelVisual::Property::TRANSFORM] = transformMap;
/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
.Add( Toolkit::DevelVisual::Transform::Property::SIZE, Vector2(1.0f, 1.0f) )
.Add( Toolkit::DevelVisual::Transform::Property::ORIGIN, Toolkit::Align::CENTER )
.Add( Toolkit::DevelVisual::Transform::Property::ANCHOR_POINT, Toolkit::Align::CENTER )
- .Add( Toolkit::DevelVisual::Transform::Property::OFFSET_SIZE_MODE, Vector4::ZERO );
+ .Add( Toolkit::DevelVisual::Transform::Property::OFFSET_POLICY, Vector2( Toolkit::DevelVisual::Transform::Policy::RELATIVE, Toolkit::DevelVisual::Transform::Policy::RELATIVE ) )
+ .Add( Toolkit::DevelVisual::Transform::Property::SIZE_POLICY, Vector2( Toolkit::DevelVisual::Transform::Policy::RELATIVE, Toolkit::DevelVisual::Transform::Policy::RELATIVE ) );
return transformMap;
}
#ifndef DALI_TOOLKIT_VISUAL_BASE_H
#define DALI_TOOLKIT_VISUAL_BASE_H
/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
* | transform | MAP |
*
* where \b customShader is a map with at least one of the following properties:
- * | %Property Name | Type | Required | Default | Description |
- * |-------------------------|------------------|----------|---------|-------------|
- * | vertexShader | STRING | No | "" | Vertex shader code|
- * | fragmentShader | STRING | No | "" | Fragment shader code|
- * | subdivideGridX | INTEGER | No | 1 | How to subdivide the grid along X |
- * | subdivideGridY | INTEGER | No | 1 | How to subdivide the grid along Y |
- * | shaderHints | INTEGER or ARRAY of STRING | No | NONE | Bitmask of hints @sa Dali::Shader::Hint |
+ * | %Property Name | Type | Required | Default | Description |
+ * |-------------------------|----------------------------|----------|---------|-----------------------------------------|
+ * | vertexShader | STRING | No | "" | Vertex shader code |
+ * | fragmentShader | STRING | No | "" | Fragment shader code |
+ * | subdivideGridX | INTEGER | No | 1 | How to subdivide the grid along X |
+ * | subdivideGridY | INTEGER | No | 1 | How to subdivide the grid along Y |
+ * | shaderHints | INTEGER or ARRAY of STRING | No | NONE | Bitmask of hints @sa Dali::Shader::Hint |
*
* and \b transform is a map with the following properties:
- * | %Property Name | Type | Required | Default |Description |
- * |-------------------------|------------------|----------|---------|------------|
- * | offset | VECTOR2 | No | (0,0) | Offset of visual from origin |
- * | size | VECTOR2 | No | (1,1) | size of visual |
- * | origin | INTEGER or STRING | No | CENTER | origin of the visual @sa Dali::Toolkit::Align |
- * | anchorPoint | INTEGER or STRING | No | CENTER | anchor point of the visual @sa Dali::Toolkit::Align |
- * | offsetSizeMode | VECTOR4 | No | (0,0,0,0) | See below |
- *
- *
- * offsetSizeMode describes whether the offset and the size are
- * relative or absolute by using 0 or 1 respectively in the corresponding
- * components (offsetSizeMode.xy for offset.xy; offsetSizeMode.zw for size.xy).
+ * | %Property Name | Type | Required | Default | Description |
+ * |-------------------------|-------------------|----------|------------------------|-----------------------------------------------------|
+ * | offset | VECTOR2 | No | (0,0) | Offset of visual from origin |
+ * | size | VECTOR2 | No | (1,1) | size of visual |
+ * | origin | INTEGER or STRING | No | CENTER | origin of the visual @sa Dali::Toolkit::Align |
+ * | anchorPoint | INTEGER or STRING | No | CENTER | anchor point of the visual @sa Dali::Toolkit::Align |
+ * | offsetPolicy | VECTOR2 | No | ( RELATIVE, RELATIVE ) | @sa Dali::Toolkit::DevelVisual::Transform::Policy |
+ * | sizePolicy | VECTOR2 | No | ( RELATIVE, RELATIVE ) | @sa Dali::Toolkit::DevelVisual::Transform::Policy |
*
* Relative means that the component describes a factor of the parent control size;
* size.x = 1 means full width; size.y = 0.5 means half height.
#define DALI_TOOLKIT_DEVEL_API_VISUALS_VISUAL_PROPERTIES_DEVEL_H
/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
OPACITY = SHADER + 4
};
-} //namespace Property
+} // namespace Property
namespace Transform
{
+/**
+ * @brief Policies used by the transform for the offset or size.
+ */
+namespace Policy
+{
+
+enum Type
+{
+ RELATIVE = 0, ///< Relative to the control (percentage [0.0f to 1.0f] of the control).
+ ABSOLUTE = 1 ///< Absolute value in world units.
+};
+
+} // namespace Policy
+
namespace Property
{
enum Type
{
/**
- * @brief Offset of the visual. It can be either relative (percentage of the parent)
- * or absolute (in world units).
+ * @brief Offset of the visual, which can be either relative (percentage [0.0f to 1.0f] of the parent) or absolute (in world units).
* @details Name "offset", type Property::VECTOR2
+ * @see OFFSET_POLICY
*/
OFFSET,
/**
- * @brief Size of the visual. It can be either relative (percentage of the parent)
- * or absolute (in world units).
+ * @brief Size of the visual, which can be either relative (percentage [0.0f to 1.0f] of the parent) or absolute (in world units).
* @details Name "size", type Property::VECTOR2
+ * @see SIZE_POLICY
*/
SIZE,
ANCHOR_POINT,
/**
- * @brief Indicates which components of the offset and size are relative
- * (percentage of the parent) or absolute (in world units).
- * 0 indicates the component is relative, and 1 absolute.
- * @details Name "offsetSizeMode", type Property::VECTOR4
+ * @brief Whether the x or y OFFSET values are relative (percentage [0.0f to 1.0f] of the control) or absolute (in world units).
+ * @details Name "offsetPolicy", type Vector2 or Property::ARRAY of Property::STRING.
+ * If Property::ARRAY then 2 strings expected for the x and y.
+ *
+ * C++:
+ * @code
+ * control.SetProperty( ..., // Some visual based property
+ * Property::Map().Add( ... ) // Properties to set up visual
+ * .Add( DevelVisual::Property::TRANSFORM,
+ * Property::Array().Add( DevelVisual::Transform::Property::OFFSET_POLICY, Vector2( Policy::ABSOLUTE, Policy::RELATIVE ) ) )
+ * .Add( DevelVisual::Transform::Property::OFFSET, Vector2( 10, 1.0f ) ) );
+ * @endcode
+ *
+ * JSON:
+ * @code
+ * {
+ * ...
+ * "transition":
+ * {
+ * "offsetPolicy" : [ "ABSOLUTE", "RELATIVE" ],
+ * "offset" : [ 10, 1.0 ]
+ * }
+ * ...
+ * }
+ *
+ * @endcode
+ * @see Policy::Type
+ * @note By default, both the x and the y offset is RELATIVE.
+ */
+ OFFSET_POLICY,
+
+ /**
+ * @brief Whether the width or height SIZE values are relative (percentage [0.0f to 1.0f] of the control) or absolute (in world units).
+ * @details Name "sizePolicy", type Vector2 or Property::ARRAY of Property::STRING.
+ * If Property::ARRAY then 2 strings expected for the width and height.
+ *
+ * @see Policy::Type
+ * @see OFFSET_POLICY for example
+ * @note By default, both the width and the height is RELATIVE to the control's size.
*/
- OFFSET_SIZE_MODE
+ SIZE_POLICY,
};
-} //namespace Property
+} // namespace Property
} // namespace Transform
/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
Property::Map visualTransform;
visualTransform.Add( Toolkit::DevelVisual::Transform::Property::SIZE, size )
- .Add( Toolkit::DevelVisual::Transform::Property::OFFSET_SIZE_MODE, Vector4( 0.0f, 0.0f, 1.0f, 1.0f) ); // Use relative size
+ .Add( Toolkit::DevelVisual::Transform::Property::SIZE_POLICY, Vector2( DevelVisual::Transform::Policy::ABSOLUTE, DevelVisual::Transform::Policy::ABSOLUTE ) );
currentBackGroundVisual.SetTransformAndSize( visualTransform, size );
}
visualTransform.Add( Toolkit::DevelVisual::Transform::Property::SIZE, visualSize )
.Add( Toolkit::DevelVisual::Transform::Property::OFFSET, visualPosition )
- .Add( Toolkit::DevelVisual::Transform::Property::OFFSET_SIZE_MODE, Vector4( 1.0f, 1.0f, 1.0f, 1.0f) ) // Use absolute size
+ .Add( Toolkit::DevelVisual::Transform::Property::OFFSET_POLICY, Vector2( DevelVisual::Transform::Policy::ABSOLUTE, DevelVisual::Transform::Policy::ABSOLUTE ) )
+ .Add( Toolkit::DevelVisual::Transform::Property::SIZE_POLICY, Vector2( DevelVisual::Transform::Policy::ABSOLUTE, DevelVisual::Transform::Policy::ABSOLUTE ) )
.Add( Toolkit::DevelVisual::Transform::Property::ORIGIN, Toolkit::Align::TOP_BEGIN )
.Add( Toolkit::DevelVisual::Transform::Property::ANCHOR_POINT, visualAnchorPoint );
Property::Map textVisualTransform;
textVisualTransform.Add( Toolkit::DevelVisual::Transform::Property::SIZE, preSize )
.Add( Toolkit::DevelVisual::Transform::Property::OFFSET, labelPosition )
- .Add( Toolkit::DevelVisual::Transform::Property::OFFSET_SIZE_MODE, Vector4( 1.0f, 1.0f, 1.0f,1.0f ) ) // Use absolute size
+ .Add( Toolkit::DevelVisual::Transform::Property::OFFSET_POLICY, Vector2( DevelVisual::Transform::Policy::ABSOLUTE, DevelVisual::Transform::Policy::ABSOLUTE ) )
+ .Add( Toolkit::DevelVisual::Transform::Property::SIZE_POLICY, Vector2( DevelVisual::Transform::Policy::ABSOLUTE, DevelVisual::Transform::Policy::ABSOLUTE ) )
.Add( Toolkit::DevelVisual::Transform::Property::ORIGIN, Toolkit::Align::TOP_BEGIN )
.Add( Toolkit::DevelVisual::Transform::Property::ANCHOR_POINT, visualAnchorPoint );
Property::Map visualTransform;
visualTransform.Add( Toolkit::DevelVisual::Transform::Property::SIZE, visualSize )
.Add( Toolkit::DevelVisual::Transform::Property::OFFSET, visualPosition )
- .Add( Toolkit::DevelVisual::Transform::Property::OFFSET_SIZE_MODE, Vector4( 1.0f, 1.0f, 1.0f, 1.0f ) ) // Use absolute size
+ .Add( Toolkit::DevelVisual::Transform::Property::OFFSET_POLICY, Vector2( DevelVisual::Transform::Policy::ABSOLUTE, DevelVisual::Transform::Policy::ABSOLUTE ) )
+ .Add( Toolkit::DevelVisual::Transform::Property::SIZE_POLICY, Vector2( DevelVisual::Transform::Policy::ABSOLUTE, DevelVisual::Transform::Policy::ABSOLUTE ) )
.Add( Toolkit::DevelVisual::Transform::Property::ORIGIN, Toolkit::Align::CENTER )
.Add( Toolkit::DevelVisual::Transform::Property::ANCHOR_POINT, Toolkit::Align::CENTER );
/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
Property::Map visualTransform;
visualTransform.Add( Toolkit::DevelVisual::Transform::Property::SIZE, trackSize )
- .Add( Toolkit::DevelVisual::Transform::Property::OFFSET_SIZE_MODE, Vector4( 1.0f, 1.0f, 1.0f, 1.0f ) ); // Use Absolute size
+ .Add( Toolkit::DevelVisual::Transform::Property::OFFSET_POLICY, Vector2( DevelVisual::Transform::Policy::ABSOLUTE, DevelVisual::Transform::Policy::ABSOLUTE ) )
+ .Add( Toolkit::DevelVisual::Transform::Property::SIZE_POLICY, Vector2( DevelVisual::Transform::Policy::ABSOLUTE, DevelVisual::Transform::Policy::ABSOLUTE ) );
+
trackVisual.SetTransformAndSize( visualTransform, trackSize );
}
Property::Map visualTransform;
visualTransform.Add( Toolkit::DevelVisual::Transform::Property::SIZE, Vector2( mDomain.from.x + mSecondaryProgressValue * ( mDomain.to.x - mDomain.from.x ), trackSize.height ) )
- .Add( Toolkit::DevelVisual::Transform::Property::OFFSET_SIZE_MODE, Vector4( 1.0f, 1.0f, 1.0f, 1.0f ) ) // Use Absolute size
+ .Add( Toolkit::DevelVisual::Transform::Property::OFFSET_POLICY, Vector2( DevelVisual::Transform::Policy::ABSOLUTE, DevelVisual::Transform::Policy::ABSOLUTE ) )
+ .Add( Toolkit::DevelVisual::Transform::Property::SIZE_POLICY, Vector2( DevelVisual::Transform::Policy::ABSOLUTE, DevelVisual::Transform::Policy::ABSOLUTE ) )
.Add( Toolkit::DevelVisual::Transform::Property::ORIGIN, Toolkit::Align::TOP_BEGIN )
.Add( Toolkit::DevelVisual::Transform::Property::ANCHOR_POINT, Toolkit::Align::TOP_BEGIN );
secondProgressVisual.SetTransformAndSize( visualTransform, trackSize );
Property::Map visualTransform;
visualTransform.Add( Toolkit::DevelVisual::Transform::Property::SIZE, Vector2( mDomain.from.x + mProgressValue * ( mDomain.to.x - mDomain.from.x ), trackSize.height ) )
- .Add( Toolkit::DevelVisual::Transform::Property::OFFSET_SIZE_MODE, Vector4( 1.0f, 1.0f, 1.0f, 1.0f ) ) // Use Absolute size
+ .Add( Toolkit::DevelVisual::Transform::Property::OFFSET_POLICY, Vector2( DevelVisual::Transform::Policy::ABSOLUTE, DevelVisual::Transform::Policy::ABSOLUTE ) )
+ .Add( Toolkit::DevelVisual::Transform::Property::SIZE_POLICY, Vector2( DevelVisual::Transform::Policy::ABSOLUTE, DevelVisual::Transform::Policy::ABSOLUTE ) )
.Add( Toolkit::DevelVisual::Transform::Property::ORIGIN, Toolkit::Align::TOP_BEGIN )
.Add( Toolkit::DevelVisual::Transform::Property::ANCHOR_POINT, Toolkit::Align::TOP_BEGIN );
progressVisual.SetTransformAndSize( visualTransform, trackSize );
Property::Map visualTransform;
visualTransform.Add( Toolkit::DevelVisual::Transform::Property::SIZE, trackSize )
- .Add( Toolkit::DevelVisual::Transform::Property::OFFSET_SIZE_MODE, Vector4( 1.0f, 1.0f, 1.0f, 1.0f ) ); // Use Absolute size
-
+ .Add( Toolkit::DevelVisual::Transform::Property::OFFSET_POLICY, Vector2( DevelVisual::Transform::Policy::ABSOLUTE, DevelVisual::Transform::Policy::ABSOLUTE ) )
+ .Add( Toolkit::DevelVisual::Transform::Property::SIZE_POLICY, Vector2( DevelVisual::Transform::Policy::ABSOLUTE, DevelVisual::Transform::Policy::ABSOLUTE ) );
labelVisual.SetTransformAndSize( visualTransform, trackSize );
}
Property::Map visualTransform;
visualTransform.Add( Toolkit::DevelVisual::Transform::Property::SIZE, trackSize )
- .Add( Toolkit::DevelVisual::Transform::Property::OFFSET_SIZE_MODE, Vector4( 1.0f, 1.0f, 1.0f, 1.0f ) ); // Use Absolute size
+ .Add( Toolkit::DevelVisual::Transform::Property::OFFSET_POLICY, Vector2( DevelVisual::Transform::Policy::ABSOLUTE, DevelVisual::Transform::Policy::ABSOLUTE ) )
+ .Add( Toolkit::DevelVisual::Transform::Property::SIZE_POLICY, Vector2( DevelVisual::Transform::Policy::ABSOLUTE, DevelVisual::Transform::Policy::ABSOLUTE ) );
indeterminateVisual.SetTransformAndSize( visualTransform, trackSize );
}
DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::Align, BOTTOM_END )
DALI_ENUM_TO_STRING_TABLE_END( ALIGN )
+DALI_ENUM_TO_STRING_TABLE_BEGIN( POLICY )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::DevelVisual::Transform::Policy, RELATIVE )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::DevelVisual::Transform::Policy, ABSOLUTE )
+DALI_ENUM_TO_STRING_TABLE_END( POLICY )
+
Dali::Vector2 PointToVector2( Toolkit::Align::Type point, Toolkit::Direction::Type direction )
{
static const float pointToVector2[] = { 0.0f,0.0f,
return result;
}
+bool GetPolicyFromValue( const Property::Value& value, Vector2& policy )
+{
+ bool success = false;
+ if( value.Get( policy ) )
+ {
+ success = true;
+ }
+ else
+ {
+ Property::Array* array = value.GetArray();
+ if( array && array->Size() == 2 )
+ {
+ DevelVisual::Transform::Policy::Type xPolicy = static_cast< DevelVisual::Transform::Policy::Type >( -1 ); // Assign an invalid value so definitely changes
+ DevelVisual::Transform::Policy::Type yPolicy = static_cast< DevelVisual::Transform::Policy::Type >( -1 ); // Assign an invalid value so definitely changes
+
+ if( Scripting::GetEnumerationProperty< DevelVisual::Transform::Policy::Type >( array->GetElementAt( 0 ), POLICY_TABLE, POLICY_TABLE_COUNT, xPolicy ) &&
+ Scripting::GetEnumerationProperty< DevelVisual::Transform::Policy::Type >( array->GetElementAt( 1 ), POLICY_TABLE, POLICY_TABLE_COUNT, yPolicy ) )
+ {
+ policy.x = xPolicy;
+ policy.y = yPolicy;
+ success = true;
+ }
+ }
+ }
+ return success;
+}
+
} // unnamed namespace
Internal::Visual::Base::Impl::Impl()
Scripting::GetEnumerationProperty< Toolkit::Align::Type >( keyValue.second, ALIGN_TABLE, ALIGN_TABLE_COUNT, mAnchorPoint );
break;
}
- case Toolkit::DevelVisual::Transform::Property::OFFSET_SIZE_MODE:
+ case Toolkit::DevelVisual::Transform::Property::OFFSET_POLICY:
+ {
+ Vector2 policy;
+ if( GetPolicyFromValue( keyValue.second, policy ) )
+ {
+ mOffsetSizeMode.x = policy.x;
+ mOffsetSizeMode.y = policy.y;
+ }
+ break;
+ }
+ case Toolkit::DevelVisual::Transform::Property::SIZE_POLICY:
{
- keyValue.second.Get( mOffsetSizeMode );
+ Vector2 policy;
+ if( GetPolicyFromValue( keyValue.second, policy ) )
+ {
+ mOffsetSizeMode.z = policy.x;
+ mOffsetSizeMode.w = policy.y;
+ }
break;
}
}
}
else if( keyValue.first == "origin" )
{
- Toolkit::Align::Type align(Toolkit::Align::CENTER);
- if( Scripting::GetEnumerationProperty< Toolkit::Align::Type >( keyValue.second, ALIGN_TABLE, ALIGN_TABLE_COUNT, align ) )
- {
- mOrigin = align;
- }
+ Scripting::GetEnumerationProperty< Toolkit::Align::Type >( keyValue.second, ALIGN_TABLE, ALIGN_TABLE_COUNT, mOrigin );
}
else if( keyValue.first == "anchorPoint" )
{
- Toolkit::Align::Type align(Toolkit::Align::CENTER);
- if( Scripting::GetEnumerationProperty< Toolkit::Align::Type >( keyValue.second, ALIGN_TABLE, ALIGN_TABLE_COUNT, align ) )
+ Scripting::GetEnumerationProperty< Toolkit::Align::Type >( keyValue.second, ALIGN_TABLE, ALIGN_TABLE_COUNT, mAnchorPoint );
+ }
+ else if( keyValue.first == "offsetPolicy" )
+ {
+ Vector2 policy;
+ if( GetPolicyFromValue( keyValue.second, policy ) )
{
- mAnchorPoint = align;
+ mOffsetSizeMode.x = policy.x;
+ mOffsetSizeMode.y = policy.y;
}
}
- else if( keyValue.first == "offsetSizeMode" )
+ else if( keyValue.first == "sizePolicy" )
{
- keyValue.second.Get( mOffsetSizeMode );
+ Vector2 policy;
+ if( GetPolicyFromValue( keyValue.second, policy ) )
+ {
+ mOffsetSizeMode.z = policy.x;
+ mOffsetSizeMode.w = policy.y;
+ }
}
}
}
.Add( Toolkit::DevelVisual::Transform::Property::SIZE, mSize )
.Add( Toolkit::DevelVisual::Transform::Property::ORIGIN, mOrigin )
.Add( Toolkit::DevelVisual::Transform::Property::ANCHOR_POINT, mAnchorPoint )
- .Add( Toolkit::DevelVisual::Transform::Property::OFFSET_SIZE_MODE, mOffsetSizeMode );
+ .Add( Toolkit::DevelVisual::Transform::Property::OFFSET_POLICY, Vector2( mOffsetSizeMode.x, mOffsetSizeMode.y ) )
+ .Add( Toolkit::DevelVisual::Transform::Property::SIZE_POLICY, Vector2( mOffsetSizeMode.z, mOffsetSizeMode.w ) );
}
void Internal::Visual::Base::Impl::Transform::RegisterUniforms( Dali::Renderer renderer, Toolkit::Direction::Type direction )
Visuals have a **transform** field in the property map to allow layouting within a control. If this field is not set, then the visual defaults to filling the control. The **transform** field has a property map with the following keys:
-| Property | String | Type | Required | Description |
-|-------------------------------------------------|----------|:-------:|:--------:|---------------------------|
-| Dali::Toolkit::Visual::Transform::Property::OFFSET | offset | VECTOR2 | No | The offset of the visual. |
-| Dali::Toolkit::Visual::Transform::Property::SIZE | size | VECTOR2 | No | The size of the visual. |
-| Dali::Toolkit::Visual::Transform::Property::OFFSET_SIZE_MODE | offsetSizeMode | VECTOR4 | No | Whether the size or offset components are Relative or Absolute [More info](@ref offset-size-mode)|
-| Dali::Toolkit::Visual::Transform::Property::ORIGIN | origin | INTEGER or STRING | No | The origin of the visual within the control's area. [More info](@ref align-type) |
-| Dali::Toolkit::Visual::Transform::Property::ANCHOR_POINT | anchorPoint | INTEGER or STRING | No | The anchor point of the visual. [More info](@ref align-type)|
+| Property | String | Type | Required | Description |
+|----------------------------------------------------------------|--------------|:-----------------:|:--------:|---------------------------------------------------------------------------------------------|
+| Dali::Toolkit::DevelVisual::Transform::Property::OFFSET | offset | VECTOR2 | No | The offset of the visual. |
+| Dali::Toolkit::DevelVisual::Transform::Property::SIZE | size | VECTOR2 | No | The size of the visual. |
+| Dali::Toolkit::DevelVisual::Transform::Property::OFFSET_POLICY | offsetPolicy | VECTOR4 | No | Whether the offset components are Relative or Absolute [More info](@ref offset-size-policy) |
+| Dali::Toolkit::DevelVisual::Transform::Property::SIZE_POLICY | sizePolicy | VECTOR4 | No | Whether the size components are Relative or Absolute [More info](@ref offset-size-policy) |
+| Dali::Toolkit::DevelVisual::Transform::Property::ORIGIN | origin | INTEGER or STRING | No | The origin of the visual within the control's area. [More info](@ref align-type) |
+| Dali::Toolkit::DevelVisual::Transform::Property::ANCHOR_POINT | anchorPoint | INTEGER or STRING | No | The anchor point of the visual. [More info](@ref align-type) |
-## Offset & size modes {#offset-size-mode}
-
-The offset and size modes can be either Relative or Absolute. The offset modes are in the x and y components of the offsetSizeMode property, and map to the offset's x and y components respectively. The size modes are in the z and w components of the offsetSizeMode property, and map to the size's x and y components, respectively.
+## Offset & Size Policy {#offset-size-policy}
-A mode value of 0 represents a Relative mode, in which case the size or offset value represents a ratio of the control's size. A mode value of 1 represents an Absolute mode, in which case the size or offset value represents world units (pixels).
+The offset and size policies can be either Relative or Absolute.
-For example, an offsetSizeMode of [0, 0, 1, 1], an offset of (0, 0.25) and a size of (20, 20) means the visual will be 20 pixels by 20 pixels in size, positioned 25% above the center of the control.
+| Enumeration | String | Description |
+|---------------------------------------------------------|----------|-------------------------------------------------------------------------------|
+| Dali::Toolkit::DevelVisual::Transform::Policy::RELATIVE | RELATIVE | *Default*. The size or offset value represents a ratio of the control's size |
+| Dali::Toolkit::DevelVisual::Transform::Policy::ABSOLUTE | ABSOLUTE | The size or offset value represents world units (pixels) |
+For example, an offsetPolicy of [ RELATIVE, RELATIVE ], a sizePolicy of [ ABSOLUTE, ABSOLUTE ], an offset of ( 0, 0.25 ) and a size of ( 20, 20 ) means the visual will be 20 pixels by 20 pixels in size, positioned 25% above the center of the control.
## Alignment {#align-type}
| Enumeration | String | Description |