(Properties) Fixes to Actor/ShaderEffect/ImageActor incorrectly setting properties.
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Tue, 25 Mar 2014 17:49:04 +0000 (17:49 +0000)
committerPaul Wisbey <p.wisbey@samsung.com>
Thu, 3 Apr 2014 16:04:42 +0000 (17:04 +0100)
[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 <adeel.kazmi@samsung.com>
automated-tests/dali-test-suite/actors/utc-Dali-Actor.cpp
dali/internal/event/actors/actor-impl.cpp
dali/internal/event/actors/image-actor-impl.cpp
dali/internal/event/effects/shader-effect-impl.cpp

index ce2ea837d7d0fd8b026583d90218eaac167d0d41..ecb69cc73fb87eb54d7ab4d4eb091128dfbf403d 100644 (file)
@@ -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 );
+  }
+}
index f2c4fef3130472c776ae89247c5b9e00e22ffaa2..b90a64b58db4a29bce663818a6ee0f056781fb10 100644 (file)
@@ -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",
index 3843c7e2ce24a3c839971a0db0e3687f85d1fee9..464108a6adb198395c26041c4f75ca4c289b2f05 100644 (file)
@@ -562,7 +562,7 @@ void ImageActor::SetDefaultProperty( Property::Index index, const Property::Valu
       }
       case Dali::ImageActor::BORDER:
       {
-        SetNinePatchBorder(propertyValue.Get<Vector4>());
+        SetNinePatchBorder( propertyValue.Get<Vector4>(), true /*in pixels*/ );
         break;
       }
       case Dali::ImageActor::IMAGE:
index df536433b0f801193459d2a0f97bf7f05b92522d..0cb922f0b35fbcda03fabadd575acfaea410d6cc 100644 (file)
@@ -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;
     }