From a58d1439bb7ddd1664692c3bf41be11ce11469c3 Mon Sep 17 00:00:00 2001 From: Adeel Kazmi Date: Tue, 25 Mar 2014 17:49:04 +0000 Subject: [PATCH] (Properties) Fixes to Actor/ShaderEffect/ImageActor incorrectly setting properties. [Problem] 1) Actor world-scale type and name is out-of-sync. 2) Cannot create a shader effect if geometry is not specified in script. 3) ImageActor setting nine-patch property does not work. [Cause] 1) Mistake in table initialisation. Table is clearer in a later patch. 2) Only creating a shader-effect if geometry is specified. 3) Not specifying that our values are in pixels. [Solution] 1) Fix. 2) Create with default geometry type. 3) Specify that we have specified the 9-patch border in pixels. Signed-off-by: Adeel Kazmi --- .../dali-test-suite/actors/utc-Dali-Actor.cpp | 65 ++++++++++++++++++++++ dali/internal/event/actors/actor-impl.cpp | 2 +- dali/internal/event/actors/image-actor-impl.cpp | 2 +- dali/internal/event/effects/shader-effect-impl.cpp | 6 +- 4 files changed, 70 insertions(+), 5 deletions(-) diff --git a/automated-tests/dali-test-suite/actors/utc-Dali-Actor.cpp b/automated-tests/dali-test-suite/actors/utc-Dali-Actor.cpp index ce2ea83..ecb69cc 100644 --- a/automated-tests/dali-test-suite/actors/utc-Dali-Actor.cpp +++ b/automated-tests/dali-test-suite/actors/utc-Dali-Actor.cpp @@ -163,6 +163,8 @@ TEST_FUNCTION( UtcDaliActorSetGetOverlay, POSITIVE_TC_IDX ); TEST_FUNCTION( UtcDaliActorDynamics, POSITIVE_TC_IDX ); TEST_FUNCTION( UtcDaliActorCreateDestroy, POSITIVE_TC_IDX ); +TEST_FUNCTION( UtcDaliActorProperties, POSITIVE_TC_IDX ); + const char* vertexSource = "void main()\n" "{\n" @@ -2877,3 +2879,66 @@ static void UtcDaliActorCreateDestroy() DALI_TEST_CHECK( actor ); delete actor; } + +struct PropertyStringIndex +{ + const char * const name; + const Property::Index index; + const Property::Type type; +}; + +const PropertyStringIndex PROPERTY_TABLE[] = +{ + { "parent-origin", Actor::PARENT_ORIGIN, Property::VECTOR3 }, + { "parent-origin-x", Actor::PARENT_ORIGIN_X, Property::FLOAT }, + { "parent-origin-y", Actor::PARENT_ORIGIN_Y, Property::FLOAT }, + { "parent-origin-z", Actor::PARENT_ORIGIN_Z, Property::FLOAT }, + { "anchor-point", Actor::ANCHOR_POINT, Property::VECTOR3 }, + { "anchor-point-x", Actor::ANCHOR_POINT_X, Property::FLOAT }, + { "anchor-point-y", Actor::ANCHOR_POINT_Y, Property::FLOAT }, + { "anchor-point-z", Actor::ANCHOR_POINT_Z, Property::FLOAT }, + { "size", Actor::SIZE, Property::VECTOR3 }, + { "size-width", Actor::SIZE_WIDTH, Property::FLOAT }, + { "size-height", Actor::SIZE_HEIGHT, Property::FLOAT }, + { "size-depth", Actor::SIZE_DEPTH, Property::FLOAT }, + { "position", Actor::POSITION, Property::VECTOR3 }, + { "position-x", Actor::POSITION_X, Property::FLOAT }, + { "position-y", Actor::POSITION_Y, Property::FLOAT }, + { "position-z", Actor::POSITION_Z, Property::FLOAT }, + { "world-position", Actor::WORLD_POSITION, Property::VECTOR3 }, + { "world-position-x", Actor::WORLD_POSITION_X, Property::FLOAT }, + { "world-position-y", Actor::WORLD_POSITION_Y, Property::FLOAT }, + { "world-position-z", Actor::WORLD_POSITION_Z, Property::FLOAT }, + { "rotation", Actor::ROTATION, Property::ROTATION }, + { "world-rotation", Actor::WORLD_ROTATION, Property::ROTATION }, + { "scale", Actor::SCALE, Property::VECTOR3 }, + { "scale-x", Actor::SCALE_X, Property::FLOAT }, + { "scale-y", Actor::SCALE_Y, Property::FLOAT }, + { "scale-z", Actor::SCALE_Z, Property::FLOAT }, + { "world-scale", Actor::WORLD_SCALE, Property::VECTOR3 }, + { "visible", Actor::VISIBLE, Property::BOOLEAN }, + { "color", Actor::COLOR, Property::VECTOR4 }, + { "color-red", Actor::COLOR_RED, Property::FLOAT }, + { "color-green", Actor::COLOR_GREEN, Property::FLOAT }, + { "color-blue", Actor::COLOR_BLUE, Property::FLOAT }, + { "color-alpha", Actor::COLOR_ALPHA, Property::FLOAT }, + { "world-color", Actor::WORLD_COLOR, Property::VECTOR4 }, + { "world-matrix", Actor::WORLD_MATRIX, Property::MATRIX }, + { "name", Actor::NAME, Property::STRING }, +}; +const unsigned int PROPERTY_TABLE_COUNT = sizeof( PROPERTY_TABLE ) / sizeof( PROPERTY_TABLE[0] ); + +void UtcDaliActorProperties() +{ + TestApplication app; + + Actor actor = Actor::New(); + + for ( unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i ) + { + tet_printf( "Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index ); + DALI_TEST_EQUALS( actor.GetPropertyName( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].name, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetPropertyIndex( PROPERTY_TABLE[i].name ), PROPERTY_TABLE[i].index, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetPropertyType( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].type, TEST_LOCATION ); + } +} diff --git a/dali/internal/event/actors/actor-impl.cpp b/dali/internal/event/actors/actor-impl.cpp index f2c4fef..b90a64b 100644 --- a/dali/internal/event/actors/actor-impl.cpp +++ b/dali/internal/event/actors/actor-impl.cpp @@ -136,10 +136,10 @@ const std::string DEFAULT_PROPERTY_NAMES[] = "rotation", "world-rotation", "scale", - "world-scale", "scale-x", "scale-y", "scale-z", + "world-scale", "visible", "color", "color-red", diff --git a/dali/internal/event/actors/image-actor-impl.cpp b/dali/internal/event/actors/image-actor-impl.cpp index 3843c7e..464108a 100644 --- a/dali/internal/event/actors/image-actor-impl.cpp +++ b/dali/internal/event/actors/image-actor-impl.cpp @@ -562,7 +562,7 @@ void ImageActor::SetDefaultProperty( Property::Index index, const Property::Valu } case Dali::ImageActor::BORDER: { - SetNinePatchBorder(propertyValue.Get()); + SetNinePatchBorder( propertyValue.Get(), true /*in pixels*/ ); break; } case Dali::ImageActor::IMAGE: diff --git a/dali/internal/event/effects/shader-effect-impl.cpp b/dali/internal/event/effects/shader-effect-impl.cpp index df53643..0cb922f 100644 --- a/dali/internal/event/effects/shader-effect-impl.cpp +++ b/dali/internal/event/effects/shader-effect-impl.cpp @@ -617,9 +617,10 @@ void ShaderEffect::SetDefaultProperty( Property::Index index, const Property::Va std::string vertex = GetShader("vertex", propertyValue); std::string fragment = GetShader("fragment", propertyValue); + GeometryType geometryType = GEOMETRY_TYPE_IMAGE; + if( propertyValue.HasKey("geometry-type") ) { - GeometryType geometryType = GEOMETRY_TYPE_IMAGE; Property::Value geometryValue = propertyValue.GetValue("geometry-type"); DALI_ASSERT_ALWAYS(geometryValue.GetType() == Property::STRING && "Geometry type is not a string" ); @@ -644,9 +645,8 @@ void ShaderEffect::SetDefaultProperty( Property::Index index, const Property::Va { DALI_ASSERT_ALWAYS(!"Geometry type unknown" ); } - - SetShaderProgram( vertexPrefix, vertex, fragmentPrefix, fragment, geometryType, ShaderEffectPtr(this) ); } + SetShaderProgram( vertexPrefix, vertex, fragmentPrefix, fragment, geometryType, ShaderEffectPtr(this) ); break; } -- 2.7.4