[Problem] 1) Cannot create an actor from a Property::Map.
2) No mechanism of having event-thread only properties within Core.
[Cause] 1) Not available.
2) Not available.
[Solution] 1) Create a method which creates an actor from a property map and vice versa.
2) Added mechanism which checks whether a property can be used as an input to a
constraint.
Signed-off-by: Adeel Kazmi <adeel.kazmi@samsung.com>
{ "world-color", Actor::WORLD_COLOR, Property::VECTOR4 },
{ "world-matrix", Actor::WORLD_MATRIX, Property::MATRIX },
{ "name", Actor::NAME, Property::STRING },
+ { "sensitive", Actor::SENSITIVE, Property::BOOLEAN },
+ { "leave-required", Actor::LEAVE_REQUIRED, Property::BOOLEAN },
+ { "inherit-shader-effect", Actor::INHERIT_SHADER_EFFECT, Property::BOOLEAN },
+ { "inherit-rotation", Actor::INHERIT_ROTATION, Property::BOOLEAN },
+ { "inherit-scale", Actor::INHERIT_SCALE, Property::BOOLEAN },
+ { "color-mode", Actor::COLOR_MODE, Property::STRING },
+ { "position-inheritance", Actor::POSITION_INHERITANCE, Property::STRING },
+ { "draw-mode", Actor::DRAW_MODE, Property::STRING },
};
const unsigned int PROPERTY_TABLE_COUNT = sizeof( PROPERTY_TABLE ) / sizeof( PROPERTY_TABLE[0] );
TEST_FUNCTION( UtcDaliHandleGetPropertyIndex, POSITIVE_TC_IDX );
TEST_FUNCTION( UtcDaliHandleIsPropertyWritable, POSITIVE_TC_IDX );
TEST_FUNCTION( UtcDaliHandleIsPropertyAnimatable, POSITIVE_TC_IDX );
+TEST_FUNCTION( UtcDaliHandleIsPropertyAConstraintInput, POSITIVE_TC_IDX );
TEST_FUNCTION( UtcDaliHandleGetPropertyType, POSITIVE_TC_IDX );
TEST_FUNCTION( UtcDaliHandleNonAnimtableProperties, POSITIVE_TC_IDX );
TEST_FUNCTION( UtcDaliHandleNonAnimtableCompositeProperties, POSITIVE_TC_IDX );
DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::COLOR_GREEN ) );
DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::COLOR_BLUE ) );
DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::COLOR_ALPHA ) );
+ DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::SENSITIVE ) );
+ DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::LEAVE_REQUIRED ) );
+ DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::INHERIT_SHADER_EFFECT ) );
+ DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::INHERIT_ROTATION ) );
+ DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::INHERIT_SCALE ) );
+ DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::COLOR_MODE ) );
+ DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::POSITION_INHERITANCE ) );
+ DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::DRAW_MODE ) );
// World-properties are not writable:
DALI_TEST_CHECK( false == actor.IsPropertyWritable( Actor::WORLD_POSITION ) );
DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::WORLD_POSITION_Y ) );
DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::WORLD_POSITION_Z ) );
+ // Event-thread only properties can not be animated
+ DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::SENSITIVE ) );
+ DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::LEAVE_REQUIRED ) );
+ DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::INHERIT_SHADER_EFFECT ) );
+ DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::INHERIT_ROTATION ) );
+ DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::INHERIT_SCALE ) );
+ DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::COLOR_MODE ) );
+ DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::POSITION_INHERITANCE ) );
+ DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::DRAW_MODE ) );
+
// Type registered properties are not animatable
DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( PROPERTY_REGISTRATION_START_INDEX ) ); // START
DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( PROPERTY_REGISTRATION_START_INDEX + ( ( PROPERTY_REGISTRATION_MAX_INDEX - PROPERTY_REGISTRATION_START_INDEX ) * 0.5 ) ) ); // MIDDLE
DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( PROPERTY_REGISTRATION_MAX_INDEX ) ); // MAX
}
+void UtcDaliHandleIsPropertyAConstraintInput()
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+
+ // Actor properties which can be used as a constraint input:
+ DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::PARENT_ORIGIN ) );
+ DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::PARENT_ORIGIN_X ) );
+ DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::PARENT_ORIGIN_Y ) );
+ DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::PARENT_ORIGIN_Z ) );
+ DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::ANCHOR_POINT ) );
+ DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::ANCHOR_POINT_X ) );
+ DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::ANCHOR_POINT_Y ) );
+ DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::ANCHOR_POINT_Z ) );
+ DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::SIZE ) );
+ DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::SIZE_WIDTH ) );
+ DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::SIZE_HEIGHT ) );
+ DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::SIZE_DEPTH ) );
+ DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::POSITION ) );
+ DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::POSITION_X ) );
+ DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::POSITION_Y ) );
+ DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::POSITION_Z ) );
+ DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::ROTATION ) );
+ DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::SCALE ) );
+ DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::SCALE_X ) );
+ DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::SCALE_Y ) );
+ DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::SCALE_Z ) );
+ DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::VISIBLE ) );
+ DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::COLOR ) );
+ DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::COLOR_RED ) );
+ DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::COLOR_GREEN ) );
+ DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::COLOR_BLUE ) );
+ DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::COLOR_ALPHA ) );
+ DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::WORLD_POSITION ) );
+ DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::WORLD_ROTATION ) );
+ DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::WORLD_SCALE ) );
+ DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::WORLD_COLOR ) );
+ DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::WORLD_POSITION_X ) );
+ DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::WORLD_POSITION_Y ) );
+ DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::WORLD_POSITION_Z ) );
+
+ // Actor properties that cannot be used as a constraint input
+ DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::NAME ) );
+ DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::SENSITIVE ) );
+ DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::LEAVE_REQUIRED ) );
+ DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::INHERIT_SHADER_EFFECT ) );
+ DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::INHERIT_ROTATION ) );
+ DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::INHERIT_SCALE ) );
+ DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::COLOR_MODE ) );
+ DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::POSITION_INHERITANCE ) );
+ DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::DRAW_MODE ) );
+}
+
void UtcDaliHandleGetPropertyType()
{
tet_infoline("Positive Test Dali::Handle::GetPropertyType()");
TEST_FUNCTION( UtcDaliImageActorNewNullWithArea, POSITIVE_TC_IDX );
TEST_FUNCTION( UtcDaliImageActorSetImage, POSITIVE_TC_IDX );
TEST_FUNCTION( UtcDaliImageActorPropertyIndices, POSITIVE_TC_IDX );
+TEST_FUNCTION( UtcDaliImageActorImageProperty, POSITIVE_TC_IDX );
// Called only once before first test is run.
static void Startup()
DALI_TEST_CHECK( indices.size() > basicActor.GetPropertyCount() );
DALI_TEST_EQUALS( indices.size(), imageActor.GetPropertyCount(), TEST_LOCATION );
}
+
+void UtcDaliImageActorImageProperty()
+{
+ TestApplication application;
+ Image image = Image::New( "MY_PATH" );
+ ImageActor imageActor = ImageActor::New( image );
+
+ Stage::GetCurrent().Add( imageActor );
+ application.SendNotification();
+ application.Render();
+
+ Property::Value imageMap = imageActor.GetProperty( ImageActor::IMAGE );
+ DALI_TEST_CHECK( imageMap.HasKey( "filename" ) );
+ DALI_TEST_EQUALS( imageMap.GetValue( "filename" ).Get< std::string >(), "MY_PATH", TEST_LOCATION );
+}
}
catch ( DaliException& e )
{
- DALI_TEST_ASSERT( e, "( source.propertyIndex < DEFAULT_PROPERTY_MAX_COUNT ) || ( source.propertyIndex >= CUSTOM_PROPERTY_START )", TEST_LOCATION );
+ DALI_TEST_ASSERT( e, "mTargetProxy->IsPropertyAConstraintInput( source.propertyIndex )", TEST_LOCATION );
}
}
--- /dev/null
+utc-Dali-Scripting
--- /dev/null
+../master-makefile.mk
\ No newline at end of file
--- /dev/null
+TARGETS += \
+ utc-Dali-Scripting \
--- /dev/null
+/dali-test-suite/scripting/utc-Dali-Scripting
--- /dev/null
+//
+// Copyright (c) 2014 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <iostream>
+
+#include <stdlib.h>
+#include <tet_api.h>
+
+#include <dali/public-api/dali-core.h>
+
+#include <dali-test-suite-utils.h>
+
+using namespace Dali;
+using namespace Dali::Scripting;
+
+static void Startup();
+static void Cleanup();
+
+extern "C" {
+ void (*tet_startup)() = Startup;
+ void (*tet_cleanup)() = Cleanup;
+}
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+#define MAX_NUMBER_OF_TESTS 10000
+extern "C" {
+ struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS];
+}
+
+TEST_FUNCTION( UtcDaliScriptingGetColorMode, POSITIVE_TC_IDX );
+TEST_FUNCTION( UtcDaliScriptingGetPositionInheritanceMode, POSITIVE_TC_IDX );
+TEST_FUNCTION( UtcDaliScriptingGetDrawMode, POSITIVE_TC_IDX );
+TEST_FUNCTION( UtcDaliScriptingGetAnchorConstant, POSITIVE_TC_IDX );
+TEST_FUNCTION( UtcDaliScriptingNewImageNegative, NEGATIVE_TC_IDX );
+TEST_FUNCTION( UtcDaliScriptingNewImage, POSITIVE_TC_IDX );
+TEST_FUNCTION( UtcDaliScriptingNewShaderEffect, POSITIVE_TC_IDX );
+TEST_FUNCTION( UtcDaliScriptingNewActorNegative, NEGATIVE_TC_IDX );
+TEST_FUNCTION( UtcDaliScriptingNewActorProperties, POSITIVE_TC_IDX );
+TEST_FUNCTION( UtcDaliScriptingNewActorChildren, POSITIVE_TC_IDX );
+TEST_FUNCTION( UtcDaliScriptingCreatePropertyMapActor, POSITIVE_TC_IDX );
+TEST_FUNCTION( UtcDaliScriptingCreatePropertyMapImage, POSITIVE_TC_IDX );
+
+// Called only once before first test is run.
+static void Startup()
+{
+}
+
+// Called only once after last test is run
+static void Cleanup()
+{
+}
+
+struct StringEnum
+{
+ const char * string;
+ int value;
+};
+
+const StringEnum COLOR_MODE_VALUES[] =
+{
+ { "USE_OWN_COLOR", USE_OWN_COLOR },
+ { "USE_PARENT_COLOR", USE_PARENT_COLOR },
+ { "USE_OWN_MULTIPLY_PARENT_COLOR", USE_OWN_MULTIPLY_PARENT_COLOR },
+ { "USE_OWN_MULTIPLY_PARENT_ALPHA", USE_OWN_MULTIPLY_PARENT_ALPHA },
+};
+const unsigned int COLOR_MODE_VALUES_COUNT = sizeof( COLOR_MODE_VALUES ) / sizeof( COLOR_MODE_VALUES[0] );
+
+void UtcDaliScriptingGetColorMode()
+{
+ TestApplication application;
+
+ for ( unsigned int i = 0; i < COLOR_MODE_VALUES_COUNT; ++i )
+ {
+ tet_printf( "Checking %s == %d\n", COLOR_MODE_VALUES[i].string, COLOR_MODE_VALUES[i].value );
+ DALI_TEST_EQUALS( COLOR_MODE_VALUES[i].value, GetColorMode( COLOR_MODE_VALUES[i].string ), TEST_LOCATION );
+ DALI_TEST_EQUALS( COLOR_MODE_VALUES[i].string, GetColorMode( (ColorMode) COLOR_MODE_VALUES[i].value ), TEST_LOCATION );
+ }
+
+ try
+ {
+ (void)GetColorMode("INVALID_ARG");
+ tet_result( TET_FAIL );
+ }
+ catch ( DaliException& e )
+ {
+ DALI_TEST_ASSERT( e, "!\"Unknown", TEST_LOCATION );
+ }
+}
+
+const StringEnum POSITION_INHERITANCE_MODE_VALUES[] =
+{
+ { "INHERIT_PARENT_POSITION", INHERIT_PARENT_POSITION },
+ { "USE_PARENT_POSITION", USE_PARENT_POSITION },
+ { "USE_PARENT_POSITION_PLUS_LOCAL_POSITION", USE_PARENT_POSITION_PLUS_LOCAL_POSITION },
+ { "DONT_INHERIT_POSITION", DONT_INHERIT_POSITION },
+};
+const unsigned int POSITION_INHERITANCE_MODE_VALUES_COUNT = sizeof( POSITION_INHERITANCE_MODE_VALUES ) / sizeof( POSITION_INHERITANCE_MODE_VALUES[0] );
+
+void UtcDaliScriptingGetPositionInheritanceMode()
+{
+ TestApplication application;
+
+ for ( unsigned int i = 0; i < POSITION_INHERITANCE_MODE_VALUES_COUNT; ++i )
+ {
+ tet_printf( "Checking %s == %d\n", POSITION_INHERITANCE_MODE_VALUES[i].string, POSITION_INHERITANCE_MODE_VALUES[i].value );
+ DALI_TEST_EQUALS( POSITION_INHERITANCE_MODE_VALUES[i].value, GetPositionInheritanceMode( POSITION_INHERITANCE_MODE_VALUES[i].string ), TEST_LOCATION );
+ DALI_TEST_EQUALS( POSITION_INHERITANCE_MODE_VALUES[i].string, GetPositionInheritanceMode( (PositionInheritanceMode) POSITION_INHERITANCE_MODE_VALUES[i].value ), TEST_LOCATION );
+ }
+
+ try
+ {
+ (void)GetPositionInheritanceMode("INVALID_ARG");
+ tet_result( TET_FAIL );
+ }
+ catch ( DaliException& e )
+ {
+ DALI_TEST_ASSERT( e, "!\"Unknown", TEST_LOCATION );
+ }
+}
+
+const StringEnum DRAW_MODE_VALUES[] =
+{
+ { "NORMAL", DrawMode::NORMAL },
+ { "OVERLAY", DrawMode::OVERLAY },
+ { "STENCIL", DrawMode::STENCIL },
+};
+const unsigned int DRAW_MODE_VALUES_COUNT = sizeof( DRAW_MODE_VALUES ) / sizeof( DRAW_MODE_VALUES[0] );
+
+void UtcDaliScriptingGetDrawMode()
+{
+ TestApplication application;
+
+ for ( unsigned int i = 0; i < DRAW_MODE_VALUES_COUNT; ++i )
+ {
+ tet_printf( "Checking %s == %d\n", DRAW_MODE_VALUES[i].string, DRAW_MODE_VALUES[i].value );
+ DALI_TEST_EQUALS( DRAW_MODE_VALUES[i].value, GetDrawMode( DRAW_MODE_VALUES[i].string ), TEST_LOCATION );
+ DALI_TEST_EQUALS( DRAW_MODE_VALUES[i].string, GetDrawMode( (DrawMode::Type) DRAW_MODE_VALUES[i].value ), TEST_LOCATION );
+ }
+
+ try
+ {
+ (void)GetDrawMode("INVALID_ARG");
+ tet_result( TET_FAIL );
+ }
+ catch ( DaliException& e )
+ {
+ DALI_TEST_ASSERT( e, "!\"Unknown", TEST_LOCATION );
+ }
+}
+
+void UtcDaliScriptingGetAnchorConstant()
+{
+ TestApplication application;
+
+ DALI_TEST_EQUALS( Dali::ParentOrigin::BACK_TOP_LEFT, GetAnchorConstant( "BACK_TOP_LEFT" ), TEST_LOCATION );
+ DALI_TEST_EQUALS( Dali::ParentOrigin::BACK_TOP_CENTER, GetAnchorConstant( "BACK_TOP_CENTER" ), TEST_LOCATION );
+ DALI_TEST_EQUALS( Dali::ParentOrigin::BACK_TOP_RIGHT, GetAnchorConstant( "BACK_TOP_RIGHT" ), TEST_LOCATION );
+ DALI_TEST_EQUALS( Dali::ParentOrigin::BACK_CENTER_LEFT, GetAnchorConstant( "BACK_CENTER_LEFT" ), TEST_LOCATION );
+ DALI_TEST_EQUALS( Dali::ParentOrigin::BACK_CENTER, GetAnchorConstant( "BACK_CENTER" ), TEST_LOCATION );
+ DALI_TEST_EQUALS( Dali::ParentOrigin::BACK_CENTER_RIGHT, GetAnchorConstant( "BACK_CENTER_RIGHT" ), TEST_LOCATION );
+ DALI_TEST_EQUALS( Dali::ParentOrigin::BACK_BOTTOM_LEFT, GetAnchorConstant( "BACK_BOTTOM_LEFT" ), TEST_LOCATION );
+ DALI_TEST_EQUALS( Dali::ParentOrigin::BACK_BOTTOM_CENTER, GetAnchorConstant( "BACK_BOTTOM_CENTER" ), TEST_LOCATION );
+ DALI_TEST_EQUALS( Dali::ParentOrigin::BACK_BOTTOM_RIGHT, GetAnchorConstant( "BACK_BOTTOM_RIGHT" ), TEST_LOCATION );
+ DALI_TEST_EQUALS( Dali::ParentOrigin::TOP_LEFT, GetAnchorConstant( "TOP_LEFT" ), TEST_LOCATION );
+ DALI_TEST_EQUALS( Dali::ParentOrigin::TOP_CENTER, GetAnchorConstant( "TOP_CENTER" ), TEST_LOCATION );
+ DALI_TEST_EQUALS( Dali::ParentOrigin::TOP_RIGHT, GetAnchorConstant( "TOP_RIGHT" ), TEST_LOCATION );
+ DALI_TEST_EQUALS( Dali::ParentOrigin::CENTER_LEFT, GetAnchorConstant( "CENTER_LEFT" ), TEST_LOCATION );
+ DALI_TEST_EQUALS( Dali::ParentOrigin::CENTER, GetAnchorConstant( "CENTER" ), TEST_LOCATION );
+ DALI_TEST_EQUALS( Dali::ParentOrigin::CENTER_RIGHT, GetAnchorConstant( "CENTER_RIGHT" ), TEST_LOCATION );
+ DALI_TEST_EQUALS( Dali::ParentOrigin::BOTTOM_LEFT, GetAnchorConstant( "BOTTOM_LEFT" ), TEST_LOCATION );
+ DALI_TEST_EQUALS( Dali::ParentOrigin::BOTTOM_CENTER, GetAnchorConstant( "BOTTOM_CENTER" ), TEST_LOCATION );
+ DALI_TEST_EQUALS( Dali::ParentOrigin::BOTTOM_RIGHT, GetAnchorConstant( "BOTTOM_RIGHT" ), TEST_LOCATION );
+ DALI_TEST_EQUALS( Dali::ParentOrigin::FRONT_TOP_LEFT, GetAnchorConstant( "FRONT_TOP_LEFT" ), TEST_LOCATION );
+ DALI_TEST_EQUALS( Dali::ParentOrigin::FRONT_TOP_CENTER, GetAnchorConstant( "FRONT_TOP_CENTER" ), TEST_LOCATION );
+ DALI_TEST_EQUALS( Dali::ParentOrigin::FRONT_TOP_RIGHT, GetAnchorConstant( "FRONT_TOP_RIGHT" ), TEST_LOCATION );
+ DALI_TEST_EQUALS( Dali::ParentOrigin::FRONT_CENTER_LEFT, GetAnchorConstant( "FRONT_CENTER_LEFT" ), TEST_LOCATION );
+ DALI_TEST_EQUALS( Dali::ParentOrigin::FRONT_CENTER, GetAnchorConstant( "FRONT_CENTER" ), TEST_LOCATION );
+ DALI_TEST_EQUALS( Dali::ParentOrigin::FRONT_CENTER_RIGHT, GetAnchorConstant( "FRONT_CENTER_RIGHT" ), TEST_LOCATION );
+ DALI_TEST_EQUALS( Dali::ParentOrigin::FRONT_BOTTOM_LEFT, GetAnchorConstant( "FRONT_BOTTOM_LEFT" ), TEST_LOCATION );
+ DALI_TEST_EQUALS( Dali::ParentOrigin::FRONT_BOTTOM_CENTER, GetAnchorConstant( "FRONT_BOTTOM_CENTER" ), TEST_LOCATION );
+ DALI_TEST_EQUALS( Dali::ParentOrigin::FRONT_BOTTOM_RIGHT, GetAnchorConstant( "FRONT_BOTTOM_RIGHT" ), TEST_LOCATION );
+
+ try
+ {
+ (void)GetAnchorConstant("INVALID_ARG");
+ tet_result( TET_FAIL );
+ }
+ catch ( DaliException& e )
+ {
+ DALI_TEST_ASSERT( e, "!\"Unknown", TEST_LOCATION );
+ }
+}
+
+void UtcDaliScriptingNewImageNegative()
+{
+ TestApplication application;
+
+ // Invalid filename
+ try
+ {
+ Property::Map map;
+ map.push_back( Property::StringValuePair( "filename", Vector3::ZERO ) );
+ Image image = NewImage( map );
+ tet_result( TET_FAIL );
+ }
+ catch ( DaliException& e )
+ {
+ DALI_TEST_ASSERT( e, "map.GetValue(field).GetType()", TEST_LOCATION );
+ }
+
+ // Invalid load-policy
+ try
+ {
+ Property::Map map;
+ map.push_back( Property::StringValuePair( "load-policy", Vector3::ZERO ) );
+ Image image = NewImage( map );
+ tet_result( TET_FAIL );
+ }
+ catch ( DaliException& e )
+ {
+ DALI_TEST_ASSERT( e, "map.GetValue(field).GetType()", TEST_LOCATION );
+
+ // Invalid value
+ try
+ {
+ Property::Map map;
+ map.push_back( Property::StringValuePair( "load-policy", "INVALID" ) );
+ Image image = NewImage( map );
+ tet_result( TET_FAIL );
+ }
+ catch ( DaliException& e )
+ {
+ DALI_TEST_ASSERT( e, "!\"Unknown", TEST_LOCATION );
+ }
+ }
+
+ // Invalid release-policy
+ try
+ {
+ Property::Map map;
+ map.push_back( Property::StringValuePair( "release-policy", Vector3::ZERO ) );
+ Image image = NewImage( map );
+ tet_result( TET_FAIL );
+ }
+ catch ( DaliException& e )
+ {
+ DALI_TEST_ASSERT( e, "map.GetValue(field).GetType()", TEST_LOCATION );
+
+ // Invalid value
+ try
+ {
+ Property::Map map;
+ map.push_back( Property::StringValuePair( "release-policy", "INVALID" ) );
+ Image image = NewImage( map );
+ tet_result( TET_FAIL );
+ }
+ catch ( DaliException& e )
+ {
+ DALI_TEST_ASSERT( e, "!\"Unknown", TEST_LOCATION );
+ }
+ }
+
+ // Invalid width
+ try
+ {
+ Property::Map map;
+ map.push_back( Property::StringValuePair( "width", "Invalid" ) );
+ map.push_back( Property::StringValuePair( "height", "Invalid" ) );
+ Image image = NewImage( map );
+ tet_result( TET_FAIL );
+ }
+ catch ( DaliException& e )
+ {
+ DALI_TEST_ASSERT( e, "value.GetType()", TEST_LOCATION );
+ }
+
+ // Invalid height
+ try
+ {
+ Property::Map map;
+ map.push_back( Property::StringValuePair( "width", 10 ) );
+ map.push_back( Property::StringValuePair( "height", "Invalid" ) );
+ Image image = NewImage( map );
+ tet_result( TET_FAIL );
+ }
+ catch ( DaliException& e )
+ {
+ DALI_TEST_ASSERT( e, "value.GetType()", TEST_LOCATION );
+ }
+
+ // Invalid pixel-format
+ try
+ {
+ Property::Map map;
+ map.push_back( Property::StringValuePair( "pixel-format", Vector3::ZERO ) );
+ Image image = NewImage( map );
+ tet_result( TET_FAIL );
+ }
+ catch ( DaliException& e )
+ {
+ DALI_TEST_ASSERT( e, "map.GetValue(field).GetType()", TEST_LOCATION );
+
+ // Invalid value
+ try
+ {
+ Property::Map map;
+ map.push_back( Property::StringValuePair( "pixel-format", "INVALID" ) );
+ Image image = NewImage( map );
+ tet_result( TET_FAIL );
+ }
+ catch ( DaliException& e )
+ {
+ DALI_TEST_ASSERT( e, "!\"Unknown", TEST_LOCATION );
+ }
+ }
+
+ // Invalid scaling-mode
+ try
+ {
+ Property::Map map;
+ map.push_back( Property::StringValuePair( "scaling-mode", Vector3::ZERO ) );
+ Image image = NewImage( map );
+ tet_result( TET_FAIL );
+ }
+ catch ( DaliException& e )
+ {
+ DALI_TEST_ASSERT( e, "map.GetValue(field).GetType()", TEST_LOCATION );
+
+ // Invalid value
+ try
+ {
+ Property::Map map;
+ map.push_back( Property::StringValuePair( "scaling-mode", "INVALID" ) );
+ Image image = NewImage( map );
+ tet_result( TET_FAIL );
+ }
+ catch ( DaliException& e )
+ {
+ DALI_TEST_ASSERT( e, "!\"Unknown", TEST_LOCATION );
+ }
+ }
+
+ // Invalid crop
+ try
+ {
+ Property::Map map;
+ map.push_back( Property::StringValuePair( "crop", "Invalid" ) );
+ Image image = NewImage( map );
+ tet_result( TET_FAIL );
+ }
+ catch ( DaliException& e )
+ {
+ DALI_TEST_ASSERT( e, "map.GetValue(field).GetType()", TEST_LOCATION );
+ }
+
+ // Invalid type
+ try
+ {
+ Property::Map map;
+ map.push_back( Property::StringValuePair( "type", Vector3::ZERO ) );
+ Image image = NewImage( map );
+ tet_result( TET_FAIL );
+ }
+ catch ( DaliException& e )
+ {
+ DALI_TEST_ASSERT( e, "map.GetValue(\"type\").GetType()", TEST_LOCATION );
+
+ // Invalid value
+ try
+ {
+ Property::Map map;
+ map.push_back( Property::StringValuePair( "type", "INVALID" ) );
+ Image image = NewImage( map );
+ tet_result( TET_FAIL );
+ }
+ catch ( DaliException& e )
+ {
+ DALI_TEST_ASSERT( e, "!\"Unknown", TEST_LOCATION );
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// Helpers for string to enum comparisons for Image and ImageAttributes
+//////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Template to check enumerations of type T, with a class of type X
+ */
+template< typename T, typename X >
+void TestEnumStrings(
+ Property::Map& map, // The map used to create instance of type X
+ const StringEnum* values, // An array of string values
+ unsigned int num, // Number of items in the array
+ T ( X::*method )() const, // The member method of X to call to get the enum
+ X ( *creator ) ( const Property::Value& ) // The method which creates an instance of type X
+)
+{
+ Property::Map::iterator iter = map.end() - 1;
+ for ( unsigned int i = 0; i < num; ++i )
+ {
+ iter->second = values[i].string;
+ tet_printf("Checking: %s: %s\n", iter->first.c_str(), values[i].string );
+ X instance = creator( map );
+ DALI_TEST_EQUALS( values[i].value, ( instance.*method )(), TEST_LOCATION );
+ }
+}
+
+/// Helper method to create ImageAttributes using an Image
+ImageAttributes NewImageAttributes( const Property::Value& map )
+{
+ Image image = NewImage( map );
+ return image.GetAttributes();
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+void UtcDaliScriptingNewImage()
+{
+ TestApplication application;
+
+ Property::Map map;
+ map.push_back( Property::StringValuePair( "filename", "TEST_FILE" ) );
+
+ // Filename only
+ {
+ Image image = NewImage( map );
+ DALI_TEST_EQUALS( "TEST_FILE", image.GetFilename(), TEST_LOCATION );
+ }
+
+ // load-policy
+ map.push_back( Property::StringValuePair( "load-policy", "" ) );
+ {
+ const StringEnum values[] =
+ {
+ { "IMMEDIATE", Image::Immediate },
+ { "ON_DEMAND", Image::OnDemand }
+ };
+ TestEnumStrings< Image::LoadPolicy, Image >( map, values, ( sizeof( values ) / sizeof ( values[0] ) ), &Image::GetLoadPolicy, &NewImage );
+ }
+
+ // release-policy
+ map.push_back( Property::StringValuePair( "release-policy", "" ) );
+ {
+ const StringEnum values[] =
+ {
+ { "UNUSED", Image::Unused },
+ { "NEVER", Image::Never }
+ };
+ TestEnumStrings< Image::ReleasePolicy, Image >( map, values, ( sizeof( values ) / sizeof ( values[0] ) ), &Image::GetReleasePolicy, &NewImage );
+ }
+
+ // float width and height
+ map.push_back( Property::StringValuePair( "width", (float) 10.0f ) );
+ map.push_back( Property::StringValuePair( "height", (float) 20.0f ) );
+ {
+ Image image = NewImage( map );
+ DALI_TEST_EQUALS( image.GetWidth(), 10.0f, TEST_LOCATION );
+ DALI_TEST_EQUALS( image.GetHeight(), 20.0f, TEST_LOCATION );
+ }
+
+ // int width and height
+ map.erase( map.end() - 2, map.end() );
+ map.push_back( Property::StringValuePair( "width", 50 ) );
+ map.push_back( Property::StringValuePair( "height", 70 ) );
+ {
+ Image image = NewImage( map );
+ DALI_TEST_EQUALS( image.GetWidth(), 50u, TEST_LOCATION );
+ DALI_TEST_EQUALS( image.GetHeight(), 70u, TEST_LOCATION );
+ }
+
+ //map.erase( map.end() - 2, map.end() );
+
+ // pixel-format
+ map.push_back( Property::StringValuePair( "pixel-format", "" ) );
+ {
+ const StringEnum values[] =
+ {
+ { "A8", Pixel::A8 },
+ { "L8", Pixel::L8 },
+ { "LA88", Pixel::LA88 },
+ { "RGB565", Pixel::RGB565 },
+ { "BGR565", Pixel::BGR565 },
+ { "RGBA4444", Pixel::RGBA4444 },
+ { "BGRA4444", Pixel::BGRA4444 },
+ { "RGBA5551", Pixel::RGBA5551 },
+ { "BGRA5551", Pixel::BGRA5551 },
+ { "RGB888", Pixel::RGB888 },
+ { "RGB8888", Pixel::RGB8888 },
+ { "BGR8888", Pixel::BGR8888 },
+ { "RGBA8888", Pixel::RGBA8888 },
+ { "BGRA8888", Pixel::BGRA8888 },
+ { "COMPRESSED_R11_EAC", Pixel::COMPRESSED_R11_EAC },
+ { "COMPRESSED_SIGNED_R11_EAC", Pixel::COMPRESSED_SIGNED_R11_EAC },
+ { "COMPRESSED_RG11_EAC", Pixel::COMPRESSED_RG11_EAC },
+ { "COMPRESSED_SIGNED_RG11_EAC", Pixel::COMPRESSED_SIGNED_RG11_EAC },
+ { "COMPRESSED_RGB8_ETC2", Pixel::COMPRESSED_RGB8_ETC2 },
+ { "COMPRESSED_SRGB8_ETC2", Pixel::COMPRESSED_SRGB8_ETC2 },
+ { "COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2", Pixel::COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 },
+ { "COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2", Pixel::COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 },
+ { "COMPRESSED_RGBA8_ETC2_EAC", Pixel::COMPRESSED_RGBA8_ETC2_EAC },
+ { "COMPRESSED_SRGB8_ALPHA8_ETC2_EAC", Pixel::COMPRESSED_SRGB8_ALPHA8_ETC2_EAC },
+ { "COMPRESSED_RGB8_ETC1", Pixel::COMPRESSED_RGB8_ETC1 },
+ { "COMPRESSED_RGB_PVRTC_4BPPV1", Pixel::COMPRESSED_RGB_PVRTC_4BPPV1 },
+ { "A8", Pixel::A8 }, // Checked already but reset so that BitmapImage works
+ };
+ TestEnumStrings< Pixel::Format, ImageAttributes >( map, values, ( sizeof( values ) / sizeof ( values[0] ) ), &ImageAttributes::GetPixelFormat, &NewImageAttributes );
+ }
+
+ // scaling-mode
+ map.push_back( Property::StringValuePair( "scaling-mode", "" ) );
+ {
+ const StringEnum values[] =
+ {
+ { "SHRINK_TO_FIT", ImageAttributes::ShrinkToFit },
+ { "SCALE_TO_FILL", ImageAttributes::ScaleToFill },
+ { "FIT_WIDTH", ImageAttributes::FitWidth },
+ { "FIT_HEIGHT", ImageAttributes::FitHeight },
+ };
+ TestEnumStrings< ImageAttributes::ScalingMode, ImageAttributes >( map, values, ( sizeof( values ) / sizeof ( values[0] ) ), &ImageAttributes::GetScalingMode, &NewImageAttributes );
+ }
+
+ // crop
+ map.push_back( Property::StringValuePair( "crop", Vector4( 50, 60, 70, 80 ) ) );
+ {
+ Image image = NewImage( map );
+ ImageAttributes attributes = image.GetAttributes();
+ Rect<float> crop = attributes.GetCrop();
+ DALI_TEST_EQUALS( crop.x, 50, TEST_LOCATION );
+ DALI_TEST_EQUALS( crop.y, 60, TEST_LOCATION );
+ DALI_TEST_EQUALS( crop.width, 70, TEST_LOCATION );
+ DALI_TEST_EQUALS( crop.height, 80, TEST_LOCATION );
+ }
+
+ // type FrameBufferImage
+ map.push_back( Property::StringValuePair( "type", "FrameBufferImage" ) );
+ {
+ Image image = NewImage( map );
+ DALI_TEST_CHECK( FrameBufferImage::DownCast( image ) );
+ }
+ // type BitMapImage
+ (map.end() - 1)->second = "BitmapImage";
+ {
+ Image image = NewImage( map );
+ DALI_TEST_CHECK( BitmapImage::DownCast( image ) );
+ }
+ // type Image
+ (map.end() - 1)->second = "Image";
+ {
+ Image image = NewImage( map );
+ DALI_TEST_CHECK( Image::DownCast( image ) );
+ DALI_TEST_CHECK( !FrameBufferImage::DownCast( image ) );
+ DALI_TEST_CHECK( !BitmapImage::DownCast( image ) );
+ }
+}
+
+void UtcDaliScriptingNewShaderEffect()
+{
+ TestApplication application;
+
+ Property::Map programMap;
+ programMap.push_back( Property::StringValuePair( "vertex-filename", "bump.vert" ) );
+ programMap.push_back( Property::StringValuePair( "fragment-filename", "bump.frag" ) );
+
+ Property::Map imageMap;
+ imageMap.push_back( Property::StringValuePair( "filename", "image.png" ) );
+
+ Property::Map map;
+ map.push_back( Property::StringValuePair( "image", imageMap ) );
+ map.push_back( Property::StringValuePair( "program", programMap ) );
+ map.push_back( Property::StringValuePair( "uLightPosition", Vector3( 0.0, 0.0, -1.5) ) );
+ map.push_back( Property::StringValuePair( "uAmbientLight", (int)10 ) );
+
+ ShaderEffect shader = NewShaderEffect( map );
+
+ DALI_TEST_CHECK( shader );
+}
+
+void UtcDaliScriptingNewActorNegative()
+{
+ TestApplication application;
+
+ // Empty map
+ {
+ Actor handle = NewActor( Property::Map() );
+ DALI_TEST_CHECK( !handle );
+ }
+
+ // Map with only properties
+ {
+ Property::Map map;
+ map.push_back( Property::StringValuePair( "parent-origin", ParentOrigin::TOP_CENTER ) );
+ map.push_back( Property::StringValuePair( "anchor-point", AnchorPoint::TOP_CENTER ) );
+ Actor handle = NewActor( map );
+ DALI_TEST_CHECK( !handle );
+ }
+
+ // Add some signals to the map, we should have no signal connections as its not yet supported
+ {
+ Property::Map map;
+ map.push_back( Property::StringValuePair( "type", "Actor" ) );
+ map.push_back( Property::StringValuePair( "signals", Property::MAP ) );
+ Actor handle = NewActor( map );
+ DALI_TEST_CHECK( handle );
+ DALI_TEST_CHECK( !handle.MouseWheelEventSignal().GetConnectionCount() );
+ DALI_TEST_CHECK( !handle.OffStageSignal().GetConnectionCount() );
+ DALI_TEST_CHECK( !handle.OnStageSignal().GetConnectionCount() );
+ DALI_TEST_CHECK( !handle.SetSizeSignal().GetConnectionCount() );
+ DALI_TEST_CHECK( !handle.TouchedSignal().GetConnectionCount() );
+ }
+}
+
+void UtcDaliScriptingNewActorProperties()
+{
+ TestApplication application;
+
+ Property::Map map;
+ map.push_back( Property::StringValuePair( "type", "Actor" ) );
+ map.push_back( Property::StringValuePair( "size", Vector3::ONE ) );
+ map.push_back( Property::StringValuePair( "position", Vector3::XAXIS ) );
+ map.push_back( Property::StringValuePair( "scale", Vector3::ONE ) );
+ map.push_back( Property::StringValuePair( "visible", false ) );
+ map.push_back( Property::StringValuePair( "color", Color::MAGENTA ) );
+ map.push_back( Property::StringValuePair( "name", "MyActor" ) );
+ map.push_back( Property::StringValuePair( "color-mode", "USE_PARENT_COLOR" ) );
+ map.push_back( Property::StringValuePair( "inherit-shader-effect", false ) );
+ map.push_back( Property::StringValuePair( "sensitive", false ) );
+ map.push_back( Property::StringValuePair( "leave-required", true ) );
+ map.push_back( Property::StringValuePair( "position-inheritance", "DONT_INHERIT_POSITION" ) );
+ map.push_back( Property::StringValuePair( "draw-mode", "STENCIL" ) );
+ map.push_back( Property::StringValuePair( "inherit-rotation", false ) );
+ map.push_back( Property::StringValuePair( "inherit-scale", false ) );
+
+ // Default properties
+ {
+ Actor handle = NewActor( map );
+ DALI_TEST_CHECK( handle );
+
+ Stage::GetCurrent().Add( handle );
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( handle.GetCurrentSize(), Vector3::ONE, TEST_LOCATION );
+ DALI_TEST_EQUALS( handle.GetCurrentPosition(), Vector3::XAXIS, TEST_LOCATION );
+ DALI_TEST_EQUALS( handle.GetCurrentScale(), Vector3::ONE, TEST_LOCATION );
+ DALI_TEST_EQUALS( handle.IsVisible(), false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handle.GetCurrentColor(), Color::MAGENTA, TEST_LOCATION );
+ DALI_TEST_EQUALS( handle.GetName(), "MyActor", TEST_LOCATION );
+ DALI_TEST_EQUALS( handle.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
+ DALI_TEST_EQUALS( handle.GetInheritShaderEffect(), false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handle.IsSensitive(), false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handle.GetLeaveRequired(), true, TEST_LOCATION );
+ DALI_TEST_EQUALS( handle.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
+ DALI_TEST_EQUALS( handle.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
+ DALI_TEST_EQUALS( handle.IsRotationInherited(), false, TEST_LOCATION );
+ DALI_TEST_EQUALS( handle.IsScaleInherited(), false, TEST_LOCATION );
+
+ Stage::GetCurrent().Remove( handle );
+ }
+
+ // Check Anchor point and parent origin vector3s
+ map.push_back( Property::StringValuePair( "parent-origin", ParentOrigin::TOP_CENTER ) );
+ map.push_back( Property::StringValuePair( "anchor-point", AnchorPoint::TOP_LEFT ) );
+ {
+ Actor handle = NewActor( map );
+ DALI_TEST_CHECK( handle );
+
+ Stage::GetCurrent().Add( handle );
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( handle.GetCurrentParentOrigin(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
+ DALI_TEST_EQUALS( handle.GetCurrentAnchorPoint(), AnchorPoint::TOP_LEFT, TEST_LOCATION );
+
+ Stage::GetCurrent().Remove( handle );
+ }
+
+ // Check Anchor point and parent origin STRINGS
+ map.erase( map.end() - 2, map.end() ); // delete previously added parent origin and anchor point
+ map.push_back( Property::StringValuePair( "parent-origin", "BACK_TOP_LEFT" ) );
+ map.push_back( Property::StringValuePair( "anchor-point", "FRONT_CENTER_LEFT" ) );
+ {
+ Actor handle = NewActor( map );
+ DALI_TEST_CHECK( handle );
+
+ Stage::GetCurrent().Add( handle );
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( handle.GetCurrentParentOrigin(), ParentOrigin::BACK_TOP_LEFT, TEST_LOCATION );
+ DALI_TEST_EQUALS( handle.GetCurrentAnchorPoint(), AnchorPoint::FRONT_CENTER_LEFT, TEST_LOCATION );
+
+ Stage::GetCurrent().Remove( handle );
+ }
+}
+
+void UtcDaliScriptingNewActorChildren()
+{
+ TestApplication application;
+
+ Property::Map map;
+ map.push_back( Property::StringValuePair( "type", "Actor" ) );
+ map.push_back( Property::StringValuePair( "position", Vector3::XAXIS ) );
+
+ Property::Map child1Map;
+ child1Map.push_back( Property::StringValuePair( "type", "ImageActor" ) );
+ child1Map.push_back( Property::StringValuePair( "position", Vector3::YAXIS ) );
+
+ Property::Map child2Map;
+ child2Map.push_back( Property::StringValuePair( "type", "TextActor" ) );
+ child2Map.push_back( Property::StringValuePair( "position", Vector3::ZAXIS ) );
+
+ Property::Map grandChildMap;
+ grandChildMap.push_back( Property::StringValuePair( "type", "LightActor" ) );
+ grandChildMap.push_back( Property::StringValuePair( "position", Vector3::ONE ) );
+
+ // Add arrays to appropriate maps
+ Property::Array grandChildArray;
+ grandChildArray.push_back( grandChildMap );
+ Property::Array childArray;
+ child1Map.push_back( Property::StringValuePair( "actors", grandChildArray ) );
+ childArray.push_back( child1Map );
+ childArray.push_back( child2Map );
+ map.push_back( Property::StringValuePair( "actors", childArray ) );
+
+ // Create
+ Actor handle = NewActor( map );
+ DALI_TEST_CHECK( handle );
+
+ Stage::GetCurrent().Add( handle );
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( handle.GetCurrentPosition(), Vector3::XAXIS, TEST_LOCATION );
+ DALI_TEST_EQUALS( handle.GetChildCount(), 2u, TEST_LOCATION );
+
+ Actor child1 = handle.GetChildAt(0);
+ DALI_TEST_CHECK( child1 );
+ DALI_TEST_CHECK( ImageActor::DownCast( child1 ) );
+ DALI_TEST_EQUALS( child1.GetCurrentPosition(), Vector3::YAXIS, TEST_LOCATION );
+ DALI_TEST_EQUALS( child1.GetChildCount(), 1u, TEST_LOCATION );
+
+ Actor child2 = handle.GetChildAt(1);
+ DALI_TEST_CHECK( child2 );
+ DALI_TEST_CHECK( TextActor::DownCast( child2 ) );
+ DALI_TEST_EQUALS( child2.GetCurrentPosition(), Vector3::ZAXIS, TEST_LOCATION );
+ DALI_TEST_EQUALS( child2.GetChildCount(), 0u, TEST_LOCATION );
+
+ Actor grandChild = child1.GetChildAt( 0 );
+ DALI_TEST_CHECK( grandChild );
+ DALI_TEST_CHECK( LightActor::DownCast( grandChild ) );
+ DALI_TEST_EQUALS( grandChild.GetCurrentPosition(), Vector3::ONE, TEST_LOCATION );
+ DALI_TEST_EQUALS( grandChild.GetChildCount(), 0u, TEST_LOCATION );
+
+ Stage::GetCurrent().Remove( handle );
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// Helpers for string to enum comparisons for Actor to Property::Map
+//////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Template to check enumerations of type T
+ */
+template< typename T >
+void TestEnumStrings(
+ const char * const keyName, // The name of the key to check
+ TestApplication& application, // Reference to the application class
+ const StringEnum* values, // An array of string values
+ unsigned int num, // Number of items in the array
+ void ( Actor::*method )( T ) // The Actor member method to set the enumeration
+)
+{
+ for ( unsigned int i = 0; i < num; ++i )
+ {
+ tet_printf("Checking: %s: %s\n", keyName, values[i].string );
+
+ Actor actor = Actor::New();
+ (actor.*method)( ( T ) values[i].value );
+
+ Stage::GetCurrent().Add( actor );
+ application.SendNotification();
+ application.Render();
+
+ Property::Map map;
+ CreatePropertyMap( actor, map );
+
+ DALI_TEST_CHECK( !map.empty() );
+ Property::Value value( map );
+ DALI_TEST_CHECK( value.HasKey( keyName ) );
+ DALI_TEST_EQUALS( value.GetValue( keyName ).Get< std::string >(), values[i].string, TEST_LOCATION );
+
+ Stage::GetCurrent().Remove( actor );
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+void UtcDaliScriptingCreatePropertyMapActor()
+{
+ TestApplication application;
+
+ // Actor Type
+ {
+ Actor actor = Actor::New();
+
+ Property::Map map;
+ CreatePropertyMap( actor, map );
+ DALI_TEST_CHECK( !map.empty() );
+ Property::Value value( map );
+ DALI_TEST_CHECK( value.HasKey( "type" ) );
+ DALI_TEST_EQUALS( value.GetValue( "type").Get< std::string >(), "Actor", TEST_LOCATION );
+
+ Stage::GetCurrent().Remove( actor );
+ }
+
+ // ImageActor Type
+ {
+ Actor actor = ImageActor::New();
+
+ Property::Map map;
+ CreatePropertyMap( actor, map );
+ DALI_TEST_CHECK( !map.empty() );
+ Property::Value value( map );
+ DALI_TEST_CHECK( value.HasKey( "type" ) );
+ DALI_TEST_EQUALS( value.GetValue( "type").Get< std::string >(), "ImageActor", TEST_LOCATION );
+
+ Stage::GetCurrent().Remove( actor );
+ }
+
+ // Default properties
+ {
+ Actor actor = Actor::New();
+ actor.SetSize( Vector3::ONE );
+ actor.SetPosition( Vector3::XAXIS );
+ actor.SetScale( Vector3::ZAXIS );
+ actor.SetVisible( false );
+ actor.SetColor( Color::MAGENTA );
+ actor.SetName( "MyActor" );
+ actor.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
+ actor.SetParentOrigin( ParentOrigin::TOP_RIGHT );
+ actor.SetInheritShaderEffect( false );
+ actor.SetSensitive( false );
+ actor.SetLeaveRequired( true );
+ actor.SetInheritRotation( false );
+ actor.SetInheritScale( false );
+
+ Stage::GetCurrent().Add( actor );
+ application.SendNotification();
+ application.Render();
+
+ Property::Map map;
+ CreatePropertyMap( actor, map );
+
+ DALI_TEST_CHECK( !map.empty() );
+ Property::Value value( map );
+ DALI_TEST_CHECK( value.HasKey( "size" ) );
+ DALI_TEST_EQUALS( value.GetValue( "size" ).Get< Vector3 >(), Vector3::ONE, TEST_LOCATION );
+ DALI_TEST_CHECK( value.HasKey( "position" ) );
+ DALI_TEST_EQUALS( value.GetValue( "position" ).Get< Vector3 >(), Vector3::XAXIS, TEST_LOCATION );
+ DALI_TEST_CHECK( value.HasKey( "scale" ) );
+ DALI_TEST_EQUALS( value.GetValue( "scale" ).Get< Vector3 >(), Vector3::ZAXIS, TEST_LOCATION );
+ DALI_TEST_CHECK( value.HasKey( "visible" ) );
+ DALI_TEST_EQUALS( value.GetValue( "visible" ).Get< bool >(), false, TEST_LOCATION );
+ DALI_TEST_CHECK( value.HasKey( "color" ) );
+ DALI_TEST_EQUALS( value.GetValue( "color" ).Get< Vector4 >(), Color::MAGENTA, TEST_LOCATION );
+ DALI_TEST_CHECK( value.HasKey( "name" ) );
+ DALI_TEST_EQUALS( value.GetValue( "name").Get< std::string >(), "MyActor", TEST_LOCATION );
+ DALI_TEST_CHECK( value.HasKey( "anchor-point" ) );
+ DALI_TEST_EQUALS( value.GetValue( "anchor-point" ).Get< Vector3 >(), AnchorPoint::CENTER_LEFT, TEST_LOCATION );
+ DALI_TEST_CHECK( value.HasKey( "parent-origin" ) );
+ DALI_TEST_EQUALS( value.GetValue( "parent-origin" ).Get< Vector3 >(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
+ DALI_TEST_CHECK( value.HasKey( "inherit-shader-effect" ) );
+ DALI_TEST_EQUALS( value.GetValue( "inherit-shader-effect" ).Get< bool >(), false, TEST_LOCATION );
+ DALI_TEST_CHECK( value.HasKey( "sensitive" ) );
+ DALI_TEST_EQUALS( value.GetValue( "sensitive" ).Get< bool >(), false, TEST_LOCATION );
+ DALI_TEST_CHECK( value.HasKey( "leave-required" ) );
+ DALI_TEST_EQUALS( value.GetValue( "leave-required" ).Get< bool >(), true, TEST_LOCATION );
+ DALI_TEST_CHECK( value.HasKey( "inherit-rotation" ) );
+ DALI_TEST_EQUALS( value.GetValue( "inherit-rotation" ).Get< bool >(), false, TEST_LOCATION );
+ DALI_TEST_CHECK( value.HasKey( "inherit-scale" ) );
+ DALI_TEST_EQUALS( value.GetValue( "inherit-scale" ).Get< bool >(), false, TEST_LOCATION );
+
+ Stage::GetCurrent().Remove( actor );
+ }
+
+ // ColorMode
+ TestEnumStrings< ColorMode >( "color-mode", application, COLOR_MODE_VALUES, COLOR_MODE_VALUES_COUNT, &Actor::SetColorMode );
+
+ // PositionInheritanceMode
+ TestEnumStrings< PositionInheritanceMode >( "position-inheritance", application, POSITION_INHERITANCE_MODE_VALUES, POSITION_INHERITANCE_MODE_VALUES_COUNT, &Actor::SetPositionInheritanceMode );
+
+ // DrawMode
+ TestEnumStrings< DrawMode::Type >( "draw-mode", application, DRAW_MODE_VALUES, DRAW_MODE_VALUES_COUNT, &Actor::SetDrawMode );
+
+ // Children
+ {
+ Actor actor = Actor::New();
+ Actor child = ImageActor::New();
+ Actor grandChild = TextActor::New();
+ Actor grandChild2 = LightActor::New();
+ actor.Add( child );
+ child.Add( grandChild );
+ child.Add( grandChild2 );
+
+ Stage::GetCurrent().Add( actor );
+ application.SendNotification();
+ application.Render();
+
+ Property::Map map;
+ CreatePropertyMap( actor, map );
+ DALI_TEST_CHECK( !map.empty() );
+
+ Property::Value value( map );
+ DALI_TEST_CHECK( value.HasKey( "type" ) );
+ DALI_TEST_EQUALS( value.GetValue( "type" ).Get< std::string >(), "Actor", TEST_LOCATION );
+
+ DALI_TEST_CHECK( value.HasKey( "actors" ) );
+ Property::Array children( value.GetValue( "actors").Get< Property::Array >() );
+ DALI_TEST_CHECK( !children.empty() );
+ Property::Map childMap( children[0].Get< Property::Map >() );
+ DALI_TEST_CHECK( !childMap.empty() );
+ Property::Value childValue( childMap );
+ DALI_TEST_CHECK( childValue.HasKey( "type" ) );
+ DALI_TEST_EQUALS( childValue.GetValue( "type" ).Get< std::string >(), "ImageActor", TEST_LOCATION );
+
+ DALI_TEST_CHECK( childValue.HasKey( "actors" ) );
+ Property::Array grandChildren( childValue.GetValue( "actors").Get< Property::Array >() );
+ DALI_TEST_CHECK( grandChildren.size() == 2u );
+
+ Property::Map grandChildMap( grandChildren[0].Get< Property::Map >() );
+ DALI_TEST_CHECK( !grandChildMap.empty() );
+ Property::Value grandChildValue( grandChildMap );
+ DALI_TEST_CHECK( grandChildValue.HasKey( "type" ) );
+ DALI_TEST_EQUALS( grandChildValue.GetValue( "type" ).Get< std::string >(), "TextActor", TEST_LOCATION );
+
+ Property::Map grandChild2Map( grandChildren[1].Get< Property::Map >() );
+ DALI_TEST_CHECK( !grandChild2Map.empty() );
+ Property::Value grandChild2Value( grandChild2Map );
+ DALI_TEST_CHECK( grandChild2Value.HasKey( "type" ) );
+ DALI_TEST_EQUALS( grandChild2Value.GetValue( "type" ).Get< std::string >(), "LightActor", TEST_LOCATION );
+
+ Stage::GetCurrent().Remove( actor );
+ }
+}
+
+void UtcDaliScriptingCreatePropertyMapImage()
+{
+ TestApplication application;
+
+ // Empty
+ {
+ Image image;
+ Property::Map map;
+ CreatePropertyMap( image, map );
+ DALI_TEST_CHECK( map.empty() );
+ }
+
+ // Default
+ {
+ Image image = Image::New( "MY_PATH" );
+
+ Property::Map map;
+ CreatePropertyMap( image, map );
+ DALI_TEST_CHECK( !map.empty() );
+
+ Property::Value value( map );
+ DALI_TEST_CHECK( value.HasKey( "type" ) );
+ DALI_TEST_EQUALS( value.GetValue( "type" ).Get< std::string >(), "Image", TEST_LOCATION );
+ DALI_TEST_CHECK( value.HasKey( "filename" ) );
+ DALI_TEST_EQUALS( value.GetValue( "filename" ).Get< std::string >(), "MY_PATH", TEST_LOCATION );
+ DALI_TEST_CHECK( value.HasKey( "load-policy") );
+ DALI_TEST_EQUALS( value.GetValue( "load-policy" ).Get< std::string >(), "IMMEDIATE", TEST_LOCATION );
+ DALI_TEST_CHECK( value.HasKey( "release-policy") );
+ DALI_TEST_EQUALS( value.GetValue( "release-policy" ).Get< std::string >(), "NEVER", TEST_LOCATION );
+ DALI_TEST_CHECK( value.HasKey( "pixel-format") );
+ DALI_TEST_EQUALS( value.GetValue( "pixel-format" ).Get< std::string >(), "RGBA8888", TEST_LOCATION );
+ DALI_TEST_CHECK( value.HasKey( "scaling-mode") );
+ DALI_TEST_EQUALS( value.GetValue( "scaling-mode" ).Get< std::string >(), "SHRINK_TO_FIT", TEST_LOCATION );
+ DALI_TEST_CHECK( value.HasKey( "crop" ) );
+ DALI_TEST_EQUALS( value.GetValue( "crop" ).Get< Vector4 >(), Vector4( 0.0f, 0.0f, 1.0f, 1.0f ), TEST_LOCATION );
+ DALI_TEST_CHECK( !value.HasKey( "width" ) );
+ DALI_TEST_CHECK( !value.HasKey( "height" ) );
+ }
+
+ // Change values
+ {
+ ImageAttributes attributes;
+ attributes.SetPixelFormat( Pixel::A8 );
+ attributes.SetScalingMode( ImageAttributes::FitWidth );
+ attributes.SetCrop( Rect< float >( 0.5f, 0.2f, 0.2f, 0.4f ) );
+ attributes.SetSize( 300, 400 );
+ Image image = Image::New( "MY_PATH", attributes, Image::OnDemand, Image::Unused );
+
+ Property::Map map;
+ CreatePropertyMap( image, map );
+ DALI_TEST_CHECK( !map.empty() );
+
+ Property::Value value( map );
+ DALI_TEST_CHECK( value.HasKey( "type" ) );
+ DALI_TEST_EQUALS( value.GetValue( "type" ).Get< std::string >(), "Image", TEST_LOCATION );
+ DALI_TEST_CHECK( value.HasKey( "filename" ) );
+ DALI_TEST_EQUALS( value.GetValue( "filename" ).Get< std::string >(), "MY_PATH", TEST_LOCATION );
+ DALI_TEST_CHECK( value.HasKey( "load-policy") );
+ DALI_TEST_EQUALS( value.GetValue( "load-policy" ).Get< std::string >(), "ON_DEMAND", TEST_LOCATION );
+ DALI_TEST_CHECK( value.HasKey( "release-policy") );
+ DALI_TEST_EQUALS( value.GetValue( "release-policy" ).Get< std::string >(), "UNUSED", TEST_LOCATION );
+ DALI_TEST_CHECK( value.HasKey( "pixel-format") );
+ DALI_TEST_EQUALS( value.GetValue( "pixel-format" ).Get< std::string >(), "A8", TEST_LOCATION );
+ DALI_TEST_CHECK( value.HasKey( "scaling-mode") );
+ DALI_TEST_EQUALS( value.GetValue( "scaling-mode" ).Get< std::string >(), "FIT_WIDTH", TEST_LOCATION );
+ DALI_TEST_CHECK( value.HasKey( "crop" ) );
+ DALI_TEST_EQUALS( value.GetValue( "crop" ).Get< Vector4 >(), Vector4( 0.5f, 0.2f, 0.2f, 0.4f ), TEST_LOCATION );
+ DALI_TEST_CHECK( value.HasKey( "width" ) );
+ DALI_TEST_EQUALS( value.GetValue( "width" ).Get< int >(), 300, TEST_LOCATION );
+ DALI_TEST_CHECK( value.HasKey( "height" ) );
+ DALI_TEST_EQUALS( value.GetValue( "height" ).Get< int >(), 400, TEST_LOCATION );
+ }
+
+ // BitmapImage
+ {
+ Image image = BitmapImage::New( 200, 300, Pixel::RGBA8888 );
+ Property::Map map;
+ CreatePropertyMap( image, map );
+ Property::Value value( map );
+ DALI_TEST_CHECK( value.HasKey( "type" ) );
+ DALI_TEST_EQUALS( value.GetValue( "type" ).Get< std::string >(), "BitmapImage", TEST_LOCATION );
+ }
+
+ // FrameBufferImage
+ {
+ Image image = FrameBufferImage::New( 200, 300, Pixel::RGBA8888 );
+ Property::Map map;
+ CreatePropertyMap( image, map );
+ Property::Value value( map );
+ DALI_TEST_CHECK( value.HasKey( "type" ) );
+ DALI_TEST_EQUALS( value.GetValue( "type" ).Get< std::string >(), "FrameBufferImage", TEST_LOCATION );
+ }
+}
^signals
^text
^type-registry
+ ^scripting
actors
:include:/dali-test-suite/actors/tslist
common
:include:/dali-test-suite/common/tslist
+scripting
+ :include:/dali-test-suite/scripting/tslist
+
##### INTERNAL Tests #####
INTERNAL
- :include:/dali-internal-test-suite/resource-manager/tslist
- :include:/dali-internal-test-suite/text/tslist
- :include:/dali-internal-test-suite/material/tslist
- :include:/dali-internal-test-suite/image-factory/tslist
+ ^resource-manager
+ ^internal-text
+ ^internal-material
+ ^image-factory
resource-manager
:include:/dali-internal-test-suite/resource-manager/tslist
* <h3>Key Events:</h3>
*
* Key events are received by an actor once set to grab key events, only one actor can be set as focused.
+ *
+ * @nosubgrouping
*/
class DALI_IMPORT_API Actor : public Constrainable
{
typedef SignalV2< void (Actor) > OnStageSignalV2; ///< Stage connection signal type
typedef SignalV2< void (Actor) > OffStageSignalV2; ///< Stage disconnection signal type
- // Default Properties
- static const Property::Index PARENT_ORIGIN; ///< name "parent-origin", type VECTOR3
- static const Property::Index PARENT_ORIGIN_X; ///< name "parent-origin-x", type FLOAT
- static const Property::Index PARENT_ORIGIN_Y; ///< name "parent-origin-y", type FLOAT
- static const Property::Index PARENT_ORIGIN_Z; ///< name "parent-origin-z", type FLOAT
- static const Property::Index ANCHOR_POINT; ///< name "anchor-point", type VECTOR3
- static const Property::Index ANCHOR_POINT_X; ///< name "anchor-point-x", type FLOAT
- static const Property::Index ANCHOR_POINT_Y; ///< name "anchor-point-y", type FLOAT
- static const Property::Index ANCHOR_POINT_Z; ///< name "anchor-point-z", type FLOAT
- static const Property::Index SIZE; ///< name "size", type VECTOR3
- static const Property::Index SIZE_WIDTH; ///< name "size-width", type FLOAT
- static const Property::Index SIZE_HEIGHT; ///< name "size-height", type FLOAT
- static const Property::Index SIZE_DEPTH; ///< name "size-depth", type FLOAT
- static const Property::Index POSITION; ///< name "position", type VECTOR3
- static const Property::Index POSITION_X; ///< name "position-x", type FLOAT
- static const Property::Index POSITION_Y; ///< name "position-y", type FLOAT
- static const Property::Index POSITION_Z; ///< name "position-z", type FLOAT
- static const Property::Index WORLD_POSITION; ///< name "world-position", type VECTOR3 (read-only)
- static const Property::Index WORLD_POSITION_X; ///< name "world-position-x", type FLOAT (read-only)
- static const Property::Index WORLD_POSITION_Y; ///< name "world-position-y", type FLOAT (read-only)
- static const Property::Index WORLD_POSITION_Z; ///< name "world-position-z", type FLOAT (read-only)
- static const Property::Index ROTATION; ///< name "rotation", type ROTATION
- static const Property::Index WORLD_ROTATION; ///< name "world-rotation", type ROTATION (read-only)
- static const Property::Index SCALE; ///< name "scale", type VECTOR3
- static const Property::Index SCALE_X; ///< name "scale-x", type FLOAT
- static const Property::Index SCALE_Y; ///< name "scale-y", type FLOAT
- static const Property::Index SCALE_Z; ///< name "scale-z", type FLOAT
- static const Property::Index WORLD_SCALE; ///< name "world-scale", type VECTOR3 (read-only)
- static const Property::Index VISIBLE; ///< name "visible", type BOOLEAN
- static const Property::Index COLOR; ///< name "color", type VECTOR4
- static const Property::Index COLOR_RED; ///< name "color-red", type FLOAT
- static const Property::Index COLOR_GREEN; ///< name "color-green", type FLOAT
- static const Property::Index COLOR_BLUE; ///< name "color-blue", type FLOAT
- static const Property::Index COLOR_ALPHA; ///< name "color-alpha", type FLOAT
- static const Property::Index WORLD_COLOR; ///< name "world-color", type VECTOR4 (read-only)
- static const Property::Index WORLD_MATRIX; ///< name "world-matrix", type MATRIX (read-only)
- static const Property::Index NAME; ///< name "name", type STRING
-
- // Signal Names
- static const char* const SIGNAL_TOUCHED; ///< Touched signal name
- static const char* const SIGNAL_MOUSE_WHEEL_EVENT;///< Mouse wheel signal name
- static const char* const SIGNAL_SET_SIZE; ///< SetSize signal name
- static const char* const SIGNAL_ON_STAGE; ///< Stage connection signal name
- static const char* const SIGNAL_OFF_STAGE; ///< Stage disconnection signal name
-
-
- //Action Names
- static const char* const ACTION_SHOW; ///< Show action name
- static const char* const ACTION_HIDE; ///< Hide action name
-
+ /// @name Properties
+ /** @{ */
+ static const Property::Index PARENT_ORIGIN; ///< name "parent-origin", type VECTOR3
+ static const Property::Index PARENT_ORIGIN_X; ///< name "parent-origin-x", type FLOAT
+ static const Property::Index PARENT_ORIGIN_Y; ///< name "parent-origin-y", type FLOAT
+ static const Property::Index PARENT_ORIGIN_Z; ///< name "parent-origin-z", type FLOAT
+ static const Property::Index ANCHOR_POINT; ///< name "anchor-point", type VECTOR3
+ static const Property::Index ANCHOR_POINT_X; ///< name "anchor-point-x", type FLOAT
+ static const Property::Index ANCHOR_POINT_Y; ///< name "anchor-point-y", type FLOAT
+ static const Property::Index ANCHOR_POINT_Z; ///< name "anchor-point-z", type FLOAT
+ static const Property::Index SIZE; ///< name "size", type VECTOR3
+ static const Property::Index SIZE_WIDTH; ///< name "size-width", type FLOAT
+ static const Property::Index SIZE_HEIGHT; ///< name "size-height", type FLOAT
+ static const Property::Index SIZE_DEPTH; ///< name "size-depth", type FLOAT
+ static const Property::Index POSITION; ///< name "position", type VECTOR3
+ static const Property::Index POSITION_X; ///< name "position-x", type FLOAT
+ static const Property::Index POSITION_Y; ///< name "position-y", type FLOAT
+ static const Property::Index POSITION_Z; ///< name "position-z", type FLOAT
+ static const Property::Index WORLD_POSITION; ///< name "world-position", type VECTOR3 (read-only)
+ static const Property::Index WORLD_POSITION_X; ///< name "world-position-x", type FLOAT (read-only)
+ static const Property::Index WORLD_POSITION_Y; ///< name "world-position-y", type FLOAT (read-only)
+ static const Property::Index WORLD_POSITION_Z; ///< name "world-position-z", type FLOAT (read-only)
+ static const Property::Index ROTATION; ///< name "rotation", type ROTATION
+ static const Property::Index WORLD_ROTATION; ///< name "world-rotation", type ROTATION (read-only)
+ static const Property::Index SCALE; ///< name "scale", type VECTOR3
+ static const Property::Index SCALE_X; ///< name "scale-x", type FLOAT
+ static const Property::Index SCALE_Y; ///< name "scale-y", type FLOAT
+ static const Property::Index SCALE_Z; ///< name "scale-z", type FLOAT
+ static const Property::Index WORLD_SCALE; ///< name "world-scale", type VECTOR3 (read-only)
+ static const Property::Index VISIBLE; ///< name "visible", type BOOLEAN
+ static const Property::Index COLOR; ///< name "color", type VECTOR4
+ static const Property::Index COLOR_RED; ///< name "color-red", type FLOAT
+ static const Property::Index COLOR_GREEN; ///< name "color-green", type FLOAT
+ static const Property::Index COLOR_BLUE; ///< name "color-blue", type FLOAT
+ static const Property::Index COLOR_ALPHA; ///< name "color-alpha", type FLOAT
+ static const Property::Index WORLD_COLOR; ///< name "world-color", type VECTOR4 (read-only)
+ static const Property::Index WORLD_MATRIX; ///< name "world-matrix", type MATRIX (read-only)
+ static const Property::Index NAME; ///< name "name", type STRING
+ static const Property::Index SENSITIVE; ///< name "sensitive", type BOOLEAN
+ static const Property::Index LEAVE_REQUIRED; ///< name "leave-required", type BOOLEAN
+ static const Property::Index INHERIT_SHADER_EFFECT; ///< name "inherit-shader-effect", type BOOLEAN
+ static const Property::Index INHERIT_ROTATION; ///< name "inherit-rotation", type BOOLEAN
+ static const Property::Index INHERIT_SCALE; ///< name "inherit-scale", type BOOLEAN
+ static const Property::Index COLOR_MODE; ///< name "color-mode", type STRING
+ static const Property::Index POSITION_INHERITANCE; ///< name "position-inheritance", type STRING
+ static const Property::Index DRAW_MODE; ///< name "draw-mode", type STRING
+ /** @} */
+
+ /// @name Signals
+ /** @{ */
+ static const char* const SIGNAL_TOUCHED; ///< name "touched", @see TouchedSignal()
+ static const char* const SIGNAL_MOUSE_WHEEL_EVENT; ///< name "mouse-wheel-event", @see MouseWheelEventSignal()
+ static const char* const SIGNAL_SET_SIZE; ///< name "set-size", @see SetSizeSignal()
+ static const char* const SIGNAL_ON_STAGE; ///< name "on-stage", @see OnStageSignal()
+ static const char* const SIGNAL_OFF_STAGE; ///< name "off-stage", @see OffStageSignal()
+ /** @} */
+
+ /// @name Actions
+ /** @{ */
+ static const char* const ACTION_SHOW; ///< name "show", @see SetVisible()
+ static const char* const ACTION_HIDE; ///< name "hide", @see SetVisible()
+ /** @} */
// Creation
/**
* @brief Query the name of a property.
*
- * @pre Property::INVALID_INDEX < index < GetPropertyCount().
* @param [in] index The index of the property.
* @return The name of the property.
*/
/**
* @brief Query whether a property can be set using SetProperty().
*
- * @pre Property::INVALID_INDEX < index < GetPropertyCount().
+ * @pre Property::INVALID_INDEX < index.
* @param [in] index The index of the property.
* @return True if the property is writable.
*/
/**
* @brief Query whether a writable property can be the target of an animation or constraint.
*
- * @pre Property::INVALID_INDEX < index < GetPropertyCount().
* @param [in] index The index of the property.
* @return True if the property is animatable.
*/
bool IsPropertyAnimatable(Property::Index index) const;
/**
+ * @brief Query whether a property can be used as in input to a constraint.
+ *
+ * @param [in] index The index of the property.
+ * @return True if the property can be used as a constraint input.
+ */
+ bool IsPropertyAConstraintInput(Property::Index index) const;
+
+ /**
* @brief Query the type of a property.
*
- * @pre Property::INVALID_INDEX < index < GetPropertyCount().
* @param [in] index The index of the property.
* @return The type of the property.
*/
* @brief Set the value of an existing property.
*
* @pre Handle::IsPropertyWritable(index) returns true.
- * @pre Property::INVALID_INDEX < index < GetPropertyCount().
* @pre The property types match i.e. propertyValue.GetType() is equal to GetPropertyType(index).
* @param [in] index The index of the property.
* @param [in] propertyValue The new value of the property.
/**
* @brief Retrieve a property value.
*
- * @pre Property::INVALID_INDEX < index < GetPropertyCount().
* @param [in] index The index of the property.
* @return The property value.
*/
/**
* @brief Convenience function for obtaining a property of a known type.
*
- * @pre Property::INVALID_INDEX < index < GetPropertyCount().
* @pre The property types match i.e. PropertyTypes::Get<T>() is equal to GetPropertyType(index).
* @param [in] index The index of the property.
* @return The property value.
/**
* @brief Add a property notification to this object.
*
- * @pre Property::INVALID_INDEX < index < GetPropertyCount().
* @param [in] index The index of the property.
* @param [in] condition The notification will be triggered when this condition is satisfied.
*
/**
* @brief Add a property notification to this object.
*
- * @pre Property::INVALID_INDEX < index < GetPropertyCount().
* @param [in] index The index of the property.
* @param [in] componentIndex Index to the component of a complex property such as a Vector
* @param [in] condition The notification will be triggered when this condition is satisfied.
{
/**
- * @brief PropertyRegistration indices should be between this range.
+ * @brief These are the property index ranges.
*
* Enumerations are being used here rather than static constants so that switch statements can be
* used to compare property indices.
*/
-enum PropertyRegistrationIndices
+enum
{
PROPERTY_REGISTRATION_START_INDEX = 10000000, ///< The index when registering a property should start from this number
- PROPERTY_REGISTRATION_MAX_INDEX = 19999999 ///< The maximum index supported when registering a property
+ PROPERTY_REGISTRATION_MAX_INDEX = 19999999, ///< The maximum index supported when registering a property
+ PROPERTY_CUSTOM_START_INDEX = 50000000, ///< The index at which custom properties start
};
} // namespace Dali
#include <dali/public-api/math/vector3.h>
#include <dali/public-api/math/radian.h>
#include <dali/public-api/object/type-registry.h>
+#include <dali/public-api/scripting/scripting.h>
#include <dali/internal/common/internal-constants.h>
#include <dali/internal/event/render-tasks/render-task-impl.h>
namespace Dali
{
-const Property::Index Actor::PARENT_ORIGIN = 0;
-const Property::Index Actor::PARENT_ORIGIN_X = 1;
-const Property::Index Actor::PARENT_ORIGIN_Y = 2;
-const Property::Index Actor::PARENT_ORIGIN_Z = 3;
-const Property::Index Actor::ANCHOR_POINT = 4;
-const Property::Index Actor::ANCHOR_POINT_X = 5;
-const Property::Index Actor::ANCHOR_POINT_Y = 6;
-const Property::Index Actor::ANCHOR_POINT_Z = 7;
-const Property::Index Actor::SIZE = 8;
-const Property::Index Actor::SIZE_WIDTH = 9;
-const Property::Index Actor::SIZE_HEIGHT = 10;
-const Property::Index Actor::SIZE_DEPTH = 11;
-const Property::Index Actor::POSITION = 12;
-const Property::Index Actor::POSITION_X = 13;
-const Property::Index Actor::POSITION_Y = 14;
-const Property::Index Actor::POSITION_Z = 15;
-const Property::Index Actor::WORLD_POSITION = 16;
-const Property::Index Actor::WORLD_POSITION_X = 17;
-const Property::Index Actor::WORLD_POSITION_Y = 18;
-const Property::Index Actor::WORLD_POSITION_Z = 19;
-const Property::Index Actor::ROTATION = 20;
-const Property::Index Actor::WORLD_ROTATION = 21;
-const Property::Index Actor::SCALE = 22;
-const Property::Index Actor::SCALE_X = 23;
-const Property::Index Actor::SCALE_Y = 24;
-const Property::Index Actor::SCALE_Z = 25;
-const Property::Index Actor::WORLD_SCALE = 26;
-const Property::Index Actor::VISIBLE = 27;
-const Property::Index Actor::COLOR = 28;
-const Property::Index Actor::COLOR_RED = 29;
-const Property::Index Actor::COLOR_GREEN = 30;
-const Property::Index Actor::COLOR_BLUE = 31;
-const Property::Index Actor::COLOR_ALPHA = 32;
-const Property::Index Actor::WORLD_COLOR = 33;
-const Property::Index Actor::WORLD_MATRIX = 34;
-const Property::Index Actor::NAME = 35;
+const Property::Index Actor::PARENT_ORIGIN = 0;
+const Property::Index Actor::PARENT_ORIGIN_X = 1;
+const Property::Index Actor::PARENT_ORIGIN_Y = 2;
+const Property::Index Actor::PARENT_ORIGIN_Z = 3;
+const Property::Index Actor::ANCHOR_POINT = 4;
+const Property::Index Actor::ANCHOR_POINT_X = 5;
+const Property::Index Actor::ANCHOR_POINT_Y = 6;
+const Property::Index Actor::ANCHOR_POINT_Z = 7;
+const Property::Index Actor::SIZE = 8;
+const Property::Index Actor::SIZE_WIDTH = 9;
+const Property::Index Actor::SIZE_HEIGHT = 10;
+const Property::Index Actor::SIZE_DEPTH = 11;
+const Property::Index Actor::POSITION = 12;
+const Property::Index Actor::POSITION_X = 13;
+const Property::Index Actor::POSITION_Y = 14;
+const Property::Index Actor::POSITION_Z = 15;
+const Property::Index Actor::WORLD_POSITION = 16;
+const Property::Index Actor::WORLD_POSITION_X = 17;
+const Property::Index Actor::WORLD_POSITION_Y = 18;
+const Property::Index Actor::WORLD_POSITION_Z = 19;
+const Property::Index Actor::ROTATION = 20;
+const Property::Index Actor::WORLD_ROTATION = 21;
+const Property::Index Actor::SCALE = 22;
+const Property::Index Actor::SCALE_X = 23;
+const Property::Index Actor::SCALE_Y = 24;
+const Property::Index Actor::SCALE_Z = 25;
+const Property::Index Actor::WORLD_SCALE = 26;
+const Property::Index Actor::VISIBLE = 27;
+const Property::Index Actor::COLOR = 28;
+const Property::Index Actor::COLOR_RED = 29;
+const Property::Index Actor::COLOR_GREEN = 30;
+const Property::Index Actor::COLOR_BLUE = 31;
+const Property::Index Actor::COLOR_ALPHA = 32;
+const Property::Index Actor::WORLD_COLOR = 33;
+const Property::Index Actor::WORLD_MATRIX = 34;
+const Property::Index Actor::NAME = 35;
+const Property::Index Actor::SENSITIVE = 36;
+const Property::Index Actor::LEAVE_REQUIRED = 37;
+const Property::Index Actor::INHERIT_SHADER_EFFECT = 38;
+const Property::Index Actor::INHERIT_ROTATION = 39;
+const Property::Index Actor::INHERIT_SCALE = 40;
+const Property::Index Actor::COLOR_MODE = 41;
+const Property::Index Actor::POSITION_INHERITANCE = 42;
+const Property::Index Actor::DRAW_MODE = 43;
namespace // unnamed namespace
{
-/// An empty string returned for invalid property name lookups
-const std::string INVALID_PROPERTY_NAME;
-
/**
* We want to discourage the use of property strings (minimize string comparisons),
* particularly for the default properties.
*/
-const std::string DEFAULT_PROPERTY_NAMES[] =
-{
- "parent-origin",
- "parent-origin-x",
- "parent-origin-y",
- "parent-origin-z",
- "anchor-point",
- "anchor-point-x",
- "anchor-point-y",
- "anchor-point-z",
- "size",
- "size-width",
- "size-height",
- "size-depth",
- "position",
- "position-x",
- "position-y",
- "position-z",
- "world-position",
- "world-position-x",
- "world-position-y",
- "world-position-z",
- "rotation",
- "world-rotation",
- "scale",
- "scale-x",
- "scale-y",
- "scale-z",
- "world-scale",
- "visible",
- "color",
- "color-red",
- "color-green",
- "color-blue",
- "color-alpha",
- "world-color",
- "world-matrix",
- "name"
-};
-const int DEFAULT_PROPERTY_COUNT = sizeof( DEFAULT_PROPERTY_NAMES ) / sizeof( std::string );
-
-const Property::Type DEFAULT_PROPERTY_TYPES[DEFAULT_PROPERTY_COUNT] =
-{
- Property::VECTOR3, // PARENT_ORIGIN
- Property::FLOAT, // PARENT_ORIGIN_X
- Property::FLOAT, // PARENT_ORIGIN_Y
- Property::FLOAT, // PARENT_ORIGIN_Z
- Property::VECTOR3, // ANCHOR_POINT
- Property::FLOAT, // ANCHOR_POINT_X
- Property::FLOAT, // ANCHOR_POINT_Y
- Property::FLOAT, // ANCHOR_POINT_Z
- Property::VECTOR3, // SIZE
- Property::FLOAT, // SIZE_WIDTH
- Property::FLOAT, // SIZE_HEIGHT
- Property::FLOAT, // SIZE_DEPTH
- Property::VECTOR3, // POSITION
- Property::FLOAT, // POSITION_X
- Property::FLOAT, // POSITION_Y
- Property::FLOAT, // POSITION_Z
- Property::VECTOR3, // WORLD_POSITION
- Property::FLOAT, // WORLD_POSITION_X
- Property::FLOAT, // WORLD_POSITION_Y
- Property::FLOAT, // WORLD_POSITION_Z
- Property::ROTATION, // ROTATION
- Property::ROTATION, // WORLD_ROTATION
- Property::VECTOR3, // SCALE
- Property::FLOAT, // SCALE_X
- Property::FLOAT, // SCALE_Y
- Property::FLOAT, // SCALE_Z
- Property::VECTOR3, // WORLD_SCALE
- Property::BOOLEAN, // VISIBLE
- Property::VECTOR4, // COLOR
- Property::FLOAT, // COLOR_RED
- Property::FLOAT, // COLOR_GREEN
- Property::FLOAT, // COLOR_BLUE
- Property::FLOAT, // COLOR_ALPHA
- Property::VECTOR4, // WORLD_COLOR
- Property::MATRIX, // WORLD_MATRIX
- Property::STRING, // NAME
+const Internal::PropertyDetails DEFAULT_PROPERTY_DETAILS[] =
+{
+ // Name Type writable animatable constraint-input
+ { "parent-origin", Property::VECTOR3, true, false, true }, // PARENT_ORIGIN
+ { "parent-origin-x", Property::FLOAT, true, false, true }, // PARENT_ORIGIN_X
+ { "parent-origin-y", Property::FLOAT, true, false, true }, // PARENT_ORIGIN_Y
+ { "parent-origin-z", Property::FLOAT, true, false, true }, // PARENT_ORIGIN_Z
+ { "anchor-point", Property::VECTOR3, true, false, true }, // ANCHOR_POINT
+ { "anchor-point-x", Property::FLOAT, true, false, true }, // ANCHOR_POINT_X
+ { "anchor-point-y", Property::FLOAT, true, false, true }, // ANCHOR_POINT_Y
+ { "anchor-point-z", Property::FLOAT, true, false, true }, // ANCHOR_POINT_Z
+ { "size", Property::VECTOR3, true, true, true }, // SIZE
+ { "size-width", Property::FLOAT, true, true, true }, // SIZE_WIDTH
+ { "size-height", Property::FLOAT, true, true, true }, // SIZE_HEIGHT
+ { "size-depth", Property::FLOAT, true, true, true }, // SIZE_DEPTH
+ { "position", Property::VECTOR3, true, true, true }, // POSITION
+ { "position-x", Property::FLOAT, true, true, true }, // POSITION_X
+ { "position-y", Property::FLOAT, true, true, true }, // POSITION_Y
+ { "position-z", Property::FLOAT, true, true, true }, // POSITION_Z
+ { "world-position", Property::VECTOR3, false, false, true }, // WORLD_POSITION
+ { "world-position-x", Property::FLOAT, false, false, true }, // WORLD_POSITION_X
+ { "world-position-y", Property::FLOAT, false, false, true }, // WORLD_POSITION_Y
+ { "world-position-z", Property::FLOAT, false, false, true }, // WORLD_POSITION_Z
+ { "rotation", Property::ROTATION, true, true, true }, // ROTATION
+ { "world-rotation", Property::ROTATION, false, false, true }, // WORLD_ROTATION
+ { "scale", Property::VECTOR3, true, true, true }, // SCALE
+ { "scale-x", Property::FLOAT, true, true, true }, // SCALE_X
+ { "scale-y", Property::FLOAT, true, true, true }, // SCALE_Y
+ { "scale-z", Property::FLOAT, true, true, true }, // SCALE_Z
+ { "world-scale", Property::VECTOR3, false, false, true }, // WORLD_SCALE
+ { "visible", Property::BOOLEAN, true, true, true }, // VISIBLE
+ { "color", Property::VECTOR4, true, true, true }, // COLOR
+ { "color-red", Property::FLOAT, true, true, true }, // COLOR_RED
+ { "color-green", Property::FLOAT, true, true, true }, // COLOR_GREEN
+ { "color-blue", Property::FLOAT, true, true, true }, // COLOR_BLUE
+ { "color-alpha", Property::FLOAT, true, true, true }, // COLOR_ALPHA
+ { "world-color", Property::VECTOR4, false, false, true }, // WORLD_COLOR
+ { "world-matrix", Property::MATRIX, false, false, true }, // WORLD_MATRIX
+ { "name", Property::STRING, true, false, false }, // NAME
+ { "sensitive", Property::BOOLEAN, true, false, false }, // SENSITIVE
+ { "leave-required", Property::BOOLEAN, true, false, false }, // LEAVE_REQUIRED
+ { "inherit-shader-effect", Property::BOOLEAN, true, false, false }, // INHERIT_SHADER_EFFECT
+ { "inherit-rotation", Property::BOOLEAN, true, false, false }, // INHERIT_ROTATION
+ { "inherit-scale", Property::BOOLEAN, true, false, false }, // INHERIT_SCALE
+ { "color-mode", Property::STRING, true, false, false }, // COLOR_MODE
+ { "position-inheritance", Property::STRING, true, false, false }, // POSITION_INHERITANCE
+ { "draw-mode", Property::STRING, true, false, false }, // DRAW_MODE
};
+const int DEFAULT_PROPERTY_COUNT = sizeof( DEFAULT_PROPERTY_DETAILS ) / sizeof( Internal::PropertyDetails );
} // unnamed namespace
for (int i=0; i<DEFAULT_PROPERTY_COUNT; ++i)
{
- (*mDefaultPropertyLookup)[DEFAULT_PROPERTY_NAMES[i]] = i;
+ (*mDefaultPropertyLookup)[DEFAULT_PROPERTY_DETAILS[i].name] = i;
}
}
{
if( index < DEFAULT_PROPERTY_COUNT )
{
- return DEFAULT_PROPERTY_NAMES[index];
+ return DEFAULT_PROPERTY_DETAILS[index].name;
}
else
{
// index out of range..return empty string
- return INVALID_PROPERTY_NAME;
+ return String::EMPTY;
}
}
bool Actor::IsDefaultPropertyWritable(Property::Index index) const
{
- // World-properties are not writable
- return ( Dali::Actor::WORLD_POSITION != index &&
- Dali::Actor::WORLD_POSITION_X != index &&
- Dali::Actor::WORLD_POSITION_Y != index &&
- Dali::Actor::WORLD_POSITION_Z != index &&
- Dali::Actor::WORLD_ROTATION != index &&
- Dali::Actor::WORLD_SCALE != index &&
- Dali::Actor::WORLD_COLOR != index &&
- Dali::Actor::WORLD_MATRIX != index);
+ if( index < DEFAULT_PROPERTY_COUNT )
+ {
+ return DEFAULT_PROPERTY_DETAILS[index].writable;
+ }
+ else
+ {
+ return false;
+ }
}
bool Actor::IsDefaultPropertyAnimatable(Property::Index index) const
{
- // ParentOrigin, AnchorPoint & World-properties are not animatable
- return ( Dali::Actor::PARENT_ORIGIN != index &&
- Dali::Actor::PARENT_ORIGIN_X != index &&
- Dali::Actor::PARENT_ORIGIN_Y != index &&
- Dali::Actor::PARENT_ORIGIN_Z != index &&
- Dali::Actor::ANCHOR_POINT != index &&
- Dali::Actor::ANCHOR_POINT_X != index &&
- Dali::Actor::ANCHOR_POINT_Y != index &&
- Dali::Actor::ANCHOR_POINT_Z != index &&
- Dali::Actor::WORLD_POSITION != index &&
- Dali::Actor::WORLD_POSITION_X != index &&
- Dali::Actor::WORLD_POSITION_Y != index &&
- Dali::Actor::WORLD_POSITION_Z != index &&
- Dali::Actor::WORLD_ROTATION != index &&
- Dali::Actor::WORLD_SCALE != index &&
- Dali::Actor::WORLD_COLOR != index &&
- Dali::Actor::WORLD_MATRIX != index);
+ if( index < DEFAULT_PROPERTY_COUNT )
+ {
+ return DEFAULT_PROPERTY_DETAILS[index].animatable;
+ }
+ else
+ {
+ return false;
+ }
+}
+
+bool Actor::IsDefaultPropertyAConstraintInput( Property::Index index ) const
+{
+ if( index < DEFAULT_PROPERTY_COUNT )
+ {
+ return DEFAULT_PROPERTY_DETAILS[index].constraintInput;
+ }
+ else
+ {
+ return false;
+ }
}
Property::Type Actor::GetDefaultPropertyType(Property::Index index) const
{
if( index < DEFAULT_PROPERTY_COUNT )
{
- return DEFAULT_PROPERTY_TYPES[index];
+ return DEFAULT_PROPERTY_DETAILS[index].type;
}
else
{
break;
}
+ case Dali::Actor::SENSITIVE:
+ {
+ SetSensitive( property.Get<bool>() );
+ break;
+ }
+
+ case Dali::Actor::LEAVE_REQUIRED:
+ {
+ SetLeaveRequired( property.Get<bool>() );
+ break;
+ }
+
+ case Dali::Actor::INHERIT_SHADER_EFFECT:
+ {
+ SetInheritShaderEffect( property.Get<bool>() );
+ break;
+ }
+
+ case Dali::Actor::INHERIT_ROTATION:
+ {
+ SetInheritRotation( property.Get<bool>() );
+ break;
+ }
+
+ case Dali::Actor::INHERIT_SCALE:
+ {
+ SetInheritScale( property.Get<bool>() );
+ break;
+ }
+
+ case Dali::Actor::COLOR_MODE:
+ {
+ SetColorMode( Scripting::GetColorMode( property.Get<std::string>() ) );
+ break;
+ }
+
+ case Dali::Actor::POSITION_INHERITANCE:
+ {
+ SetPositionInheritanceMode( Scripting::GetPositionInheritanceMode( property.Get<std::string>() ) );
+ break;
+ }
+
+ case Dali::Actor::DRAW_MODE:
+ {
+ SetDrawMode( Scripting::GetDrawMode( property.Get<std::string>() ) );
+ break;
+ }
+
default:
{
DALI_ASSERT_ALWAYS(false && "Actor::Property is out of bounds"); // should not come here
break;
}
+ case Dali::Actor::SENSITIVE:
+ {
+ value = IsSensitive();
+ break;
+ }
+
+ case Dali::Actor::LEAVE_REQUIRED:
+ {
+ value = GetLeaveRequired();
+ break;
+ }
+
+ case Dali::Actor::INHERIT_SHADER_EFFECT:
+ {
+ value = GetInheritShaderEffect();
+ break;
+ }
+
+ case Dali::Actor::INHERIT_ROTATION:
+ {
+ value = IsRotationInherited();
+ break;
+ }
+
+ case Dali::Actor::INHERIT_SCALE:
+ {
+ value = IsScaleInherited();
+ break;
+ }
+
+ case Dali::Actor::COLOR_MODE:
+ {
+ value = Scripting::GetColorMode( GetColorMode() );
+ break;
+ }
+
+ case Dali::Actor::POSITION_INHERITANCE:
+ {
+ value = Scripting::GetPositionInheritanceMode( GetPositionInheritanceMode() );
+ break;
+ }
+
+ case Dali::Actor::DRAW_MODE:
+ {
+ value = Scripting::GetDrawMode( GetDrawMode() );
+ break;
+ }
+
default:
{
DALI_ASSERT_ALWAYS(false && "Actor Property index invalid" ); // should not come here
virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
/**
+ * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyAConstraintInput()
+ */
+ virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
+
+ /**
* @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyType()
*/
virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
static DefaultPropertyLookup* mDefaultPropertyLookup;
};
+/**
+ * @brief Structure for setting up default properties and their details.
+ */
+struct PropertyDetails
+{
+ std::string name; ///< The name of the property.
+ Property::Type type; ///< The property type.
+ bool writable:1; ///< Whether the property is writable
+ bool animatable:1; ///< Whether the property is animatable.
+ bool constraintInput:1; ///< Whether the property can be used as an input to a constraint.
+};
+
} // namespace Internal
// Helpers for public-api forwarding methods
namespace Dali
{
-const Property::Index CameraActor::TYPE = DEFAULT_ACTOR_PROPERTY_MAX_COUNT;
-const Property::Index CameraActor::PROJECTION_MODE = DEFAULT_ACTOR_PROPERTY_MAX_COUNT + 1;
-const Property::Index CameraActor::FIELD_OF_VIEW = DEFAULT_ACTOR_PROPERTY_MAX_COUNT + 2;
-const Property::Index CameraActor::ASPECT_RATIO = DEFAULT_ACTOR_PROPERTY_MAX_COUNT + 3;
-const Property::Index CameraActor::NEAR_PLANE_DISTANCE = DEFAULT_ACTOR_PROPERTY_MAX_COUNT + 4;
-const Property::Index CameraActor::FAR_PLANE_DISTANCE = DEFAULT_ACTOR_PROPERTY_MAX_COUNT + 5;
-const Property::Index CameraActor::LEFT_PLANE_DISTANCE = DEFAULT_ACTOR_PROPERTY_MAX_COUNT + 6;
-const Property::Index CameraActor::RIGHT_PLANE_DISTANCE = DEFAULT_ACTOR_PROPERTY_MAX_COUNT + 7;
-const Property::Index CameraActor::TOP_PLANE_DISTANCE = DEFAULT_ACTOR_PROPERTY_MAX_COUNT + 8;
-const Property::Index CameraActor::BOTTOM_PLANE_DISTANCE = DEFAULT_ACTOR_PROPERTY_MAX_COUNT + 9;
-const Property::Index CameraActor::TARGET_POSITION = DEFAULT_ACTOR_PROPERTY_MAX_COUNT + 10;
-const Property::Index CameraActor::PROJECTION_MATRIX = DEFAULT_ACTOR_PROPERTY_MAX_COUNT + 11;
-const Property::Index CameraActor::VIEW_MATRIX = DEFAULT_ACTOR_PROPERTY_MAX_COUNT + 12;
-const Property::Index CameraActor::INVERT_Y_AXIS = DEFAULT_ACTOR_PROPERTY_MAX_COUNT + 13;
+const Property::Index CameraActor::TYPE = Internal::DEFAULT_ACTOR_PROPERTY_MAX_COUNT;
+const Property::Index CameraActor::PROJECTION_MODE = Internal::DEFAULT_ACTOR_PROPERTY_MAX_COUNT + 1;
+const Property::Index CameraActor::FIELD_OF_VIEW = Internal::DEFAULT_ACTOR_PROPERTY_MAX_COUNT + 2;
+const Property::Index CameraActor::ASPECT_RATIO = Internal::DEFAULT_ACTOR_PROPERTY_MAX_COUNT + 3;
+const Property::Index CameraActor::NEAR_PLANE_DISTANCE = Internal::DEFAULT_ACTOR_PROPERTY_MAX_COUNT + 4;
+const Property::Index CameraActor::FAR_PLANE_DISTANCE = Internal::DEFAULT_ACTOR_PROPERTY_MAX_COUNT + 5;
+const Property::Index CameraActor::LEFT_PLANE_DISTANCE = Internal::DEFAULT_ACTOR_PROPERTY_MAX_COUNT + 6;
+const Property::Index CameraActor::RIGHT_PLANE_DISTANCE = Internal::DEFAULT_ACTOR_PROPERTY_MAX_COUNT + 7;
+const Property::Index CameraActor::TOP_PLANE_DISTANCE = Internal::DEFAULT_ACTOR_PROPERTY_MAX_COUNT + 8;
+const Property::Index CameraActor::BOTTOM_PLANE_DISTANCE = Internal::DEFAULT_ACTOR_PROPERTY_MAX_COUNT + 9;
+const Property::Index CameraActor::TARGET_POSITION = Internal::DEFAULT_ACTOR_PROPERTY_MAX_COUNT + 10;
+const Property::Index CameraActor::PROJECTION_MATRIX = Internal::DEFAULT_ACTOR_PROPERTY_MAX_COUNT + 11;
+const Property::Index CameraActor::VIEW_MATRIX = Internal::DEFAULT_ACTOR_PROPERTY_MAX_COUNT + 12;
+const Property::Index CameraActor::INVERT_Y_AXIS = Internal::DEFAULT_ACTOR_PROPERTY_MAX_COUNT + 13;
namespace Internal
{
return animatable;
}
+bool CameraActor::IsDefaultPropertyAConstraintInput( Property::Index index ) const
+{
+ bool animatable = true; // Our properties can be used as inputs to constraints.
+
+ if( index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT )
+ {
+ animatable = Actor::IsDefaultPropertyAConstraintInput(index);
+ }
+ return animatable;
+}
+
Property::Type CameraActor::GetDefaultPropertyType( Property::Index index ) const
{
if(index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT)
virtual bool IsDefaultPropertyAnimatable( Property::Index index ) const;
/**
+ * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyAConstraintInput()
+ */
+ virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
+
+ /**
* copydoc Dali::Internal::ProxyObject
*/
virtual Property::Type GetDefaultPropertyType( Property::Index index ) const;
namespace Dali
{
-const Property::Index ImageActor::PIXEL_AREA = DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT;
-const Property::Index ImageActor::FADE_IN = DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 1;
-const Property::Index ImageActor::FADE_IN_DURATION = DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 2;
-const Property::Index ImageActor::STYLE = DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 3;
-const Property::Index ImageActor::BORDER = DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 4;
-const Property::Index ImageActor::IMAGE = DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 5;
+const Property::Index ImageActor::PIXEL_AREA = Internal::DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT;
+const Property::Index ImageActor::FADE_IN = Internal::DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 1;
+const Property::Index ImageActor::FADE_IN_DURATION = Internal::DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 2;
+const Property::Index ImageActor::STYLE = Internal::DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 3;
+const Property::Index ImageActor::BORDER = Internal::DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 4;
+const Property::Index ImageActor::IMAGE = Internal::DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 5;
namespace Internal
{
ImageActor::Style StyleEnum(const std::string &s)
{
- if(s == "NINE_PATCH")
+ if(s == "STYLE_NINE_PATCH")
{
return Dali::ImageActor::STYLE_NINE_PATCH;
}
{
if(style == Dali::ImageActor::STYLE_NINE_PATCH)
{
- return "NINE_PATCH";
+ return "STYLE_NINE_PATCH";
}
else // if(s == "QUAD")
{
}
}
+bool ImageActor::IsDefaultPropertyAConstraintInput( Property::Index index ) const
+{
+ if( index < DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT )
+ {
+ return RenderableActor::IsDefaultPropertyAConstraintInput(index);
+ }
+ return true; // Our properties can be used as input to constraints.
+}
+
Property::Type ImageActor::GetDefaultPropertyType( Property::Index index ) const
{
if(index < DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT)
}
case Dali::ImageActor::IMAGE:
{
- ret = Property::Value(Property::MAP);
+ Property::Map map;
+ Scripting::CreatePropertyMap( mImageAttachment->GetImage(), map );
+ ret = Property::Value( map );
break;
}
default:
virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
/**
+ * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyAConstraintInput()
+ */
+ virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
+
+ /**
* @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyType()
*/
virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
namespace Dali
{
-const Property::Index Layer::CLIPPING_ENABLE = DEFAULT_ACTOR_PROPERTY_MAX_COUNT;
-const Property::Index Layer::CLIPPING_BOX = DEFAULT_ACTOR_PROPERTY_MAX_COUNT + 1;
+const Property::Index Layer::CLIPPING_ENABLE = Internal::DEFAULT_ACTOR_PROPERTY_MAX_COUNT;
+const Property::Index Layer::CLIPPING_BOX = Internal::DEFAULT_ACTOR_PROPERTY_MAX_COUNT + 1;
namespace Internal
{
}
}
+bool Layer::IsDefaultPropertyAConstraintInput( Property::Index index ) const
+{
+ if(index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT)
+ {
+ return Actor::IsDefaultPropertyAConstraintInput(index);
+ }
+ return true; // our properties can be used as an input to a constraint
+}
+
Property::Type Layer::GetDefaultPropertyType( Property::Index index ) const
{
if(index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT)
virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
/**
+ * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyAConstraintInput()
+ */
+ virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
+
+ /**
* @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyType()
*/
virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
namespace Dali
{
-const Property::Index LightActor::LIGHT_TYPE = DEFAULT_ACTOR_PROPERTY_MAX_COUNT;
-const Property::Index LightActor::ENABLE = DEFAULT_ACTOR_PROPERTY_MAX_COUNT + 1;
-const Property::Index LightActor::FALL_OFF = DEFAULT_ACTOR_PROPERTY_MAX_COUNT + 2;
-const Property::Index LightActor::SPOT_ANGLE = DEFAULT_ACTOR_PROPERTY_MAX_COUNT + 3;
-const Property::Index LightActor::AMBIENT_COLOR = DEFAULT_ACTOR_PROPERTY_MAX_COUNT + 4;
-const Property::Index LightActor::DIFFUSE_COLOR = DEFAULT_ACTOR_PROPERTY_MAX_COUNT + 5;
-const Property::Index LightActor::SPECULAR_COLOR = DEFAULT_ACTOR_PROPERTY_MAX_COUNT + 6;
-const Property::Index LightActor::DIRECTION = DEFAULT_ACTOR_PROPERTY_MAX_COUNT + 7;
+const Property::Index LightActor::LIGHT_TYPE = Internal::DEFAULT_ACTOR_PROPERTY_MAX_COUNT;
+const Property::Index LightActor::ENABLE = Internal::DEFAULT_ACTOR_PROPERTY_MAX_COUNT + 1;
+const Property::Index LightActor::FALL_OFF = Internal::DEFAULT_ACTOR_PROPERTY_MAX_COUNT + 2;
+const Property::Index LightActor::SPOT_ANGLE = Internal::DEFAULT_ACTOR_PROPERTY_MAX_COUNT + 3;
+const Property::Index LightActor::AMBIENT_COLOR = Internal::DEFAULT_ACTOR_PROPERTY_MAX_COUNT + 4;
+const Property::Index LightActor::DIFFUSE_COLOR = Internal::DEFAULT_ACTOR_PROPERTY_MAX_COUNT + 5;
+const Property::Index LightActor::SPECULAR_COLOR = Internal::DEFAULT_ACTOR_PROPERTY_MAX_COUNT + 6;
+const Property::Index LightActor::DIRECTION = Internal::DEFAULT_ACTOR_PROPERTY_MAX_COUNT + 7;
namespace Internal
{
}
}
+bool LightActor::IsDefaultPropertyAConstraintInput( Property::Index index ) const
+{
+ if( index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT )
+ {
+ return Actor::IsDefaultPropertyAConstraintInput(index);
+ }
+ return true; // Our properties can be used as input to constraints.
+}
+
Property::Type LightActor::GetDefaultPropertyType( Property::Index index ) const
{
if(index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT)
virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
/**
+ * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyAConstraintInput()
+ */
+ virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
+
+ /**
* @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyType()
*/
virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
namespace Dali
{
-const Property::Index TextActor::TEXT = DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT;
-const Property::Index TextActor::FONT = DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 1;
-const Property::Index TextActor::FONT_STYLE = DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 2;
-const Property::Index TextActor::OUTLINE_ENABLE = DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 3;
-const Property::Index TextActor::OUTLINE_COLOR = DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 4;
-const Property::Index TextActor::OUTLINE_THICKNESS_WIDTH = DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 5;
-const Property::Index TextActor::SMOOTH_EDGE = DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 6;
-const Property::Index TextActor::GLOW_ENABLE = DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 7;
-const Property::Index TextActor::GLOW_COLOR = DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 8;
-const Property::Index TextActor::GLOW_INTENSITY = DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 9;
-const Property::Index TextActor::SHADOW_ENABLE = DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 10;
-const Property::Index TextActor::SHADOW_COLOR = DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 11;
-const Property::Index TextActor::SHADOW_OFFSET = DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 12;
-const Property::Index TextActor::ITALICS_ANGLE = DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 13;
-const Property::Index TextActor::UNDERLINE = DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 14;
-const Property::Index TextActor::WEIGHT = DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 15;
-const Property::Index TextActor::FONT_DETECTION_AUTOMATIC = DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 16;
-const Property::Index TextActor::GRADIENT_COLOR = DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 17;
-const Property::Index TextActor::GRADIENT_START_POINT = DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 18;
-const Property::Index TextActor::GRADIENT_END_POINT = DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 19;
-const Property::Index TextActor::SHADOW_SIZE = DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 20;
-const Property::Index TextActor::TEXT_COLOR = DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 21;
+const Property::Index TextActor::TEXT = Internal::DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT;
+const Property::Index TextActor::FONT = Internal::DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 1;
+const Property::Index TextActor::FONT_STYLE = Internal::DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 2;
+const Property::Index TextActor::OUTLINE_ENABLE = Internal::DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 3;
+const Property::Index TextActor::OUTLINE_COLOR = Internal::DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 4;
+const Property::Index TextActor::OUTLINE_THICKNESS_WIDTH = Internal::DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 5;
+const Property::Index TextActor::SMOOTH_EDGE = Internal::DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 6;
+const Property::Index TextActor::GLOW_ENABLE = Internal::DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 7;
+const Property::Index TextActor::GLOW_COLOR = Internal::DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 8;
+const Property::Index TextActor::GLOW_INTENSITY = Internal::DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 9;
+const Property::Index TextActor::SHADOW_ENABLE = Internal::DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 10;
+const Property::Index TextActor::SHADOW_COLOR = Internal::DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 11;
+const Property::Index TextActor::SHADOW_OFFSET = Internal::DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 12;
+const Property::Index TextActor::ITALICS_ANGLE = Internal::DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 13;
+const Property::Index TextActor::UNDERLINE = Internal::DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 14;
+const Property::Index TextActor::WEIGHT = Internal::DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 15;
+const Property::Index TextActor::FONT_DETECTION_AUTOMATIC = Internal::DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 16;
+const Property::Index TextActor::GRADIENT_COLOR = Internal::DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 17;
+const Property::Index TextActor::GRADIENT_START_POINT = Internal::DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 18;
+const Property::Index TextActor::GRADIENT_END_POINT = Internal::DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 19;
+const Property::Index TextActor::SHADOW_SIZE = Internal::DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 20;
+const Property::Index TextActor::TEXT_COLOR = Internal::DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 21;
namespace
{
}
}
+bool TextActor::IsDefaultPropertyAConstraintInput( Property::Index index ) const
+{
+ if( index < DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT )
+ {
+ return RenderableActor::IsDefaultPropertyAConstraintInput(index);
+ }
+ return true; // Our properties can be used as input to constraints.
+}
+
Property::Type TextActor::GetDefaultPropertyType( Property::Index index ) const
{
if(index < DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT)
virtual bool IsDefaultPropertyAnimatable( Property::Index index ) const ;
/**
+ * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyAConstraintInput()
+ */
+ virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
+
+ /**
* copydoc Dali::Internal::ProxyObject
*/
virtual Property::Type GetDefaultPropertyType( Property::Index index ) const ;
return true; // All default properties are currently animatable
}
+bool ActiveConstraintBase::IsDefaultPropertyAConstraintInput( Property::Index index ) const
+{
+ return true; // All default properties can currently be used as a constraint input
+}
+
Property::Type ActiveConstraintBase::GetDefaultPropertyType( Property::Index index ) const
{
if ( ( index >= 0 ) && ( index < DEFAULT_PROPERTY_COUNT ) )
virtual bool IsDefaultPropertyAnimatable( Property::Index index ) const;
/**
+ * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyAConstraintInput()
+ */
+ virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
+
+ /**
* @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyType()
*/
virtual Property::Type GetDefaultPropertyType( Property::Index index ) const;
#include <dali/internal/common/event-to-update.h>
#include <dali/internal/common/message.h>
#include <dali/internal/event/common/proxy-object.h>
-#include <dali/internal/event/common/property-index-ranges.h>
#include <dali/internal/event/common/thread-local-storage.h>
#include <dali/internal/event/common/stage-impl.h>
#include <dali/internal/event/animation/active-constraint-base.h>
{
Source& source = *iter;
- // Type registry properties cannot be used as inputs
- DALI_ASSERT_ALWAYS( ( source.propertyIndex < DEFAULT_PROPERTY_MAX_COUNT ) || ( source.propertyIndex >= CUSTOM_PROPERTY_START ) );
-
PropertyInputImpl* inputProperty( NULL );
int componentIndex( Property::INVALID_COMPONENT_INDEX );
if ( OBJECT_PROPERTY == source.sourceType )
{
+ DALI_ASSERT_ALWAYS( source.object->IsPropertyAConstraintInput( source.propertyIndex ) );
+
SceneGraph::PropertyOwner* owner = const_cast< SceneGraph::PropertyOwner* >( source.object->GetSceneObject() );
// The property owner will not exist, if the target proxy-object is off-stage
}
else if ( LOCAL_PROPERTY == source.sourceType )
{
+ DALI_ASSERT_ALWAYS( mTargetProxy->IsPropertyAConstraintInput( source.propertyIndex ) );
+
inputProperty = const_cast< PropertyInputImpl* >( mTargetProxy->GetSceneObjectInputProperty( source.propertyIndex ) );
componentIndex = mTargetProxy->GetPropertyComponentIndex( source.propertyIndex );
// This will not exist, if the target proxy-object is off-stage
if ( NULL != proxyParent )
{
+ DALI_ASSERT_ALWAYS( proxyParent->IsPropertyAConstraintInput( source.propertyIndex ) );
+
SceneGraph::PropertyOwner* owner = const_cast< SceneGraph::PropertyOwner* >( proxyParent->GetSceneObject() );
// The property owner will not exist, if the parent proxy-object is off-stage
if ( OBJECT_PROPERTY == source.sourceType )
{
+ DALI_ASSERT_ALWAYS( source.object->IsPropertyAConstraintInput( source.propertyIndex ) );
+
SceneGraph::PropertyOwner* owner = const_cast< SceneGraph::PropertyOwner* >( source.object->GetSceneObject() );
// The property owner will not exist, if the target proxy-object is off-stage
}
else if ( LOCAL_PROPERTY == source.sourceType )
{
+ DALI_ASSERT_ALWAYS( mTargetProxy->IsPropertyAConstraintInput( source.propertyIndex ) );
+
inputProperty = const_cast< PropertyInputImpl* >( mTargetProxy->GetSceneObjectInputProperty( source.propertyIndex ) );
componentIndex = mTargetProxy->GetPropertyComponentIndex( source.propertyIndex );
// This will not exist, if the target proxy-object is off-stage
if ( NULL != proxyParent )
{
+ DALI_ASSERT_ALWAYS( proxyParent->IsPropertyAConstraintInput( source.propertyIndex ) );
+
SceneGraph::PropertyOwner* owner = const_cast< SceneGraph::PropertyOwner* >( proxyParent->GetSceneObject() );
// The property owner will not exist, if the parent proxy-object is off-stage
virtual bool IsPropertyAnimatable(Property::Index index) const = 0;
/**
+ * @copydoc Dali::Handle::IsPropertyAConstraintInput()
+ */
+ virtual bool IsPropertyAConstraintInput(Property::Index index) const = 0;
+
+ /**
* @copydoc Dali::Handle::GetPropertyType()
*/
virtual Property::Type GetPropertyType(Property::Index index) const = 0;
* Specifies the allowed ranges for different class types to cater for future allocation
*/
-#define DEFAULT_PROPERTY_MAX_COUNT PROPERTY_REGISTRATION_START_INDEX ///< Default Property Range: 0 to 9999999
-
-#define DEFAULT_ACTOR_PROPERTY_MAX_COUNT 10000 ///< Actor Range: 0 to 9999
-#define DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT 20000 ///< Renderable Actor Range: 10000 to 19999
+enum
+{
+ DEFAULT_PROPERTY_MAX_COUNT = PROPERTY_REGISTRATION_START_INDEX, ///< Default Property Range: 0 to 9999999
-#define DEFAULT_GESTURE_DETECTOR_PROPERTY_MAX_COUNT 10000 ///< GestureDetector Range: 0 to 9999
+ DEFAULT_ACTOR_PROPERTY_MAX_COUNT = 10000, ///< Actor Range: 0 to 9999
+ DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT = 20000, ///< Renderable Actor Range: 10000 to 19999
-#define CUSTOM_PROPERTY_START 50000000 ///< Custom Property Range: 50000000 onwards
+ DEFAULT_GESTURE_DETECTOR_PROPERTY_MAX_COUNT = 10000, ///< GestureDetector Range: 0 to 9999
+};
} // namespace Internal
} // unnamed namespace
ProxyObject::ProxyObject()
-: mTypeInfo( NULL ),
- mNextCustomPropertyIndex( 0u ),
+: mNextCustomPropertyIndex( 0u ),
mCustomProperties( NULL ),
+ mTypeInfo( NULL ),
mConstraints( NULL ),
mRemovedConstraints( NULL ),
mPropertyNotifications( NULL )
return false;
}
+bool ProxyObject::IsPropertyAConstraintInput(Property::Index index) const
+{
+ DALI_ASSERT_ALWAYS(index > Property::INVALID_INDEX && "Property index is out of bounds");
+
+ if ( index < DEFAULT_PROPERTY_MAX_COUNT )
+ {
+ return IsDefaultPropertyAConstraintInput( index );
+ }
+
+ if ( ( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX ) )
+ {
+ // Type Registry event-thread only properties cannot be used as an input to a constraint.
+ return false;
+ }
+
+ if( mCustomProperties )
+ {
+ // Check custom property
+ CustomPropertyLookup::const_iterator entry = mCustomProperties->find( index );
+ DALI_ASSERT_ALWAYS( mCustomProperties->end() != entry && "Cannot find property index" );
+
+ // ... custom properties can be used as input to a constraint.
+ return true;
+ }
+ return false;
+}
+
Property::Type ProxyObject::GetPropertyType( Property::Index index ) const
{
DALI_ASSERT_ALWAYS(index > Property::INVALID_INDEX && "Property index is out of bounds" );
// Default properties start from index zero
if ( 0u == mNextCustomPropertyIndex )
{
- mNextCustomPropertyIndex = CUSTOM_PROPERTY_START;
+ mNextCustomPropertyIndex = PROPERTY_CUSTOM_START_INDEX;
}
// Add entry to the property lookup
// Default properties start from index zero
if ( 0u == mNextCustomPropertyIndex )
{
- mNextCustomPropertyIndex = CUSTOM_PROPERTY_START;
+ mNextCustomPropertyIndex = PROPERTY_CUSTOM_START_INDEX;
}
// Add entry to the property lookup
virtual bool IsPropertyAnimatable(Property::Index index) const;
/**
+ * @copydoc Dali::Internal::Object::IsPropertyAConstraintInput()
+ */
+ virtual bool IsPropertyAConstraintInput(Property::Index index) const;
+
+ /**
* @copydoc Dali::Internal::Object::GetPropertyType()
*/
virtual Property::Type GetPropertyType(Property::Index index) const;
/**
* Query how many default properties the derived class supports.
- * @pre Property::INVALID_INDEX < index < GetDefaultPropertyCount().
* @return The number of default properties.
*/
virtual const std::string& GetDefaultPropertyName( Property::Index index ) const = 0;
/**
* Query whether a default property is writable.
- * @pre Property::INVALID_INDEX < index < GetDefaultPropertyCount().
* @param [in] index The index of the property.
* @return True if the property is animatable.
*/
/**
* Query whether a default property is animatable.
* This determines whether the property can be the target of an animation or constraint.
- * @pre Property::INVALID_INDEX < index < GetDefaultPropertyCount().
* @param [in] index The index of the property.
* @return True if the property is animatable.
*/
virtual bool IsDefaultPropertyAnimatable( Property::Index index ) const = 0;
/**
+ * @brief Query whether a default property can be used as an input to a constraint.
+ *
+ * @param [in] index The index of the property.
+ * @return True if the property can be used as an input to a constraint.
+ */
+ virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const = 0;
+
+ /**
* Query the type of a default property.
- * @pre Property::INVALID_INDEX < index < GetDefaultPropertyCount().
* @param [in] index The index of the property.
* @return The type of the property.
*/
/**
* Set the value of a default property.
- * @pre Property::INVALID_INDEX < index < GetDefaultPropertyCount().
* @pre The property types match i.e. propertyValue.GetType() is equal to GetPropertyType(index).
* @param [in] index The index of the property.
* @param [in] propertyValue The new value of the property.
/**
* Retrieve a default property value.
- * @pre Property::INVALID_INDEX < index < GetDefaultPropertyCount().
* @param [in] index The index of the property.
* @return The property value.
*/
private:
- mutable TypeInfo* mTypeInfo; ///< The type-info for this object, mutable so it can be lazy initialized from const method if it is required
-
Property::Index mNextCustomPropertyIndex; ///< The ID of the next custom property to be registered
mutable CustomPropertyLookup* mCustomProperties; ///< Used for accessing custom Node properties, mutable so it can be lazy initialized from const function
+ mutable TypeInfo* mTypeInfo; ///< The type-info for this object, mutable so it can be lazy initialized from const method if it is required
Dali::Vector<Observer*> mObservers;
return false;
}
+bool ShaderEffect::IsDefaultPropertyAConstraintInput( Property::Index index ) const
+{
+ return false;
+}
+
Property::Type ShaderEffect::GetDefaultPropertyType(Property::Index index) const
{
if( index < DEFAULT_PROPERTY_COUNT )
virtual bool IsDefaultPropertyAnimatable( Property::Index index ) const;
/**
+ * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyAConstraintInput()
+ */
+ virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
+
+ /**
* @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyType()
*/
virtual Property::Type GetDefaultPropertyType( Property::Index index ) const;
return false;
}
+bool GestureDetector::IsDefaultPropertyAConstraintInput( Property::Index index ) const
+{
+ return false;
+}
+
Property::Type GestureDetector::GetDefaultPropertyType(Property::Index index) const
{
return Property::NONE;
virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
/**
+ * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyAConstraintInput()
+ */
+ virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
+
+ /**
* @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyType()
*/
virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
namespace Dali
{
-const Property::Index PanGestureDetector::SCREEN_POSITION = DEFAULT_GESTURE_DETECTOR_PROPERTY_MAX_COUNT;
-const Property::Index PanGestureDetector::SCREEN_DISPLACEMENT = DEFAULT_GESTURE_DETECTOR_PROPERTY_MAX_COUNT + 1;
-const Property::Index PanGestureDetector::LOCAL_POSITION = DEFAULT_GESTURE_DETECTOR_PROPERTY_MAX_COUNT + 2;
-const Property::Index PanGestureDetector::LOCAL_DISPLACEMENT = DEFAULT_GESTURE_DETECTOR_PROPERTY_MAX_COUNT + 3;
+const Property::Index PanGestureDetector::SCREEN_POSITION = Internal::DEFAULT_GESTURE_DETECTOR_PROPERTY_MAX_COUNT;
+const Property::Index PanGestureDetector::SCREEN_DISPLACEMENT = Internal::DEFAULT_GESTURE_DETECTOR_PROPERTY_MAX_COUNT + 1;
+const Property::Index PanGestureDetector::LOCAL_POSITION = Internal::DEFAULT_GESTURE_DETECTOR_PROPERTY_MAX_COUNT + 2;
+const Property::Index PanGestureDetector::LOCAL_DISPLACEMENT = Internal::DEFAULT_GESTURE_DETECTOR_PROPERTY_MAX_COUNT + 3;
namespace Internal
{
return false;
}
+bool PanGestureDetector::IsDefaultPropertyAConstraintInput( Property::Index index ) const
+{
+ // All our properties can be used as an input to a constraint.
+ return true;
+}
+
Property::Type PanGestureDetector::GetDefaultPropertyType(Property::Index index) const
{
index -= DEFAULT_GESTURE_DETECTOR_PROPERTY_MAX_COUNT;
virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
/**
+ * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyAConstraintInput()
+ */
+ virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
+
+ /**
* @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyType()
*/
virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
return true;
}
+bool AnimatableMesh::IsDefaultPropertyAConstraintInput( Property::Index index ) const
+{
+ return true;
+}
+
Property::Type AnimatableMesh::GetDefaultPropertyType(Property::Index index) const
{
if ( ( index >= 0 ) && ( index < mPropertyCount ) )
virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
/**
+ * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyAConstraintInput()
+ */
+ virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
+
+ /**
* @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyType()
*/
virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
return false;
}
+bool CustomObject::IsDefaultPropertyAConstraintInput( Property::Index index ) const
+{
+ return false;
+}
+
Property::Type CustomObject::GetDefaultPropertyType(Property::Index index) const
{
return Property::NONE;
virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
/**
+ * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyAConstraintInput()
+ */
+ virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
+
+ /**
* @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyType()
*/
virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
return true;
}
+bool RenderTask::IsDefaultPropertyAConstraintInput( Property::Index index ) const
+{
+ return true;
+}
+
Property::Type RenderTask::GetDefaultPropertyType(Property::Index index) const
{
if( index < DEFAULT_PROPERTY_COUNT )
virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
/**
+ * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyAConstraintInput()
+ */
+ virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
+
+ /**
* @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyType()
*/
virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
return GetImplementation(*this).IsPropertyAnimatable( index );
}
+bool Handle::IsPropertyAConstraintInput(Property::Index index) const
+{
+ return GetImplementation(*this).IsPropertyAConstraintInput( index );
+}
+
Property::Type Handle::GetPropertyType(Property::Index index) const
{
return GetImplementation(*this).GetPropertyType( index );
#include <dali/public-api/scripting/scripting.h>
// INTERNAL INCLUDES
+#include <dali/public-api/actors/actor.h>
#include <dali/public-api/images/image.h>
#include <dali/public-api/images/image-attributes.h>
+#include <dali/public-api/object/type-registry.h>
#include <dali/internal/event/images/image-impl.h>
#include <dali/internal/event/images/frame-buffer-image-impl.h>
#include <dali/internal/event/images/bitmap-image-impl.h>
namespace Scripting
{
+namespace
+{
+
+// Helpers for converting strings to the enumerations and vice versa
+
+template< typename T >
+struct StringEnum
+{
+ const std::string string;
+ const T value;
+};
+
+const StringEnum< ColorMode > COLOR_MODE_TABLE[] =
+{
+ { "USE_OWN_COLOR", USE_OWN_COLOR },
+ { "USE_PARENT_COLOR", USE_PARENT_COLOR },
+ { "USE_OWN_MULTIPLY_PARENT_COLOR", USE_OWN_MULTIPLY_PARENT_COLOR },
+ { "USE_OWN_MULTIPLY_PARENT_ALPHA", USE_OWN_MULTIPLY_PARENT_ALPHA },
+};
+const unsigned int COLOR_MODE_TABLE_COUNT = sizeof( COLOR_MODE_TABLE ) / sizeof( COLOR_MODE_TABLE[0] );
+
+const StringEnum< PositionInheritanceMode > POSITION_INHERITANCE_MODE_TABLE[] =
+{
+ { "INHERIT_PARENT_POSITION", INHERIT_PARENT_POSITION },
+ { "USE_PARENT_POSITION", USE_PARENT_POSITION },
+ { "USE_PARENT_POSITION_PLUS_LOCAL_POSITION", USE_PARENT_POSITION_PLUS_LOCAL_POSITION },
+ { "DONT_INHERIT_POSITION", DONT_INHERIT_POSITION },
+};
+const unsigned int POSITION_INHERITANCE_MODE_TABLE_COUNT = sizeof( POSITION_INHERITANCE_MODE_TABLE ) / sizeof( POSITION_INHERITANCE_MODE_TABLE[0] );
+
+const StringEnum< DrawMode::Type > DRAW_MODE_TABLE[] =
+{
+ { "NORMAL", DrawMode::NORMAL },
+ { "OVERLAY", DrawMode::OVERLAY },
+ { "STENCIL", DrawMode::STENCIL },
+};
+const unsigned int DRAW_MODE_TABLE_COUNT = sizeof( DRAW_MODE_TABLE ) / sizeof( DRAW_MODE_TABLE[0] );
+
+const StringEnum< Vector3 > ANCHOR_CONSTANT_TABLE[] =
+{
+ { "BACK_TOP_LEFT", ParentOrigin::BACK_TOP_LEFT },
+ { "BACK_TOP_CENTER", ParentOrigin::BACK_TOP_CENTER },
+ { "BACK_TOP_RIGHT", ParentOrigin::BACK_TOP_RIGHT },
+ { "BACK_CENTER_LEFT", ParentOrigin::BACK_CENTER_LEFT },
+ { "BACK_CENTER", ParentOrigin::BACK_CENTER },
+ { "BACK_CENTER_RIGHT", ParentOrigin::BACK_CENTER_RIGHT },
+ { "BACK_BOTTOM_LEFT", ParentOrigin::BACK_BOTTOM_LEFT },
+ { "BACK_BOTTOM_CENTER", ParentOrigin::BACK_BOTTOM_CENTER },
+ { "BACK_BOTTOM_RIGHT", ParentOrigin::BACK_BOTTOM_RIGHT },
+ { "TOP_LEFT", ParentOrigin::TOP_LEFT },
+ { "TOP_CENTER", ParentOrigin::TOP_CENTER },
+ { "TOP_RIGHT", ParentOrigin::TOP_RIGHT },
+ { "CENTER_LEFT", ParentOrigin::CENTER_LEFT },
+ { "CENTER", ParentOrigin::CENTER },
+ { "CENTER_RIGHT", ParentOrigin::CENTER_RIGHT },
+ { "BOTTOM_LEFT", ParentOrigin::BOTTOM_LEFT },
+ { "BOTTOM_CENTER", ParentOrigin::BOTTOM_CENTER },
+ { "BOTTOM_RIGHT", ParentOrigin::BOTTOM_RIGHT },
+ { "FRONT_TOP_LEFT", ParentOrigin::FRONT_TOP_LEFT },
+ { "FRONT_TOP_CENTER", ParentOrigin::FRONT_TOP_CENTER },
+ { "FRONT_TOP_RIGHT", ParentOrigin::FRONT_TOP_RIGHT },
+ { "FRONT_CENTER_LEFT", ParentOrigin::FRONT_CENTER_LEFT },
+ { "FRONT_CENTER", ParentOrigin::FRONT_CENTER },
+ { "FRONT_CENTER_RIGHT", ParentOrigin::FRONT_CENTER_RIGHT },
+ { "FRONT_BOTTOM_LEFT", ParentOrigin::FRONT_BOTTOM_LEFT },
+ { "FRONT_BOTTOM_CENTER", ParentOrigin::FRONT_BOTTOM_CENTER },
+ { "FRONT_BOTTOM_RIGHT", ParentOrigin::FRONT_BOTTOM_RIGHT },
+};
+const unsigned int ANCHOR_CONSTANT_TABLE_COUNT = sizeof( ANCHOR_CONSTANT_TABLE ) / sizeof( ANCHOR_CONSTANT_TABLE[0] );
+
+const StringEnum< Image::LoadPolicy > IMAGE_LOAD_POLICY_TABLE[] =
+{
+ { "IMMEDIATE", Image::Immediate },
+ { "ON_DEMAND", Image::OnDemand },
+};
+const unsigned int IMAGE_LOAD_POLICY_TABLE_COUNT = sizeof( IMAGE_LOAD_POLICY_TABLE ) / sizeof( IMAGE_LOAD_POLICY_TABLE[0] );
+
+const StringEnum< Image::ReleasePolicy > IMAGE_RELEASE_POLICY_TABLE[] =
+{
+ { "UNUSED", Image::Unused },
+ { "NEVER", Image::Never },
+};
+const unsigned int IMAGE_RELEASE_POLICY_TABLE_COUNT = sizeof( IMAGE_RELEASE_POLICY_TABLE ) / sizeof( IMAGE_RELEASE_POLICY_TABLE[0] );
+
+const StringEnum< Pixel::Format > PIXEL_FORMAT_TABLE[] =
+{
+ { "A8", Pixel::A8 },
+ { "L8", Pixel::L8 },
+ { "LA88", Pixel::LA88 },
+ { "RGB565", Pixel::RGB565 },
+ { "BGR565", Pixel::BGR565 },
+ { "RGBA4444", Pixel::RGBA4444 },
+ { "BGRA4444", Pixel::BGRA4444 },
+ { "RGBA5551", Pixel::RGBA5551 },
+ { "BGRA5551", Pixel::BGRA5551 },
+ { "RGB888", Pixel::RGB888 },
+ { "RGB8888", Pixel::RGB8888 },
+ { "BGR8888", Pixel::BGR8888 },
+ { "RGBA8888", Pixel::RGBA8888 },
+ { "BGRA8888", Pixel::BGRA8888 },
+ { "COMPRESSED_R11_EAC", Pixel::COMPRESSED_R11_EAC },
+ { "COMPRESSED_SIGNED_R11_EAC", Pixel::COMPRESSED_SIGNED_R11_EAC },
+ { "COMPRESSED_RG11_EAC", Pixel::COMPRESSED_RG11_EAC },
+ { "COMPRESSED_SIGNED_RG11_EAC", Pixel::COMPRESSED_SIGNED_RG11_EAC },
+ { "COMPRESSED_RGB8_ETC2", Pixel::COMPRESSED_RGB8_ETC2 },
+ { "COMPRESSED_SRGB8_ETC2", Pixel::COMPRESSED_SRGB8_ETC2 },
+ { "COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2", Pixel::COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 },
+ { "COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2", Pixel::COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 },
+ { "COMPRESSED_RGBA8_ETC2_EAC", Pixel::COMPRESSED_RGBA8_ETC2_EAC },
+ { "COMPRESSED_SRGB8_ALPHA8_ETC2_EAC", Pixel::COMPRESSED_SRGB8_ALPHA8_ETC2_EAC },
+ { "COMPRESSED_RGB8_ETC1", Pixel::COMPRESSED_RGB8_ETC1 },
+ { "COMPRESSED_RGB_PVRTC_4BPPV1", Pixel::COMPRESSED_RGB_PVRTC_4BPPV1 },
+};
+const unsigned int PIXEL_FORMAT_TABLE_COUNT = sizeof( PIXEL_FORMAT_TABLE ) / sizeof( PIXEL_FORMAT_TABLE[0] );
+
+const StringEnum< ImageAttributes::ScalingMode > IMAGE_SCALING_MODE_TABLE[] =
+{
+ { "SHRINK_TO_FIT", ImageAttributes::ShrinkToFit },
+ { "SCALE_TO_FILL", ImageAttributes::ScaleToFill },
+ { "FIT_WIDTH", ImageAttributes::FitWidth },
+ { "FIT_HEIGHT", ImageAttributes::FitHeight },
+};
+const unsigned int IMAGE_SCALING_MODE_TABLE_COUNT = sizeof( IMAGE_SCALING_MODE_TABLE ) / sizeof( IMAGE_SCALING_MODE_TABLE[0] );
+
+template< typename T >
+T GetEnumeration( const std::string& value, const StringEnum< T >* table, const unsigned int tableCount )
+{
+ T v( table->value );
+ bool set( false );
+
+ for ( unsigned int i = 0; ( i < tableCount ) && ( !set ); ++i )
+ {
+ set = SetIfEqual(value, table->string, v, table->value );
+ ++table;
+ }
+
+ if ( !set )
+ {
+ DALI_ASSERT_ALWAYS( !"Unknown enumeration string" );
+ }
+
+ return v;
+}
+
+template< typename T >
+const std::string& GetEnumerationName( const T& value, const StringEnum< T >* table, const unsigned int tableCount )
+{
+ for ( unsigned int i = 0; i < tableCount; ++i )
+ {
+ if ( value == table[i].value )
+ {
+ return table[i].string;
+ break;
+ }
+ }
+
+ return String::EMPTY;
+}
+
+} // unnamed namespace
+
bool CompareEnums(const std::string& a, const std::string& b)
{
std::string::const_iterator ia = a.begin();
}
+ColorMode GetColorMode( const std::string& value )
+{
+ return GetEnumeration< ColorMode >( value, COLOR_MODE_TABLE, COLOR_MODE_TABLE_COUNT );
+}
+
+
+const std::string& GetColorMode( ColorMode value )
+{
+ return GetEnumerationName< ColorMode >( value, COLOR_MODE_TABLE, COLOR_MODE_TABLE_COUNT );
+}
+
+PositionInheritanceMode GetPositionInheritanceMode( const std::string& value )
+{
+ return GetEnumeration< PositionInheritanceMode >( value, POSITION_INHERITANCE_MODE_TABLE, POSITION_INHERITANCE_MODE_TABLE_COUNT );
+}
+
+
+const std::string& GetPositionInheritanceMode( PositionInheritanceMode value )
+{
+ return GetEnumerationName< PositionInheritanceMode >( value, POSITION_INHERITANCE_MODE_TABLE, POSITION_INHERITANCE_MODE_TABLE_COUNT );
+}
+
+
+DrawMode::Type GetDrawMode( const std::string& value )
+{
+ return GetEnumeration< DrawMode::Type >( value, DRAW_MODE_TABLE, DRAW_MODE_TABLE_COUNT );
+}
+
+
+const std::string& GetDrawMode( DrawMode::Type value )
+{
+ return GetEnumerationName< DrawMode::Type >( value, DRAW_MODE_TABLE, DRAW_MODE_TABLE_COUNT );
+}
+
+
+Vector3 GetAnchorConstant( const std::string& value )
+{
+ return GetEnumeration< Vector3 >( value, ANCHOR_CONSTANT_TABLE, ANCHOR_CONSTANT_TABLE_COUNT );
+}
+
+
Image NewImage( const Property::Value& map )
{
Image ret;
{
DALI_ASSERT_ALWAYS(map.GetValue(field).GetType() == Property::STRING && "Image load-policy property is not a string" );
std::string v(map.GetValue(field).Get<std::string>());
- if(v == "IMMEDIATE")
- {
- loadPolicy = Dali::Image::Immediate;
- }
- else if(v == "ON_DEMAND")
- {
- loadPolicy = Dali::Image::OnDemand;
- }
- else
- {
- DALI_ASSERT_ALWAYS(!"Unknown image load-policy");
- }
+ loadPolicy = GetEnumeration< Image::LoadPolicy >( v, IMAGE_LOAD_POLICY_TABLE, IMAGE_LOAD_POLICY_TABLE_COUNT );
}
field = "release-policy";
{
DALI_ASSERT_ALWAYS(map.GetValue(field).GetType() == Property::STRING && "Image release-policy property is not a string" );
std::string v(map.GetValue(field).Get<std::string>());
- if(v == "UNUSED")
- {
- releasePolicy = Dali::Image::Unused;
- }
- else if(v == "NEVER")
- {
- releasePolicy = Dali::Image::Never;
- }
- else
- {
- DALI_ASSERT_ALWAYS(!"Unknown image release-policy");
- }
+ releasePolicy = GetEnumeration< Image::ReleasePolicy >( v, IMAGE_RELEASE_POLICY_TABLE, IMAGE_RELEASE_POLICY_TABLE_COUNT );
}
if( map.HasKey("width") && map.HasKey("height") )
if( map.HasKey(field) )
{
DALI_ASSERT_ALWAYS(map.GetValue(field).GetType() == Property::STRING && "Image release-policy property is not a string" );
-
std::string s(map.GetValue(field).Get<std::string>());
-
- if(s == "A8")
- {
- attributes.SetPixelFormat(Pixel::A8);
- }
- else if(s == "L8")
- {
- attributes.SetPixelFormat(Pixel::L8);
- }
- else if(s == "LA88")
- {
- attributes.SetPixelFormat(Pixel::LA88);
- }
- else if(s == "RGB565")
- {
- attributes.SetPixelFormat(Pixel::RGB565);
- }
- else if(s == "BGR565")
- {
- attributes.SetPixelFormat(Pixel::BGR565);
- }
- else if(s == "RGBA4444")
- {
- attributes.SetPixelFormat(Pixel::RGBA4444);
- }
- else if(s == "BGRA4444")
- {
- attributes.SetPixelFormat(Pixel::BGRA4444);
- }
- else if(s == "RGBA5551")
- {
- attributes.SetPixelFormat(Pixel::RGBA5551);
- }
- else if(s == "BGRA5551")
- {
- attributes.SetPixelFormat(Pixel::BGRA5551);
- }
- else if(s == "RGB888")
- {
- attributes.SetPixelFormat(Pixel::RGB888);
- }
- else if(s == "RGB8888")
- {
- attributes.SetPixelFormat(Pixel::RGB8888);
- }
- else if(s == "BGR8888")
- {
- attributes.SetPixelFormat(Pixel::BGR8888);
- }
- else if(s == "RGBA8888")
- {
- attributes.SetPixelFormat(Pixel::RGBA8888);
- }
- else if(s == "BGRA8888")
- {
- attributes.SetPixelFormat(Pixel::BGRA8888);
- }
- else
- {
- DALI_ASSERT_ALWAYS(!"Unknown image pixel format");
- }
+ attributes.SetPixelFormat( GetEnumeration< Pixel::Format >( s, PIXEL_FORMAT_TABLE, PIXEL_FORMAT_TABLE_COUNT ));
}
field = "scaling-mode";
if( map.HasKey(field) )
{
DALI_ASSERT_ALWAYS(map.GetValue(field).GetType() == Property::STRING && "Image release-policy property is not a string" );
-
std::string s(map.GetValue(field).Get<std::string>());
-
- if(s == "SHRINK_TO_FIT")
- {
- attributes.SetScalingMode(ImageAttributes::ShrinkToFit);
- }
- else if(s == "SCALE_TO_FILL")
- {
- attributes.SetScalingMode(ImageAttributes::ScaleToFill);
- }
- else if(s == "FIT_WIDTH")
- {
- attributes.SetScalingMode(ImageAttributes::FitWidth);
- }
- else if(s == "FIT_HEIGHT")
- {
- attributes.SetScalingMode(ImageAttributes::FitHeight);
- }
- else
- {
- DALI_ASSERT_ALWAYS(!"Unknown image scaling mode");
- }
+ attributes.SetScalingMode( GetEnumeration< ImageAttributes::ScalingMode >( s, IMAGE_SCALING_MODE_TABLE, IMAGE_SCALING_MODE_TABLE_COUNT ) );
}
field = "crop";
attributes.GetPixelFormat(),
releasePolicy );
}
- else if("BitMapImage" == s)
+ else if("BitmapImage" == s)
{
ret = new Internal::BitmapImage(attributes.GetWidth(),
attributes.GetHeight(),
{
ret = Image::New(filename, attributes, loadPolicy, releasePolicy);
}
+ else
+ {
+ DALI_ASSERT_ALWAYS( !"Unknown image type" );
+ }
}
else
{
return Dali::ShaderEffect(ret.Get());
}
+
+Actor NewActor( const Property::Map& map )
+{
+ BaseHandle handle;
+
+ const Property::Map::const_iterator endIter = map.end();
+
+ // First find type and create Actor
+ Property::Map::const_iterator typeIter = map.begin();
+ for (; typeIter != endIter; ++typeIter )
+ {
+ if ( typeIter->first == "type" )
+ {
+ TypeInfo type = TypeRegistry::Get().GetTypeInfo( typeIter->second.Get< std::string >() );
+ if ( type )
+ {
+ handle = type.CreateInstance();
+ }
+ break;
+ }
+ }
+
+ if ( !handle )
+ {
+ DALI_LOG_ERROR( "Actor type not provided, returning empty handle" );
+ return Actor();
+ }
+
+ Actor actor( Actor::DownCast( handle ) );
+
+ if ( actor )
+ {
+ // Now set the properties, or create children
+ for ( Property::Map::const_iterator iter = map.begin(); iter != endIter; ++iter )
+ {
+ if ( iter == typeIter )
+ {
+ continue;
+ }
+
+ if ( iter->first == "actors" )
+ {
+ // Create children
+
+ Property::Array actorArray = iter->second.Get< Property::Array >();
+ for ( Property::Array::iterator arrayIter = actorArray.begin(), arrayEndIter = actorArray.end(); arrayIter != arrayEndIter; ++arrayIter )
+ {
+ actor.Add( NewActor( arrayIter->Get< Property::Map >() ) );
+ }
+ }
+ else if ( iter->first == "signals" )
+ {
+ DALI_LOG_ERROR( "signals not supported" );
+ }
+ else if( iter->first == "parent-origin" )
+ {
+ // Parent Origin can be a string constant as well as a Vector3
+
+ const Property::Type type( iter->second.GetType() );
+ if ( type == Property::VECTOR3 )
+ {
+ actor.SetParentOrigin( iter->second.Get< Vector3 >() );
+ }
+ else if( type == Property::STRING )
+ {
+ actor.SetParentOrigin( GetAnchorConstant( iter->second.Get< std::string >() ) );
+ }
+ }
+ else if( iter->first == "anchor-point" )
+ {
+ // Anchor Point can be a string constant as well as a Vector3
+
+ const Property::Type type( iter->second.GetType() );
+ if ( type == Property::VECTOR3 )
+ {
+ actor.SetAnchorPoint( iter->second.Get< Vector3 >() );
+ }
+ else if( type == Property::STRING )
+ {
+ actor.SetAnchorPoint( GetAnchorConstant( iter->second.Get< std::string >() ) );
+ }
+ }
+ else
+ {
+ Property::Index index( actor.GetPropertyIndex( iter->first ) );
+
+ if ( index != Property::INVALID_INDEX )
+ {
+ actor.SetProperty( index, iter->second );
+ }
+ }
+ }
+ }
+
+ return actor;
+}
+
+void CreatePropertyMap( Actor actor, Property::Map& map )
+{
+ map.clear();
+
+ if ( actor )
+ {
+ map.push_back( Property::StringValuePair( "type", actor.GetTypeName() ) );
+
+ // Default properties
+ Property::IndexContainer indices;
+ actor.GetPropertyIndices( indices );
+ const Property::IndexContainer::const_iterator endIter = indices.end();
+ for ( Property::IndexContainer::iterator iter = indices.begin(); iter != endIter; ++iter )
+ {
+ map.push_back( Property::StringValuePair( actor.GetPropertyName( *iter ), actor.GetProperty( *iter ) ) );
+ }
+
+ // Children
+ unsigned int childCount( actor.GetChildCount() );
+ if ( childCount )
+ {
+ Property::Array childArray;
+ for ( unsigned int child = 0; child < childCount; ++child )
+ {
+ Property::Map childMap;
+ CreatePropertyMap( actor.GetChildAt( child ), childMap );
+ childArray.push_back( childMap );
+ }
+ map.push_back( Property::StringValuePair( "actors", childArray ) );
+ }
+ }
+}
+
+void CreatePropertyMap( Image image, Property::Map& map )
+{
+ map.clear();
+
+ if ( image )
+ {
+ std::string imageType( "Image" );
+
+ // Get Type - cannot use TypeRegistry as Image is not a ProxyObject and thus, not registered
+ if ( BitmapImage::DownCast( image ) )
+ {
+ imageType = "BitmapImage";
+ }
+ else if ( FrameBufferImage::DownCast( image ) )
+ {
+ imageType = "FrameBufferImage";
+ }
+
+ map.push_back( Property::StringValuePair( "type", imageType ) );
+ map.push_back( Property::StringValuePair( "filename", image.GetFilename() ) );
+ map.push_back( Property::StringValuePair( "load-policy", GetEnumerationName< Image::LoadPolicy >( image.GetLoadPolicy(), IMAGE_LOAD_POLICY_TABLE, IMAGE_LOAD_POLICY_TABLE_COUNT ) ) );
+ map.push_back( Property::StringValuePair( "release-policy", GetEnumerationName< Image::ReleasePolicy >( image.GetReleasePolicy(), IMAGE_RELEASE_POLICY_TABLE, IMAGE_RELEASE_POLICY_TABLE_COUNT ) ) );
+
+ ImageAttributes attributes( image.GetAttributes() );
+ map.push_back( Property::StringValuePair( "pixel-format", GetEnumerationName< Pixel::Format >( attributes.GetPixelFormat(), PIXEL_FORMAT_TABLE, PIXEL_FORMAT_TABLE_COUNT ) ) );
+ map.push_back( Property::StringValuePair( "scaling-mode", GetEnumerationName< ImageAttributes::ScalingMode >( attributes.GetScalingMode(), IMAGE_SCALING_MODE_TABLE, IMAGE_SCALING_MODE_TABLE_COUNT ) ) );
+
+ Rect< float > crop( attributes.GetCrop() );
+ map.push_back( Property::StringValuePair( "crop", Vector4( crop.x, crop.y, crop.width, crop.height ) ) );
+
+ int width( image.GetWidth() );
+ int height( image.GetHeight() );
+
+ if ( width && height )
+ {
+ map.push_back( Property::StringValuePair( "width", width ) );
+ map.push_back( Property::StringValuePair( "height", height ) );
+ }
+ }
+}
+
} // namespace scripting
} // namespace Dali
//
// INTERNAL INCLUDES
+#include <dali/public-api/actors/actor-enumerations.h>
+#include <dali/public-api/actors/draw-mode.h>
#include <dali/public-api/images/image.h>
#include <dali/public-api/shader-effects/shader-effect.h>
#include <dali/public-api/object/property-value.h>
namespace Dali DALI_IMPORT_API
{
+class Actor;
+
/**
* @brief Utilities for scripting support.
*/
}
}
+/**
+ * @brief Takes a string and returns the appropriate color mode.
+ *
+ * @param[in] value The input string
+ * @return The corresponding color-mode.
+ */
+ColorMode GetColorMode( const std::string& value );
+
+/**
+ * @brief Takes a color mode and returns the appropriate string equivalent.
+ *
+ * @param[in] value The color mode
+ * @return The corresponding string.
+ */
+const std::string& GetColorMode( ColorMode value );
+
+/**
+ * @brief Takes a string and returns the appropriate position inheritance mode.
+ *
+ * @param[in] value The input string
+ * @return The corresponding position-inheritance-mode.
+ */
+PositionInheritanceMode GetPositionInheritanceMode( const std::string& value );
+
+/**
+ * @brief Takes a position inheritance mode and returns the string equivalent.
+ *
+ * @param[in] value The position-inheritance-mode.
+ * @return The corresponding string.
+ */
+const std::string& GetPositionInheritanceMode( PositionInheritanceMode value );
+
+/**
+ * @brief Takes a string and returns the appropriate draw mode.
+ *
+ * @param[in] value The input string
+ * @return The corresponding draw-mode.
+ */
+DrawMode::Type GetDrawMode( const std::string& value );
+
+/**
+ * @brief Takes a draw-mode and returns the string equivalent.
+ *
+ * @param[in] value The draw-mode.
+ * @return The corresponding string.
+ */
+const std::string& GetDrawMode( DrawMode::Type value );
+
+/**
+ * @brief Takes a string and returns the appropriate anchor-point or parent-origin constant.
+ *
+ * @param[in] value The input string
+ * @return The corresponding anchor-point or parent-origin constant.
+ */
+Vector3 GetAnchorConstant( const std::string& value );
/**
* @brief Creates object with data from the property value map.
*
- * @param [in] map The property value map with the following valid fields
- * "filename": type STRING
- * "load-policy" type STRING (enum)
- * "release-policy" type STRING (enum)
- * "width" type FLOAT
- * "height" type FLOAT
- * "pixel-format" type STRING (enum)
- * "scaling-mode" type STRING (enum)
- * "crop" type VECTOR4
- * "type" type STRING (FrameBufferImage|BitMapImage|Image(default))
- * Some fields are optional and some only pertain to a specific type.
+ * @param[in] map The property value map with the following valid fields:
+ * @code
+ * "filename": type STRING
+ * "load-policy" type STRING (enum)
+ * "release-policy" type STRING (enum)
+ * "width" type FLOAT
+ * "height" type FLOAT
+ * "pixel-format" type STRING (enum)
+ * "scaling-mode" type STRING (enum)
+ * "crop" type VECTOR4
+ * "type" type STRING (FrameBufferImage|BitMapImage|Image(default))
+ * @endcode
+ * Some fields are optional and some only pertain to a specific type.
+ *
* @return a pointer to a newly created object.
*/
Image NewImage( const Property::Value& map );
-
/**
* @brief Creates object with data from the property value map.
*
- * @param [in] map The property value map with the following valid fields
- * // a program can be specified as string or a filename.
- * // some fields may be ignored depending on the geometry-type
- * "program": type MAP
- * { "vertex": type STRING
- * "fragment": type STRING
- * "vertex-prefix": type STRING
- * "fragment-prefix": type STRING
- * "text-vertex": type STRING
- * "text-fragment": type STRING
- * "vertex-filename": type STRING
- * "fragment-filename": type STRING
- * "vertex-prefix-filename": type STRING
- * "fragment-prefix-filename":type STRING
- * "text-vertex-filename": type STRING
- * "text-fragment-filename": type STRING
- * "geometry-type": type STRING (enum)
- * "geometry-hints": type STRING (enum)
- * }
- * // uniforms must be specified to be registered
- * "uUniform1": type FLOAT,
- * "uUniform2": type FLOAT, etc
+ * @param[in] map The property value map with the following valid fields:
+ * @code
+ * // a program can be specified as string or a filename.
+ * // some fields may be ignored depending on the geometry-type
+ * "program": type MAP
+ * {
+ * "vertex": type STRING
+ * "fragment": type STRING
+ * "vertex-prefix": type STRING
+ * "fragment-prefix": type STRING
+ * "text-vertex": type STRING
+ * "text-fragment": type STRING
+ * "vertex-filename": type STRING
+ * "fragment-filename": type STRING
+ * "vertex-prefix-filename": type STRING
+ * "fragment-prefix-filename":type STRING
+ * "text-vertex-filename": type STRING
+ * "text-fragment-filename": type STRING
+ * "geometry-type": type STRING (enum)
+ * "geometry-hints": type STRING (enum)
+ * }
+ * // uniforms must be specified to be registered
+ * "uUniform1": type FLOAT,
+ * "uUniform2": type FLOAT, etc
+ * @endcode
*
* @return a pointer to a newly created object.
*/
ShaderEffect NewShaderEffect( const Property::Value& map );
+/**
+ * @brief Creates an actor with the date from the property value map.
+ *
+ * @param[in] map The property value map with the properties (and hierarchy) of the actor required
+ * For example:
+ * @code
+ * {
+ * "type": "ImageActor",
+ * "image":
+ * {
+ * "filename":"my-image-path.png"
+ * },
+ * "actors":
+ * [
+ * {
+ * "type":"Actor",
+ * "position":[0,0,0]
+ * }
+ * ]
+ * }
+ * @endcode
+ *
+ * @return Handle to the newly created actor.
+ */
+Actor NewActor( const Property::Map& map );
+
+/**
+ * @brief Creates a Property::Map from the actor provided.
+ *
+ * @param[in] actor The base-actor from which a Property::Map should be created
+ * @param[out] map This map is cleared and a property map of actor and its children is filled in
+ */
+void CreatePropertyMap( Actor actor, Property::Map& map );
+
+/**
+ * @brief Creates a Property::Map from the image provided.
+ *
+ * @param[in] image The image from which a Property::Map should be created
+ * @param[out] map This map is cleared and a property map of the image is filled in
+ */
+void CreatePropertyMap( Image image, Property::Map& map );
+
}
} // namespace Dali