From: Kimmo Hoikka Date: Thu, 18 Oct 2018 10:49:12 +0000 (+0100) Subject: Reducing boilerplate on default property metadata X-Git-Tag: dali_1.3.48~7 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;ds=sidebyside;h=647f5b051fe0930336dd202bd41084201c5de6b9;p=platform%2Fcore%2Fuifw%2Fdali-core.git Reducing boilerplate on default property metadata - moved all per class metadata to TypeRegistry - derived classes register default property table with TypeRegistration - removed bitflags from PropertyDetails and added index to make iterating property tables easier Change-Id: Iccdef021309163566cbd1b17c7d00d557355afdf --- diff --git a/automated-tests/src/dali/utc-Dali-CameraActor.cpp b/automated-tests/src/dali/utc-Dali-CameraActor.cpp index 46eb92f..31a8653 100644 --- a/automated-tests/src/dali/utc-Dali-CameraActor.cpp +++ b/automated-tests/src/dali/utc-Dali-CameraActor.cpp @@ -20,6 +20,8 @@ #include #include #include +#include + #include "dali-test-suite-utils/dali-test-suite-utils.h" @@ -66,6 +68,16 @@ const char* const RENDER_SHADOW_FRAGMENT_SOURCE = " gl_FragColor = vec4(uShadowColor.rgb, uShadowColor.a * alpha);\n" "}\n"; +struct PropertyDetails +{ + std::string name; ///< The name of the property. + Property::Type type; ///< The property type. + bool writable; ///< Whether the property is writable + bool animatable; ///< Whether the property is animatable. + bool constraintInput; ///< Whether the property can be used as an input to a constraint. + Property::Index enumIndex; ///< Used to check the index is correct within a debug build. +}; + } // Anonymous namespace @@ -1265,6 +1277,124 @@ int UtcDaliCameraActorDefaultProperties(void) END_TEST; } +template< typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8> +void TEST_CAMERA_PROPERTY( P1 camera, P2 stringName, P3 type, P4 isWriteable, P5 isAnimateable, P6 isConstraintInput, P7 enumName, P8 LOCATION ) +{ + DALI_TEST_EQUALS( camera.GetPropertyName( enumName ), stringName, LOCATION ); + DALI_TEST_EQUALS( camera.GetPropertyIndex( stringName ), static_cast(enumName), LOCATION ); + DALI_TEST_EQUALS( camera.GetPropertyType( enumName ), type, LOCATION ); + DALI_TEST_EQUALS( camera.IsPropertyWritable( enumName ), isWriteable, LOCATION ); + DALI_TEST_EQUALS( camera.IsPropertyAnimatable( enumName ), isAnimateable, LOCATION ); + DALI_TEST_EQUALS( camera.IsPropertyAConstraintInput( enumName ), isConstraintInput, LOCATION ); +} +int UtcDaliCameraActorDefaultPropertiesInherited(void) +{ + TestApplication application; + + CameraActor actor = CameraActor::New(); + Stage stage = Stage::GetCurrent(); + stage.Add(actor); + stage.GetRenderTaskList().GetTask(0).SetCameraActor( actor ); + + Stage::GetCurrent().Add( actor ); + application.Render( 0 ); + application.SendNotification(); + + const PropertyDetails CAMERA_DEFAULT_PROPERTY[] = + { +// actor + { "parentOrigin", Property::VECTOR3, true, false, true, Dali::Actor::Property::PARENT_ORIGIN }, + { "parentOriginX", Property::FLOAT, true, false, true, Dali::Actor::Property::PARENT_ORIGIN_X }, + { "parentOriginY", Property::FLOAT, true, false, true, Dali::Actor::Property::PARENT_ORIGIN_Y }, + { "parentOriginZ", Property::FLOAT, true, false, true, Dali::Actor::Property::PARENT_ORIGIN_Z }, + { "anchorPoint", Property::VECTOR3, true, false, true, Dali::Actor::Property::ANCHOR_POINT }, + { "anchorPointX", Property::FLOAT, true, false, true, Dali::Actor::Property::ANCHOR_POINT_X }, + { "anchorPointY", Property::FLOAT, true, false, true, Dali::Actor::Property::ANCHOR_POINT_Y }, + { "anchorPointZ", Property::FLOAT, true, false, true, Dali::Actor::Property::ANCHOR_POINT_Z }, + { "size", Property::VECTOR3, true, true, true, Dali::Actor::Property::SIZE }, + { "sizeWidth", Property::FLOAT, true, true, true, Dali::Actor::Property::SIZE_WIDTH }, + { "sizeHeight", Property::FLOAT, true, true, true, Dali::Actor::Property::SIZE_HEIGHT }, + { "sizeDepth", Property::FLOAT, true, true, true, Dali::Actor::Property::SIZE_DEPTH }, + { "position", Property::VECTOR3, true, true, true, Dali::Actor::Property::POSITION }, + { "positionX", Property::FLOAT, true, true, true, Dali::Actor::Property::POSITION_X }, + { "positionY", Property::FLOAT, true, true, true, Dali::Actor::Property::POSITION_Y }, + { "positionZ", Property::FLOAT, true, true, true, Dali::Actor::Property::POSITION_Z }, + { "worldPosition", Property::VECTOR3, false, false, true, Dali::Actor::Property::WORLD_POSITION }, + { "worldPositionX", Property::FLOAT, false, false, true, Dali::Actor::Property::WORLD_POSITION_X }, + { "worldPositionY", Property::FLOAT, false, false, true, Dali::Actor::Property::WORLD_POSITION_Y }, + { "worldPositionZ", Property::FLOAT, false, false, true, Dali::Actor::Property::WORLD_POSITION_Z }, + { "orientation", Property::ROTATION, true, true, true, Dali::Actor::Property::ORIENTATION }, + { "worldOrientation", Property::ROTATION, false, false, true, Dali::Actor::Property::WORLD_ORIENTATION }, + { "scale", Property::VECTOR3, true, true, true, Dali::Actor::Property::SCALE }, + { "scaleX", Property::FLOAT, true, true, true, Dali::Actor::Property::SCALE_X }, + { "scaleY", Property::FLOAT, true, true, true, Dali::Actor::Property::SCALE_Y }, + { "scaleZ", Property::FLOAT, true, true, true, Dali::Actor::Property::SCALE_Z }, + { "worldScale", Property::VECTOR3, false, false, true, Dali::Actor::Property::WORLD_SCALE }, + { "visible", Property::BOOLEAN, true, true, true, Dali::Actor::Property::VISIBLE }, + { "color", Property::VECTOR4, true, true, true, Dali::Actor::Property::COLOR }, + { "colorRed", Property::FLOAT, true, true, true, Dali::Actor::Property::COLOR_RED }, + { "colorGreen", Property::FLOAT, true, true, true, Dali::Actor::Property::COLOR_GREEN }, + { "colorBlue", Property::FLOAT, true, true, true, Dali::Actor::Property::COLOR_BLUE }, + { "colorAlpha", Property::FLOAT, true, true, true, Dali::Actor::Property::COLOR_ALPHA }, + { "worldColor", Property::VECTOR4, false, false, true, Dali::Actor::Property::WORLD_COLOR }, + { "worldMatrix", Property::MATRIX, false, false, true, Dali::Actor::Property::WORLD_MATRIX }, + { "name", Property::STRING, true, false, false, Dali::Actor::Property::NAME }, + { "sensitive", Property::BOOLEAN, true, false, false, Dali::Actor::Property::SENSITIVE }, + { "leaveRequired", Property::BOOLEAN, true, false, false, Dali::Actor::Property::LEAVE_REQUIRED }, + { "inheritOrientation", Property::BOOLEAN, true, false, false, Dali::Actor::Property::INHERIT_ORIENTATION }, + { "inheritScale", Property::BOOLEAN, true, false, false, Dali::Actor::Property::INHERIT_SCALE }, + { "colorMode", Property::STRING, true, false, false, Dali::Actor::Property::COLOR_MODE }, + { "positionInheritance", Property::STRING, true, false, false, Dali::Actor::Property::POSITION_INHERITANCE }, + { "drawMode", Property::STRING, true, false, false, Dali::Actor::Property::DRAW_MODE }, + { "sizeModeFactor", Property::VECTOR3, true, false, false, Dali::Actor::Property::SIZE_MODE_FACTOR }, + { "widthResizePolicy", Property::STRING, true, false, false, Dali::Actor::Property::WIDTH_RESIZE_POLICY }, + { "heightResizePolicy", Property::STRING, true, false, false, Dali::Actor::Property::HEIGHT_RESIZE_POLICY }, + { "sizeScalePolicy", Property::STRING, true, false, false, Dali::Actor::Property::SIZE_SCALE_POLICY }, + { "widthForHeight", Property::BOOLEAN, true, false, false, Dali::Actor::Property::WIDTH_FOR_HEIGHT }, + { "heightForWidth", Property::BOOLEAN, true, false, false, Dali::Actor::Property::HEIGHT_FOR_WIDTH }, + { "padding", Property::VECTOR4, true, false, false, Dali::Actor::Property::PADDING }, + { "minimumSize", Property::VECTOR2, true, false, false, Dali::Actor::Property::MINIMUM_SIZE }, + { "maximumSize", Property::VECTOR2, true, false, false, Dali::Actor::Property::MAXIMUM_SIZE }, + { "inheritPosition", Property::BOOLEAN, true, false, false, Dali::Actor::Property::INHERIT_POSITION }, + { "clippingMode", Property::STRING, true, false, false, Dali::Actor::Property::CLIPPING_MODE }, + { "layoutDirection", Property::STRING, true, false, false, Dali::Actor::Property::LAYOUT_DIRECTION }, + { "inheritLayoutDirection", Property::BOOLEAN, true, false, false, Dali::Actor::Property::INHERIT_LAYOUT_DIRECTION }, + { "siblingOrder", Property::INTEGER, true, false, false, Dali::DevelActor::Property::SIBLING_ORDER }, + { "opacity", Property::FLOAT, true, true, true, Dali::DevelActor::Property::OPACITY }, + { "screenPosition", Property::VECTOR2, false, false, false, Dali::DevelActor::Property::SCREEN_POSITION }, + { "positionUsesAnchorPoint",Property::BOOLEAN, true, false, false, Dali::DevelActor::Property::POSITION_USES_ANCHOR_POINT }, + { "culled", Property::BOOLEAN, false, false, true, Dali::DevelActor::Property::CULLED }, +// camera own + { "type", Property::STRING, true, false, true, Dali::CameraActor::Property::TYPE }, + { "projectionMode", Property::STRING, true, false, true, Dali::CameraActor::Property::PROJECTION_MODE }, + { "fieldOfView", Property::FLOAT, true, false, true, Dali::CameraActor::Property::FIELD_OF_VIEW }, + { "aspectRatio", Property::FLOAT, true, false, true, Dali::CameraActor::Property::ASPECT_RATIO }, + { "nearPlaneDistance", Property::FLOAT, true, false, true, Dali::CameraActor::Property::NEAR_PLANE_DISTANCE }, + { "farPlaneDistance", Property::FLOAT, true, false, true, Dali::CameraActor::Property::FAR_PLANE_DISTANCE }, + { "leftPlaneDistance", Property::FLOAT, true, false, true, Dali::CameraActor::Property::LEFT_PLANE_DISTANCE }, + { "rightPlaneDistance", Property::FLOAT, true, false, true, Dali::CameraActor::Property::RIGHT_PLANE_DISTANCE }, + { "topPlaneDistance", Property::FLOAT, true, false, true, Dali::CameraActor::Property::TOP_PLANE_DISTANCE }, + { "bottomPlaneDistance", Property::FLOAT, true, false, true, Dali::CameraActor::Property::BOTTOM_PLANE_DISTANCE }, + { "targetPosition", Property::VECTOR3, true, false, true, Dali::CameraActor::Property::TARGET_POSITION }, + { "projectionMatrix", Property::MATRIX, false, false, true, Dali::CameraActor::Property::PROJECTION_MATRIX }, + { "viewMatrix", Property::MATRIX, false, false, true, Dali::CameraActor::Property::VIEW_MATRIX }, + { "invertYAxis", Property::BOOLEAN, true, false, true, Dali::CameraActor::Property::INVERT_Y_AXIS } + }; + + for( uint32_t index = 0; index < (sizeof(CAMERA_DEFAULT_PROPERTY)/sizeof(PropertyDetails)); ++index ) + { + TEST_CAMERA_PROPERTY( actor, + CAMERA_DEFAULT_PROPERTY[ index ].name, + CAMERA_DEFAULT_PROPERTY[ index ].type, + CAMERA_DEFAULT_PROPERTY[ index ].writable, + CAMERA_DEFAULT_PROPERTY[ index ].animatable, + CAMERA_DEFAULT_PROPERTY[ index ].constraintInput, + CAMERA_DEFAULT_PROPERTY[ index ].enumIndex, + TEST_LOCATION ); + } + END_TEST; +} + int UtcDaliCameraActorModelView(void) { TestApplication application; diff --git a/automated-tests/src/dali/utc-Dali-CustomActor.cpp b/automated-tests/src/dali/utc-Dali-CustomActor.cpp index 34392ad..761f969 100644 --- a/automated-tests/src/dali/utc-Dali-CustomActor.cpp +++ b/automated-tests/src/dali/utc-Dali-CustomActor.cpp @@ -1331,7 +1331,6 @@ int UtcDaliCustomActorSetGetProperty(void) END_TEST; } - int utcDaliActorGetTypeInfo(void) { TestApplication application; @@ -1345,3 +1344,145 @@ int utcDaliActorGetTypeInfo(void) END_TEST; } + +/** + * A custom actor that is not type registered on purpose + */ +struct UnregisteredCustomActor : public Dali::CustomActorImpl +{ + UnregisteredCustomActor() : CustomActorImpl( ACTOR_BEHAVIOUR_NONE ) + { } + virtual ~UnregisteredCustomActor() + { } + virtual void OnStageConnection( int32_t depth ) + { } + virtual void OnStageDisconnection() + { } + virtual void OnChildAdd(Actor& child) + { } + virtual void OnChildRemove(Actor& child) + { } + virtual void OnPropertySet( Property::Index index, Property::Value propertyValue ) + { } + virtual void OnSizeSet(const Vector3& targetSize) + { } + virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize) + { } + virtual bool OnTouchEvent(const TouchEvent& event) DALI_DEPRECATED_API + { return false; } + virtual bool OnHoverEvent(const HoverEvent& event) + { return false; } + virtual bool OnKeyEvent(const KeyEvent& event) + { return false; } + virtual bool OnWheelEvent(const WheelEvent& event) + { return false; } + virtual void OnRelayout( const Vector2& size, RelayoutContainer& container ) + { } + virtual void OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension ) + { } + virtual Vector3 GetNaturalSize() + { return Vector3(); } + virtual float CalculateChildSize( const Dali::Actor& child, Dimension::Type dimension ) + { return 0.f; } + virtual float GetHeightForWidth( float width ) + { return 0.f; } + virtual float GetWidthForHeight( float height ) + { return 0.f; } + virtual bool RelayoutDependentOnChildren( Dimension::Type dimension = Dimension::ALL_DIMENSIONS ) + { return false; } + virtual void OnCalculateRelayoutSize( Dimension::Type dimension ) + { } + virtual void OnLayoutNegotiated( float size, Dimension::Type dimension ) + { } +}; + +struct UnregisteredCustomActorHandle : public Dali::CustomActor +{ + static UnregisteredCustomActorHandle New() + { + UnregisteredCustomActor* impl = new UnregisteredCustomActor; + UnregisteredCustomActorHandle custom( *impl ); // takes ownership + return custom; + } + UnregisteredCustomActorHandle() + { + } + UnregisteredCustomActorHandle( Internal::CustomActor* impl ) + : CustomActor( impl ) + { + } + UnregisteredCustomActorHandle( UnregisteredCustomActor& impl ) + : CustomActor( impl ) + { + } + static UnregisteredCustomActorHandle DownCast( BaseHandle handle ) + { + UnregisteredCustomActorHandle hndl; + CustomActor custom = Dali::CustomActor::DownCast( handle ); + if( custom ) + { + CustomActorImpl& customImpl = custom.GetImplementation(); + + UnregisteredCustomActor* impl = dynamic_cast(&customImpl); + + if( impl ) + { + hndl = UnregisteredCustomActorHandle(customImpl.GetOwner()); + } + } + return hndl; + } + +}; + +int UtcDaliCustomActorSetGetActorPropertyActionSignal(void) +{ + TestApplication application; // Need the type registry + + auto custom = UnregisteredCustomActorHandle::New(); + Stage::GetCurrent().Add( custom ); + + // should have all actor properties + DALI_TEST_EQUALS( custom.GetPropertyType( Actor::Property::COLOR ), Property::VECTOR4, TEST_LOCATION ); + auto actorHandle = Actor::New(); + DALI_TEST_EQUALS( custom.GetPropertyCount(), actorHandle.GetPropertyCount(), TEST_LOCATION ); + + DALI_TEST_EQUALS( custom.IsVisible(), true, TEST_LOCATION ); + custom.SetProperty( Actor::Property::VISIBLE, false ); + application.SendNotification(); + application.Render(); // IsVisible returns scene value + DALI_TEST_EQUALS( custom.IsVisible(), false, TEST_LOCATION ); + + // should have custom actor typename (as it has not registered itself) + DALI_TEST_EQUALS( "CustomActor", custom.GetTypeName(), TEST_LOCATION ); + + // should have actor actions + custom.DoAction( "show", Property::Map() ); + DALI_TEST_EQUALS( custom.GetProperty( Actor::Property::VISIBLE ).Get(), true, TEST_LOCATION ); + + Animation animation = Animation::New(0.01f); // very short animation + // should be able to animate actor property + animation.AnimateTo( Property( custom, Actor::Property::POSITION ), Vector3( 100.0f, 150.0f, 200.0f ) ); + animation.Play(); + + application.SendNotification(); + application.Render(1000.f); + + DALI_TEST_EQUALS( Vector3( 100.0f, 150.0f, 200.0f ), custom.GetProperty( Actor::Property::POSITION ).Get(), TEST_LOCATION ); + DALI_TEST_EQUALS( Vector3( 100.0f, 150.0f, 200.0f ), custom.GetCurrentPosition(), TEST_LOCATION ); + + Dali::WeakHandle weakRef( custom ); + // should have actor signals + custom.ConnectSignal( &application, "offStage", + [weakRef]() + { + DALI_TEST_EQUALS( weakRef.GetHandle().OnStage(), false, TEST_LOCATION ); + } ); + + Stage::GetCurrent().Remove( custom ); + Stage::GetCurrent().Add( custom ); + + + END_TEST; +} + diff --git a/automated-tests/src/dali/utc-Dali-Renderer.cpp b/automated-tests/src/dali/utc-Dali-Renderer.cpp index b517ac7..4f64bb8 100644 --- a/automated-tests/src/dali/utc-Dali-Renderer.cpp +++ b/automated-tests/src/dali/utc-Dali-Renderer.cpp @@ -89,7 +89,6 @@ void renderer_test_cleanup(void) test_return_value = TET_PASS; } - int UtcDaliRendererNew01(void) { TestApplication application; @@ -164,6 +163,83 @@ int UtcDaliRendererDownCast02(void) END_TEST; } +// using a template to auto deduce the parameter types +template< typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8> +void TEST_RENDERER_PROPERTY( P1 renderer, P2 stringName, P3 type, P4 isWriteable, P5 isAnimateable, P6 isConstraintInput, P7 enumName, P8 LOCATION ) +{ + DALI_TEST_EQUALS( renderer.GetPropertyName( enumName ), stringName, LOCATION ); + DALI_TEST_EQUALS( renderer.GetPropertyIndex( stringName ), static_cast(enumName), LOCATION ); + DALI_TEST_EQUALS( renderer.GetPropertyType( enumName ), type, LOCATION ); + DALI_TEST_EQUALS( renderer.IsPropertyWritable( enumName ), isWriteable, LOCATION ); + DALI_TEST_EQUALS( renderer.IsPropertyAnimatable( enumName ), isAnimateable, LOCATION ); + DALI_TEST_EQUALS( renderer.IsPropertyAConstraintInput( enumName ), isConstraintInput, LOCATION ); +} + +int UtcDaliRendererDefaultProperties(void) +{ + TestApplication application; +/* from renderer-impl.cpp + DALI_PROPERTY( "depthIndex", INTEGER, true, false, false, Dali::Renderer::Property::DEPTH_INDEX ) + DALI_PROPERTY( "faceCullingMode", INTEGER, true, false, false, Dali::Renderer::Property::FACE_CULLING_MODE ) + DALI_PROPERTY( "blendMode", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_MODE ) + DALI_PROPERTY( "blendEquationRgb", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_EQUATION_RGB ) + DALI_PROPERTY( "blendEquationAlpha", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_EQUATION_ALPHA ) + DALI_PROPERTY( "blendFactorSrcRgb", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_FACTOR_SRC_RGB ) + DALI_PROPERTY( "blendFactorDestRgb", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_FACTOR_DEST_RGB ) + DALI_PROPERTY( "blendFactorSrcAlpha", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_FACTOR_SRC_ALPHA ) + DALI_PROPERTY( "blendFactorDestAlpha", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_FACTOR_DEST_ALPHA ) + DALI_PROPERTY( "blendColor", VECTOR4, true, false, false, Dali::Renderer::Property::BLEND_COLOR ) + DALI_PROPERTY( "blendPreMultipliedAlpha", BOOLEAN, true, false, false, Dali::Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA ) + DALI_PROPERTY( "indexRangeFirst", INTEGER, true, false, false, Dali::Renderer::Property::INDEX_RANGE_FIRST ) + DALI_PROPERTY( "indexRangeCount", INTEGER, true, false, false, Dali::Renderer::Property::INDEX_RANGE_COUNT ) + DALI_PROPERTY( "depthWriteMode", INTEGER, true, false, false, Dali::Renderer::Property::DEPTH_WRITE_MODE ) + DALI_PROPERTY( "depthFunction", INTEGER, true, false, false, Dali::Renderer::Property::DEPTH_FUNCTION ) + DALI_PROPERTY( "depthTestMode", INTEGER, true, false, false, Dali::Renderer::Property::DEPTH_TEST_MODE ) + DALI_PROPERTY( "renderMode", INTEGER, true, false, false, Dali::Renderer::Property::RENDER_MODE ) + DALI_PROPERTY( "stencilFunction", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_FUNCTION ) + DALI_PROPERTY( "stencilFunctionMask", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_FUNCTION_MASK ) + DALI_PROPERTY( "stencilFunctionReference", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_FUNCTION_REFERENCE ) + DALI_PROPERTY( "stencilMask", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_MASK ) + DALI_PROPERTY( "stencilOperationOnFail", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_OPERATION_ON_FAIL ) + DALI_PROPERTY( "stencilOperationOnZFail", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL ) + DALI_PROPERTY( "stencilOperationOnZPass", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_OPERATION_ON_Z_PASS ) + DALI_PROPERTY( "opacity", FLOAT, true, true, true, Dali::DevelRenderer::Property::OPACITY ) +*/ + + Geometry geometry = CreateQuadGeometry(); + Shader shader = CreateShader(); + Renderer renderer = Renderer::New(geometry, shader); + DALI_TEST_EQUALS( renderer.GetPropertyCount(), 25, TEST_LOCATION ); + + TEST_RENDERER_PROPERTY( renderer, "depthIndex", Property::INTEGER, true, false, false, Renderer::Property::DEPTH_INDEX, TEST_LOCATION ); + TEST_RENDERER_PROPERTY( renderer, "faceCullingMode", Property::INTEGER, true, false, false, Renderer::Property::FACE_CULLING_MODE, TEST_LOCATION ); + TEST_RENDERER_PROPERTY( renderer, "blendMode", Property::INTEGER, true, false, false, Renderer::Property::BLEND_MODE, TEST_LOCATION ); + TEST_RENDERER_PROPERTY( renderer, "blendEquationRgb", Property::INTEGER, true, false, false, Renderer::Property::BLEND_EQUATION_RGB, TEST_LOCATION ); + TEST_RENDERER_PROPERTY( renderer, "blendEquationAlpha", Property::INTEGER, true, false, false, Renderer::Property::BLEND_EQUATION_ALPHA, TEST_LOCATION ); + TEST_RENDERER_PROPERTY( renderer, "blendFactorSrcRgb", Property::INTEGER, true, false, false, Renderer::Property::BLEND_FACTOR_SRC_RGB, TEST_LOCATION ); + TEST_RENDERER_PROPERTY( renderer, "blendFactorDestRgb", Property::INTEGER, true, false, false, Renderer::Property::BLEND_FACTOR_DEST_RGB, TEST_LOCATION ); + TEST_RENDERER_PROPERTY( renderer, "blendFactorSrcAlpha", Property::INTEGER, true, false, false, Renderer::Property::BLEND_FACTOR_SRC_ALPHA, TEST_LOCATION ); + TEST_RENDERER_PROPERTY( renderer, "blendFactorDestAlpha", Property::INTEGER, true, false, false, Renderer::Property::BLEND_FACTOR_DEST_ALPHA, TEST_LOCATION ); + TEST_RENDERER_PROPERTY( renderer, "blendColor", Property::VECTOR4, true, false, false, Renderer::Property::BLEND_COLOR, TEST_LOCATION ); + TEST_RENDERER_PROPERTY( renderer, "blendPreMultipliedAlpha", Property::BOOLEAN, true, false, false, Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, TEST_LOCATION ); + TEST_RENDERER_PROPERTY( renderer, "indexRangeFirst", Property::INTEGER, true, false, false, Renderer::Property::INDEX_RANGE_FIRST, TEST_LOCATION ); + TEST_RENDERER_PROPERTY( renderer, "indexRangeCount", Property::INTEGER, true, false, false, Renderer::Property::INDEX_RANGE_COUNT, TEST_LOCATION ); + TEST_RENDERER_PROPERTY( renderer, "depthWriteMode", Property::INTEGER, true, false, false, Renderer::Property::DEPTH_WRITE_MODE, TEST_LOCATION ); + TEST_RENDERER_PROPERTY( renderer, "depthFunction", Property::INTEGER, true, false, false, Renderer::Property::DEPTH_FUNCTION, TEST_LOCATION ); + TEST_RENDERER_PROPERTY( renderer, "depthTestMode", Property::INTEGER, true, false, false, Renderer::Property::DEPTH_TEST_MODE, TEST_LOCATION ); + TEST_RENDERER_PROPERTY( renderer, "renderMode", Property::INTEGER, true, false, false, Renderer::Property::RENDER_MODE, TEST_LOCATION ); + TEST_RENDERER_PROPERTY( renderer, "stencilFunction", Property::INTEGER, true, false, false, Renderer::Property::STENCIL_FUNCTION, TEST_LOCATION ); + TEST_RENDERER_PROPERTY( renderer, "stencilFunctionMask", Property::INTEGER, true, false, false, Renderer::Property::STENCIL_FUNCTION_MASK, TEST_LOCATION ); + TEST_RENDERER_PROPERTY( renderer, "stencilFunctionReference",Property::INTEGER, true, false, false, Renderer::Property::STENCIL_FUNCTION_REFERENCE, TEST_LOCATION ); + TEST_RENDERER_PROPERTY( renderer, "stencilMask", Property::INTEGER, true, false, false, Renderer::Property::STENCIL_MASK, TEST_LOCATION ); + TEST_RENDERER_PROPERTY( renderer, "stencilOperationOnFail", Property::INTEGER, true, false, false, Renderer::Property::STENCIL_OPERATION_ON_FAIL, TEST_LOCATION ); + TEST_RENDERER_PROPERTY( renderer, "stencilOperationOnZFail", Property::INTEGER, true, false, false, Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL, TEST_LOCATION ); + TEST_RENDERER_PROPERTY( renderer, "stencilOperationOnZPass", Property::INTEGER, true, false, false, Renderer::Property::STENCIL_OPERATION_ON_Z_PASS, TEST_LOCATION ); + TEST_RENDERER_PROPERTY( renderer, "opacity", Property::FLOAT, true, true, true, DevelRenderer::Property::OPACITY, TEST_LOCATION ); + + END_TEST; +} + int UtcDaliRendererSetGetGeometry(void) { TestApplication application; diff --git a/automated-tests/src/dali/utc-Dali-Shader.cpp b/automated-tests/src/dali/utc-Dali-Shader.cpp index cf419be..af8a65f 100644 --- a/automated-tests/src/dali/utc-Dali-Shader.cpp +++ b/automated-tests/src/dali/utc-Dali-Shader.cpp @@ -116,6 +116,25 @@ int UtcDaliShaderDownCast02(void) END_TEST; } +int UtcDaliShaderDefaultProperties(void) +{ + TestApplication application; +// from shader-impl.cpp +// DALI_PROPERTY( "program", MAP, true, false, false, Dali::Shader::Property::PROGRAM ) + + Shader shader = Shader::New(VertexSource, FragmentSource); + DALI_TEST_EQUALS( shader.GetPropertyCount(), 1, TEST_LOCATION ); + + DALI_TEST_EQUALS( shader.GetPropertyName( Shader::Property::PROGRAM ), "program", TEST_LOCATION ); + DALI_TEST_EQUALS( shader.GetPropertyIndex( "program" ), (Property::Index)Shader::Property::PROGRAM, TEST_LOCATION ); + DALI_TEST_EQUALS( shader.GetPropertyType( Shader::Property::PROGRAM ), Property::MAP, TEST_LOCATION ); + DALI_TEST_EQUALS( shader.IsPropertyWritable( Shader::Property::PROGRAM ), true, TEST_LOCATION ); + DALI_TEST_EQUALS( shader.IsPropertyAnimatable( Shader::Property::PROGRAM ), false, TEST_LOCATION ); + DALI_TEST_EQUALS( shader.IsPropertyAConstraintInput( Shader::Property::PROGRAM ), false, TEST_LOCATION ); + + END_TEST; +} + int UtcDaliShaderConstraint01(void) { TestApplication application; diff --git a/automated-tests/src/dali/utc-Dali-TypeRegistry.cpp b/automated-tests/src/dali/utc-Dali-TypeRegistry.cpp index fb2bb5b..e9178c9 100644 --- a/automated-tests/src/dali/utc-Dali-TypeRegistry.cpp +++ b/automated-tests/src/dali/utc-Dali-TypeRegistry.cpp @@ -1074,7 +1074,7 @@ int UtcDaliTypeRegistryPropertyRegistrationP(void) typeInfo.GetPropertyIndices( indices ); size_t typePropertyCount = typeInfo.GetPropertyCount(); - DALI_TEST_EQUALS( indices.Size(), 1u, TEST_LOCATION ); + DALI_TEST_EQUALS( indices.Size(), Actor::New().GetPropertyCount() + 1u, TEST_LOCATION ); DALI_TEST_EQUALS( indices.Size(), typePropertyCount, TEST_LOCATION ); // Ensure indices returned from actor and customActor differ by two @@ -1164,7 +1164,7 @@ int UtcDaliTypeRegistryAnimatablePropertyRegistrationP(void) // Check property count of type-info is 1 Property::IndexContainer indices; typeInfo.GetPropertyIndices( indices ); - DALI_TEST_EQUALS( indices.Size(), 1u, TEST_LOCATION ); + DALI_TEST_EQUALS( indices.Size(), customActor.GetPropertyCount(), TEST_LOCATION ); // Ensure indices returned from actor and customActor differ by one Actor actor = Actor::New(); @@ -1267,10 +1267,10 @@ int UtcDaliTypeRegistryAnimatablePropertyRegistrationWithDefaultP(void) // Check the animatable property type DALI_TEST_EQUALS( customActor.GetPropertyType( animatablePropertyIndex ), Property::FLOAT, TEST_LOCATION ); - // Check property count of type-info is 1 + // Check property count of type-info Property::IndexContainer indices; typeInfo.GetPropertyIndices( indices ); - DALI_TEST_EQUALS( indices.Size(), 1u, TEST_LOCATION ); + DALI_TEST_EQUALS( indices.Size(), customActor.GetPropertyCount(), TEST_LOCATION ); // Ensure indices returned from actor and customActor differ by one Actor actor = Actor::New(); @@ -1376,10 +1376,10 @@ int UtcDaliTypeRegistryAnimatablePropertyComponentRegistrationP(void) // Check the animatable property type DALI_TEST_EQUALS( customActor.GetPropertyType( animatablePropertyIndex ), animatablePropertyType, TEST_LOCATION ); - // Check property count of type-info is 1 + // Check property count of type-info Property::IndexContainer indices; typeInfo.GetPropertyIndices( indices ); - DALI_TEST_EQUALS( indices.Size(), 1u, TEST_LOCATION ); + DALI_TEST_EQUALS( indices.Size(), customActor.GetPropertyCount(), TEST_LOCATION ); // Register animatable property components std::string animatablePropertyComponentName1( "animatableProp1X" ); @@ -2057,24 +2057,14 @@ int UtcDaliPropertyRegistrationPropertyWritableP(void) int UtcDaliPropertyRegistrationPropertyWritableN(void) { - // Currently Actors don't register properties with the type registry - TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) ); Internal::TypeInfo& typeInfoImpl = GetImplementation( typeInfo ); - try - { - typeInfoImpl.IsPropertyWritable( Actor::Property::COLOR); - tet_result( TET_FAIL ); + DALI_TEST_EQUALS( typeInfoImpl.IsPropertyWritable( Actor::Property::COLOR), true, TEST_LOCATION ); - } - catch ( DaliException& e ) - { - DALI_TEST_ASSERT( e, "Cannot find property index", TEST_LOCATION ); - } END_TEST; - } + int UtcDaliPropertyRegistrationPropertyAnimatable(void) { TestApplication application; @@ -2111,7 +2101,7 @@ int UtcDaliPropertyRegistrationPropertyAnimatable(void) END_TEST; } -int UtcDaliPropertyRegistrationInvalidGetAndSet(void) +int UtcDaliPropertyRegistrationUnregisteredGetAndSet(void) { TestApplication application; int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 2000; @@ -2125,47 +2115,14 @@ int UtcDaliPropertyRegistrationInvalidGetAndSet(void) Actor customActor = Actor::DownCast( handle ); DALI_TEST_CHECK( customActor ); - // Try to set an index that hasn't been added - try - { - customActor.SetProperty( propertyIndex, true ); - tet_result( TET_FAIL ); - } - catch ( DaliException& e ) - { - DALI_TEST_ASSERT( e, "! \"Cannot find property index", TEST_LOCATION ); - } + // Try to set an index that hasn't been registered, this is a no-op for now, to be fixed in future + customActor.SetProperty( propertyIndex, true ); +// DALI_TEST_EQUALS( true, customActor.GetProperty( propertyIndex ).Get(), TEST_LOCATION); - try - { - customActor.SetProperty( animatablePropertyIndex, true ); - tet_result( TET_FAIL ); - } - catch ( DaliException& e ) - { - DALI_TEST_ASSERT( e, "! \"Cannot find property index", TEST_LOCATION ); - } - - // Try to get an index that hasn't been added - try - { - (void) customActor.GetProperty< bool >( propertyIndex ); - tet_result( TET_FAIL ); - } - catch ( DaliException& e ) - { - DALI_TEST_ASSERT( e, "! \"Cannot find property index", TEST_LOCATION ); - } + // Try to set an index that hasn't been registered + customActor.SetProperty( animatablePropertyIndex, true ); + DALI_TEST_EQUALS( true, customActor.GetProperty( animatablePropertyIndex ).Get(), TEST_LOCATION); - try - { - (void) customActor.GetProperty< bool >( animatablePropertyIndex ); - tet_result( TET_FAIL ); - } - catch ( DaliException& e ) - { - DALI_TEST_ASSERT( e, "! \"Cannot find property index", TEST_LOCATION ); - } END_TEST; } @@ -2490,7 +2447,7 @@ int UtcDaliTypeInfoGetPropertyCountP1(void) DALI_TEST_CHECK( typeInfo ); size_t actorPropertyCount = typeInfo.GetPropertyCount(); - DALI_TEST_EQUALS( actorPropertyCount == 0 , true, TEST_LOCATION ); // No event only props + DALI_TEST_EQUALS( actorPropertyCount, Actor::New().GetPropertyCount(), TEST_LOCATION ); // No event only props END_TEST; } @@ -2506,7 +2463,7 @@ int UtcDaliTypeInfoGetPropertyCountP2(void) typeInfo.GetPropertyIndices( indices ); DALI_TEST_EQUALS( propertyCount > 0 && propertyCount <= indices.Size(), true, TEST_LOCATION ); - DALI_TEST_EQUALS( propertyCount == 2, true, TEST_LOCATION ); + DALI_TEST_EQUALS( propertyCount, Actor::New().GetPropertyCount() + 2, TEST_LOCATION ); END_TEST; } diff --git a/dali/devel-api/object/csharp-type-registry.cpp b/dali/devel-api/object/csharp-type-registry.cpp index bee45d8..20186d6 100644 --- a/dali/devel-api/object/csharp-type-registry.cpp +++ b/dali/devel-api/object/csharp-type-registry.cpp @@ -31,7 +31,9 @@ bool RegisterType( const std::string& name, const std::type_info& baseType, CSha { Internal::TypeRegistry *impl = Internal::TypeRegistry::Get(); - return impl->Register( name, baseType, f ); + impl->Register( name, baseType, f ); + + return true; } bool RegisterProperty( const std::string& objectName, diff --git a/dali/internal/event/actors/actor-impl.cpp b/dali/internal/event/actors/actor-impl.cpp index 0154209..7effe7c 100644 --- a/dali/internal/event/actors/actor-impl.cpp +++ b/dali/internal/event/actors/actor-impl.cpp @@ -214,7 +214,7 @@ DALI_PROPERTY( "opacity", FLOAT, true, true, true, Dali: DALI_PROPERTY( "screenPosition", VECTOR2, false, false, false, Dali::DevelActor::Property::SCREEN_POSITION ) DALI_PROPERTY( "positionUsesAnchorPoint", BOOLEAN, true, false, false, Dali::DevelActor::Property::POSITION_USES_ANCHOR_POINT ) DALI_PROPERTY( "culled", BOOLEAN, false, false, true, Dali::DevelActor::Property::CULLED ) -DALI_PROPERTY_TABLE_END( DEFAULT_ACTOR_PROPERTY_START_INDEX ) +DALI_PROPERTY_TABLE_END( DEFAULT_ACTOR_PROPERTY_START_INDEX, ActorDefaultProperties ) // Signals @@ -240,7 +240,7 @@ BaseHandle CreateActor() return Dali::Actor::New(); } -TypeRegistration mType( typeid(Dali::Actor), typeid(Dali::Handle), CreateActor ); +TypeRegistration mType( typeid(Dali::Actor), typeid(Dali::Handle), CreateActor, ActorDefaultProperties ); SignalConnectorType signalConnector1( mType, SIGNAL_TOUCHED, &Actor::DoConnectSignal ); SignalConnectorType signalConnector2( mType, SIGNAL_HOVERED, &Actor::DoConnectSignal ); @@ -2492,90 +2492,6 @@ void Actor::DepthTraverseActorTree( OwnerPointer& sceneG } } -uint32_t Actor::GetDefaultPropertyCount() const -{ - return DEFAULT_PROPERTY_COUNT; -} - -void Actor::GetDefaultPropertyIndices( Property::IndexContainer& indices ) const -{ - indices.Reserve( DEFAULT_PROPERTY_COUNT ); - - for( int32_t i = 0; i < DEFAULT_PROPERTY_COUNT; ++i ) - { - indices.PushBack( i ); - } -} - -const char* Actor::GetDefaultPropertyName( Property::Index index ) const -{ - if( index < DEFAULT_PROPERTY_COUNT ) - { - return DEFAULT_PROPERTY_DETAILS[ index ].name; - } - - return NULL; -} - -Property::Index Actor::GetDefaultPropertyIndex( const std::string& name ) const -{ - Property::Index index = Property::INVALID_INDEX; - - // Look for name in default properties - for( int32_t i = 0; i < DEFAULT_PROPERTY_COUNT; ++i ) - { - const Internal::PropertyDetails* property = &DEFAULT_PROPERTY_DETAILS[ i ]; - if( 0 == name.compare( property->name ) ) - { - index = i; - break; - } - } - - return index; -} - -bool Actor::IsDefaultPropertyWritable( Property::Index index ) const -{ - if( index < DEFAULT_PROPERTY_COUNT ) - { - return DEFAULT_PROPERTY_DETAILS[ index ].writable; - } - - return false; -} - -bool Actor::IsDefaultPropertyAnimatable( Property::Index index ) const -{ - if( index < DEFAULT_PROPERTY_COUNT ) - { - return DEFAULT_PROPERTY_DETAILS[ index ].animatable; - } - - return false; -} - -bool Actor::IsDefaultPropertyAConstraintInput( Property::Index index ) const -{ - if( index < DEFAULT_PROPERTY_COUNT ) - { - return DEFAULT_PROPERTY_DETAILS[ index ].constraintInput; - } - - return false; -} - -Property::Type Actor::GetDefaultPropertyType( Property::Index index ) const -{ - if( index < DEFAULT_PROPERTY_COUNT ) - { - return DEFAULT_PROPERTY_DETAILS[ index ].type; - } - - // index out of range...return Property::NONE - return Property::NONE; -} - void Actor::SetDefaultProperty( Property::Index index, const Property::Value& property ) { switch( index ) @@ -3499,7 +3415,7 @@ const PropertyBase* Actor::GetSceneObjectAnimatableProperty( Property::Index ind if ( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX && index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX ) { - AnimatablePropertyMetadata* animatable = RegisterAnimatableProperty( index ); + AnimatablePropertyMetadata* animatable = GetSceneAnimatableProperty( index, nullptr ); DALI_ASSERT_ALWAYS( animatable && "Property index is invalid" ); property = animatable->GetSceneGraphProperty(); @@ -3613,7 +3529,7 @@ const PropertyInputImpl* Actor::GetSceneObjectInputProperty( Property::Index ind if ( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX && index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX ) { - AnimatablePropertyMetadata* animatable = RegisterAnimatableProperty( index ); + AnimatablePropertyMetadata* animatable = GetSceneAnimatableProperty( index, nullptr ); DALI_ASSERT_ALWAYS( animatable && "Property index is invalid" ); property = animatable->GetSceneGraphProperty(); @@ -3791,7 +3707,7 @@ int Actor::GetPropertyComponentIndex( Property::Index index ) const if ( ( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX ) ) { // check whether the animatable property is registered already, if not then register one. - AnimatablePropertyMetadata* animatableProperty = RegisterAnimatableProperty(index); + AnimatablePropertyMetadata* animatableProperty = GetSceneAnimatableProperty( index, nullptr ); if( animatableProperty ) { componentIndex = animatableProperty->componentIndex; diff --git a/dali/internal/event/actors/actor-impl.h b/dali/internal/event/actors/actor-impl.h index a64bf73..92e25e5 100755 --- a/dali/internal/event/actors/actor-impl.h +++ b/dali/internal/event/actors/actor-impl.h @@ -1617,6 +1617,7 @@ public: void RebuildDepthTree(); protected: + /** * Traverse the actor tree, inserting actors into the depth tree in sibling order. * @param[in] sceneGraphNodeDepths A vector capturing the nodes and their depth index @@ -1629,46 +1630,6 @@ public: // Default property extensions from Object /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyCount() - */ - virtual uint32_t GetDefaultPropertyCount() const; - - /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyIndices() - */ - virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const; - - /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyName() - */ - virtual const char* GetDefaultPropertyName( Property::Index index ) const; - - /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyIndex() - */ - virtual Property::Index GetDefaultPropertyIndex( const std::string& name ) const; - - /** - * @copydoc Dali::Internal::Object::IsDefaultPropertyWritable() - */ - virtual bool IsDefaultPropertyWritable( Property::Index index ) const; - - /** - * @copydoc Dali::Internal::Object::IsDefaultPropertyAnimatable() - */ - virtual bool IsDefaultPropertyAnimatable( Property::Index index ) const; - - /** - * @copydoc Dali::Internal::Object::IsDefaultPropertyAConstraintInput() - */ - virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const; - - /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyType() - */ - virtual Property::Type GetDefaultPropertyType( Property::Index index ) const; - - /** * @copydoc Dali::Internal::Object::SetDefaultProperty() */ virtual void SetDefaultProperty( Property::Index index, const Property::Value& propertyValue ); diff --git a/dali/internal/event/actors/camera-actor-impl.cpp b/dali/internal/event/actors/camera-actor-impl.cpp index 4530783..04efae9 100644 --- a/dali/internal/event/actors/camera-actor-impl.cpp +++ b/dali/internal/event/actors/camera-actor-impl.cpp @@ -64,7 +64,7 @@ DALI_PROPERTY( "targetPosition", VECTOR3, true, false, true, Dal DALI_PROPERTY( "projectionMatrix", MATRIX, false, false, true, Dali::CameraActor::Property::PROJECTION_MATRIX ) DALI_PROPERTY( "viewMatrix", MATRIX, false, false, true, Dali::CameraActor::Property::VIEW_MATRIX ) DALI_PROPERTY( "invertYAxis", BOOLEAN, true, false, true, Dali::CameraActor::Property::INVERT_Y_AXIS ) -DALI_PROPERTY_TABLE_END( DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX ) +DALI_PROPERTY_TABLE_END( DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX, CameraDefaultProperties ) // calculate the far plane distance for a 16bit depth buffer with 4 bits per unit precision void CalculateClippingAndZ( float width, float height, float& nearClippingPlane, float& farClippingPlane, float& cameraZ ) @@ -79,7 +79,7 @@ BaseHandle Create() return Dali::CameraActor::New(); } -TypeRegistration mType( typeid( Dali::CameraActor ), typeid( Dali::Actor ), Create ); +TypeRegistration mType( typeid( Dali::CameraActor ), typeid( Dali::Actor ), Create, CameraDefaultProperties ); /** * Builds the picking ray in the world reference system from an orthographic camera @@ -513,117 +513,6 @@ const SceneGraph::Camera* CameraActor::GetCamera() const return mSceneObject; } -unsigned int CameraActor::GetDefaultPropertyCount() const -{ - return Actor::GetDefaultPropertyCount() + DEFAULT_PROPERTY_COUNT; -} - -void CameraActor::GetDefaultPropertyIndices( Property::IndexContainer& indices ) const -{ - Actor::GetDefaultPropertyIndices( indices ); // Actor class properties - - indices.Reserve( indices.Size() + DEFAULT_PROPERTY_COUNT ); - - int index = DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX; - for ( int i = 0; i < DEFAULT_PROPERTY_COUNT; ++i, ++index ) - { - indices.PushBack( index ); - } -} - -bool CameraActor::IsDefaultPropertyWritable( Property::Index index ) const -{ - if( index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT ) - { - return Actor::IsDefaultPropertyWritable( index ); - } - - return DEFAULT_PROPERTY_DETAILS[index - DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX].writable; -} - -bool CameraActor::IsDefaultPropertyAnimatable( Property::Index index ) const -{ - if( index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT ) - { - return Actor::IsDefaultPropertyAnimatable( index ); - } - - return DEFAULT_PROPERTY_DETAILS[index - DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX].animatable; -} - -bool CameraActor::IsDefaultPropertyAConstraintInput( Property::Index index ) const -{ - if( index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT ) - { - return Actor::IsDefaultPropertyAConstraintInput( index ); - } - - return DEFAULT_PROPERTY_DETAILS[index - DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX].constraintInput; -} - -Property::Type CameraActor::GetDefaultPropertyType( Property::Index index ) const -{ - if( index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT ) - { - return Actor::GetDefaultPropertyType( index ); - } - else - { - index -= DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX; - - if ( ( index >= 0 ) && ( index < DEFAULT_PROPERTY_COUNT ) ) - { - return DEFAULT_PROPERTY_DETAILS[index].type; - } - else - { - // index out-of-bounds - return Property::NONE; - } - } -} - -const char* CameraActor::GetDefaultPropertyName( Property::Index index ) const -{ - if(index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT) - { - return Actor::GetDefaultPropertyName(index); - } - else - { - index -= DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX; - - if ( ( index >= 0 ) && ( index < DEFAULT_PROPERTY_COUNT ) ) - { - return DEFAULT_PROPERTY_DETAILS[index].name; - } - return NULL; - } -} - -Property::Index CameraActor::GetDefaultPropertyIndex(const std::string& name) const -{ - Property::Index index = Property::INVALID_INDEX; - - // Look for name in current class' default properties - for( int i = 0; i < DEFAULT_PROPERTY_COUNT; ++i ) - { - if( 0 == strcmp( name.c_str(), DEFAULT_PROPERTY_DETAILS[i].name ) ) // dont want to convert rhs to string - { - index = i + DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX; - break; - } - } - - // If not found, check in base class - if( Property::INVALID_INDEX == index ) - { - index = Actor::GetDefaultPropertyIndex( name ); - } - - return index; -} - void CameraActor::SetDefaultProperty( Property::Index index, const Property::Value& propertyValue ) { if(index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT) diff --git a/dali/internal/event/actors/camera-actor-impl.h b/dali/internal/event/actors/camera-actor-impl.h index a3a4ae6..0623333 100644 --- a/dali/internal/event/actors/camera-actor-impl.h +++ b/dali/internal/event/actors/camera-actor-impl.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_CAMERA_ACTOR_H /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -199,41 +199,6 @@ public: public: // properties /** - * copydoc Dali::Internal::Object - */ - virtual unsigned int GetDefaultPropertyCount() const; - - /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyIndices() - */ - virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const; - - /** - * copydoc Dali::Internal::Object - */ - virtual bool IsDefaultPropertyAnimatable( Property::Index index ) const; - - /** - * @copydoc Dali::Internal::Object::IsDefaultPropertyAConstraintInput() - */ - virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const; - - /** - * copydoc Dali::Internal::Object - */ - virtual Property::Type GetDefaultPropertyType( Property::Index index ) const; - - /** - * copydoc Dali::Internal::Object - */ - virtual const char* GetDefaultPropertyName( Property::Index index ) const; - - /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyIndex() - */ - virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const; - - /** * copydoc Dali::Internal::Object::SetDefaultProperty() */ virtual void SetDefaultProperty( Property::Index index, const Property::Value& propertyValue ); @@ -249,11 +214,6 @@ public: // properties virtual Property::Value GetDefaultPropertyCurrentValue( Property::Index index ) const; /** - * copydoc Dali::Internal::Object - */ - virtual bool IsDefaultPropertyWritable( Property::Index index ) const ; - - /** * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty() */ virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const; diff --git a/dali/internal/event/actors/layer-impl.cpp b/dali/internal/event/actors/layer-impl.cpp index b790963..e3c0bea 100644 --- a/dali/internal/event/actors/layer-impl.cpp +++ b/dali/internal/event/actors/layer-impl.cpp @@ -58,7 +58,7 @@ DALI_PROPERTY_TABLE_BEGIN DALI_PROPERTY( "clippingEnable", BOOLEAN, true, false, true, Dali::Layer::Property::CLIPPING_ENABLE ) DALI_PROPERTY( "clippingBox", RECTANGLE, true, false, true, Dali::Layer::Property::CLIPPING_BOX ) DALI_PROPERTY( "behavior", STRING, true, false, false, Dali::Layer::Property::BEHAVIOR ) -DALI_PROPERTY_TABLE_END( DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX ) +DALI_PROPERTY_TABLE_END( DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX, LayerDefaultProperties ) // Actions @@ -72,7 +72,7 @@ BaseHandle Create() return Dali::Layer::New(); } -TypeRegistration mType( typeid( Dali::Layer ), typeid( Dali::Actor ), Create ); +TypeRegistration mType( typeid( Dali::Layer ), typeid( Dali::Actor ), Create, LayerDefaultProperties ); TypeAction a1( mType, ACTION_RAISE, &Layer::DoAction ); TypeAction a2( mType, ACTION_LOWER, &Layer::DoAction ); @@ -354,110 +354,6 @@ const SceneGraph::Layer& Layer::GetSceneLayerOnStage() const return dynamic_cast< const SceneGraph::Layer& >( *mNode ); } -unsigned int Layer::GetDefaultPropertyCount() const -{ - return Actor::GetDefaultPropertyCount() + DEFAULT_PROPERTY_COUNT; -} - -void Layer::GetDefaultPropertyIndices( Property::IndexContainer& indices ) const -{ - Actor::GetDefaultPropertyIndices( indices ); // Actor class properties - indices.Reserve( indices.Size() + DEFAULT_PROPERTY_COUNT ); - - int32_t index = DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX; - for ( int32_t i = 0; i < DEFAULT_PROPERTY_COUNT; ++i, ++index ) - { - indices.PushBack( index ); - } -} - -bool Layer::IsDefaultPropertyWritable( Property::Index index ) const -{ - if( index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT ) - { - return Actor::IsDefaultPropertyWritable( index ); - } - - return DEFAULT_PROPERTY_DETAILS[ index - DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX ].writable; -} - -bool Layer::IsDefaultPropertyAnimatable( Property::Index index ) const -{ - if( index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT ) - { - return Actor::IsDefaultPropertyAnimatable( index ); - } - - return DEFAULT_PROPERTY_DETAILS[ index - DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX ].animatable; -} - -bool Layer::IsDefaultPropertyAConstraintInput( Property::Index index ) const -{ - if( index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT ) - { - return Actor::IsDefaultPropertyAConstraintInput( index ); - } - - return DEFAULT_PROPERTY_DETAILS[ index - DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX ].constraintInput; -} - -Property::Type Layer::GetDefaultPropertyType( Property::Index index ) const -{ - if( index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT ) - { - return Actor::GetDefaultPropertyType( index ); - } - - index -= DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX; - - if ( ( index >= 0 ) && ( index < DEFAULT_PROPERTY_COUNT ) ) - { - return DEFAULT_PROPERTY_DETAILS[index].type; - } - - // index out-of-bounds - return Property::NONE; -} - -const char* Layer::GetDefaultPropertyName( Property::Index index ) const -{ - if( index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT ) - { - return Actor::GetDefaultPropertyName( index ); - } - - index -= DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX; - if ( ( index >= 0 ) && ( index < DEFAULT_PROPERTY_COUNT ) ) - { - return DEFAULT_PROPERTY_DETAILS[index].name; - } - - return NULL; -} - -Property::Index Layer::GetDefaultPropertyIndex(const std::string& name) const -{ - Property::Index index = Property::INVALID_INDEX; - - // Look for name in current class' default properties - for( int32_t i = 0; i < DEFAULT_PROPERTY_COUNT; ++i ) - { - const Internal::PropertyDetails* property = &DEFAULT_PROPERTY_DETAILS[i]; - if( 0 == name.compare( property->name ) ) // dont want to convert rhs to string - { - index = i + DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX; - break; - } - } - if( Property::INVALID_INDEX == index ) - { - // If not found, check in base class - index = Actor::GetDefaultPropertyIndex( name ); - } - - return index; -} - void Layer::SetDefaultProperty( Property::Index index, const Property::Value& propertyValue ) { if( index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT ) diff --git a/dali/internal/event/actors/layer-impl.h b/dali/internal/event/actors/layer-impl.h index cf56615..92d5f7d 100644 --- a/dali/internal/event/actors/layer-impl.h +++ b/dali/internal/event/actors/layer-impl.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_LAYER_H /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -211,45 +211,6 @@ public: static bool DoAction(BaseObject* object, const std::string& actionName, const Property::Map& attributes); public: // Default property extensions from Object - /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyCount() - */ - virtual unsigned int GetDefaultPropertyCount() const; - - /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyIndices() - */ - virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const; - - /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyName() - */ - virtual const char* GetDefaultPropertyName(Property::Index index) const; - - /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyIndex() - */ - virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const; - - /** - * @copydoc Dali::Internal::Object::IsDefaultPropertyWritable() - */ - virtual bool IsDefaultPropertyWritable(Property::Index index) const; - - /** - * @copydoc Dali::Internal::Object::IsDefaultPropertyAnimatable() - */ - virtual bool IsDefaultPropertyAnimatable(Property::Index index) const; - - /** - * @copydoc Dali::Internal::Object::IsDefaultPropertyAConstraintInput() - */ - virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const; - - /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyType() - */ - virtual Property::Type GetDefaultPropertyType(Property::Index index) const; /** * @copydoc Dali::Internal::Object::SetDefaultProperty() diff --git a/dali/internal/event/animation/constrainer.h b/dali/internal/event/animation/constrainer.h index 81982a7..0e13a8f 100644 --- a/dali/internal/event/animation/constrainer.h +++ b/dali/internal/event/animation/constrainer.h @@ -2,7 +2,7 @@ #define __DALI_INTERNAL_CONSTRAINER_H__ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -53,46 +53,6 @@ public: public: // Object methods /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyCount() - */ - virtual unsigned int GetDefaultPropertyCount() const{return 0;} - - /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyIndices() - */ - virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const{} - - /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyName() - */ - virtual const char* GetDefaultPropertyName( Property::Index index ) const{return 0;} - - /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyIndex() - */ - virtual Property::Index GetDefaultPropertyIndex( const std::string& name ) const{return Property::INVALID_INDEX;} - - /** - * @copydoc Dali::Internal::Object::IsDefaultPropertyWritable() - */ - virtual bool IsDefaultPropertyWritable( Property::Index index ) const{return false;} - - /** - * @copydoc Dali::Internal::Object::IsDefaultPropertyAnimatable() - */ - virtual bool IsDefaultPropertyAnimatable( Property::Index index ) const{return false;} - - /** - * @copydoc Dali::Internal::Object::IsDefaultPropertyAConstraintInput() - */ - virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const{return false;} - - /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyType() - */ - virtual Property::Type GetDefaultPropertyType( Property::Index index ) const{return Property::NONE;} - - /** * @copydoc Dali::Internal::Object::SetDefaultProperty() */ virtual void SetDefaultProperty( Property::Index index, const Property::Value& propertyValue ){} diff --git a/dali/internal/event/animation/linear-constrainer-impl.cpp b/dali/internal/event/animation/linear-constrainer-impl.cpp index 8d17414..0613adb 100644 --- a/dali/internal/event/animation/linear-constrainer-impl.cpp +++ b/dali/internal/event/animation/linear-constrainer-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,9 +22,10 @@ #include // for strcmp // INTERNAL INCLUDES -#include #include #include +#include +#include namespace Dali @@ -41,7 +42,14 @@ namespace DALI_PROPERTY_TABLE_BEGIN DALI_PROPERTY( "value", ARRAY, true, false, false, Dali::LinearConstrainer::Property::VALUE ) DALI_PROPERTY( "progress", ARRAY, true, false, false, Dali::LinearConstrainer::Property::PROGRESS ) -DALI_PROPERTY_TABLE_END( DEFAULT_OBJECT_PROPERTY_START_INDEX ) +DALI_PROPERTY_TABLE_END( DEFAULT_OBJECT_PROPERTY_START_INDEX, LinearConstrainerDefaultProperties ) + +BaseHandle Create() +{ + return Dali::LinearConstrainer::New(); +} + +TypeRegistration mType( typeid( Dali::LinearConstrainer ), typeid( Dali::Handle ), Create, LinearConstrainerDefaultProperties ); } //Unnamed namespace @@ -59,60 +67,6 @@ LinearConstrainer::~LinearConstrainer() { } -unsigned int LinearConstrainer::GetDefaultPropertyCount() const -{ - return DEFAULT_PROPERTY_COUNT; -} - -void LinearConstrainer::GetDefaultPropertyIndices( Property::IndexContainer& indices ) const -{ - indices.Reserve( DEFAULT_PROPERTY_COUNT ); - - for ( Property::Index i = 0; i < DEFAULT_PROPERTY_COUNT; ++i ) - { - indices.PushBack( i ); - } -} - -const char* LinearConstrainer::GetDefaultPropertyName(Property::Index index) const -{ - if ( ( index >= 0 ) && ( index < DEFAULT_PROPERTY_COUNT ) ) - { - return DEFAULT_PROPERTY_DETAILS[index].name; - } - - // index out of range - return NULL; -} - -Property::Index LinearConstrainer::GetDefaultPropertyIndex(const std::string& name) const -{ - Property::Index index = Property::INVALID_INDEX; - - // Look for name in default properties - for( Property::Index i = 0; i < DEFAULT_PROPERTY_COUNT; ++i ) - { - const Internal::PropertyDetails* property = &DEFAULT_PROPERTY_DETAILS[ i ]; - if( 0 == strcmp( name.c_str(), property->name ) ) - { - index = i; - break; - } - } - return index; -} - -Property::Type LinearConstrainer::GetDefaultPropertyType(Property::Index index) const -{ - if( index < DEFAULT_PROPERTY_COUNT ) - { - return DEFAULT_PROPERTY_DETAILS[index].type; - } - - // index out of range - return Property::NONE; -} - Property::Value LinearConstrainer::GetDefaultProperty( Property::Index index ) const { if( index == Dali::LinearConstrainer::Property::VALUE ) @@ -183,36 +137,6 @@ void LinearConstrainer::SetDefaultProperty( Property::Index index, const Propert } } -bool LinearConstrainer::IsDefaultPropertyWritable(Property::Index index) const -{ - if( index < DEFAULT_PROPERTY_COUNT ) - { - return DEFAULT_PROPERTY_DETAILS[index].writable; - } - - return false; -} - -bool LinearConstrainer::IsDefaultPropertyAnimatable(Property::Index index) const -{ - if( index < DEFAULT_PROPERTY_COUNT ) - { - return DEFAULT_PROPERTY_DETAILS[index].animatable; - } - - return false; -} - -bool LinearConstrainer::IsDefaultPropertyAConstraintInput( Property::Index index ) const -{ - if( index < DEFAULT_PROPERTY_COUNT ) - { - return DEFAULT_PROPERTY_DETAILS[index].constraintInput; - } - - return false; -} - void LinearConstrainer::Apply( Property target, Property source, const Vector2& range, const Vector2& wrap) { Dali::Constraint constraint = Dali::Constraint::New( target.object, target.propertyIndex, LinearConstraintFunctor( mValue, mProgress, range, wrap ) ); diff --git a/dali/internal/event/animation/linear-constrainer-impl.h b/dali/internal/event/animation/linear-constrainer-impl.h index 87b284a..892ce4e 100644 --- a/dali/internal/event/animation/linear-constrainer-impl.h +++ b/dali/internal/event/animation/linear-constrainer-impl.h @@ -164,46 +164,6 @@ protected: private: /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyCount() - */ - virtual unsigned int GetDefaultPropertyCount() const; - - /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyIndices() - */ - virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const; - - /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyName() - */ - virtual const char* GetDefaultPropertyName(Property::Index index) const; - - /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyIndex() - */ - virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const; - - /** - * @copydoc Dali::Internal::Object::IsDefaultPropertyWritable() - */ - virtual bool IsDefaultPropertyWritable(Property::Index index) const; - - /** - * @copydoc Dali::Internal::Object::IsDefaultPropertyAnimatable() - */ - virtual bool IsDefaultPropertyAnimatable(Property::Index index) const; - - /** - * @copydoc Dali::Internal::Object::IsDefaultPropertyAConstraintInput() - */ - virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const; - - /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyType() - */ - virtual Property::Type GetDefaultPropertyType(Property::Index index) const; - - /** * @copydoc Dali::Internal::Object::SetDefaultProperty() */ virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue); diff --git a/dali/internal/event/animation/path-constrainer-impl.cpp b/dali/internal/event/animation/path-constrainer-impl.cpp index 88004cf..bcb998e 100644 --- a/dali/internal/event/animation/path-constrainer-impl.cpp +++ b/dali/internal/event/animation/path-constrainer-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,9 +22,10 @@ #include // for strcmp // INTERNAL INCLUDES -#include #include #include +#include +#include namespace Dali { @@ -41,7 +42,14 @@ DALI_PROPERTY_TABLE_BEGIN DALI_PROPERTY( "forward", VECTOR3, true, false, false, Dali::PathConstrainer::Property::FORWARD ) DALI_PROPERTY( "points", ARRAY, true, false, false, Dali::PathConstrainer::Property::POINTS ) DALI_PROPERTY( "controlPoints", ARRAY, true, false, false, Dali::PathConstrainer::Property::CONTROL_POINTS ) -DALI_PROPERTY_TABLE_END( DEFAULT_OBJECT_PROPERTY_START_INDEX ) +DALI_PROPERTY_TABLE_END( DEFAULT_OBJECT_PROPERTY_START_INDEX, PathConstrainerDefaultProperties ) + +BaseHandle Create() +{ + return Dali::PathConstrainer::New(); +} + +TypeRegistration mType( typeid( Dali::PathConstrainer ), typeid( Dali::Handle ), Create, PathConstrainerDefaultProperties ); } //Unnamed namespace @@ -60,60 +68,6 @@ PathConstrainer::~PathConstrainer() { } -unsigned int PathConstrainer::GetDefaultPropertyCount() const -{ - return DEFAULT_PROPERTY_COUNT; -} - -void PathConstrainer::GetDefaultPropertyIndices( Property::IndexContainer& indices ) const -{ - indices.Reserve( DEFAULT_PROPERTY_COUNT ); - - for ( Property::Index i = 0; i < DEFAULT_PROPERTY_COUNT; ++i ) - { - indices.PushBack( i ); - } -} - -const char* PathConstrainer::GetDefaultPropertyName(Property::Index index) const -{ - if ( ( index >= 0 ) && ( index < DEFAULT_PROPERTY_COUNT ) ) - { - return DEFAULT_PROPERTY_DETAILS[index].name; - } - - // index out of range - return NULL; -} - -Property::Index PathConstrainer::GetDefaultPropertyIndex(const std::string& name) const -{ - Property::Index index = Property::INVALID_INDEX; - - // Look for name in default properties - for( Property::Index i = 0; i < DEFAULT_PROPERTY_COUNT; ++i ) - { - const Internal::PropertyDetails* property = &DEFAULT_PROPERTY_DETAILS[ i ]; - if( 0 == strcmp( name.c_str(), property->name ) ) // dont want to convert rhs to string - { - index = i; - break; - } - } - return index; -} - -Property::Type PathConstrainer::GetDefaultPropertyType(Property::Index index) const -{ - if( index < DEFAULT_PROPERTY_COUNT ) - { - return DEFAULT_PROPERTY_DETAILS[index].type; - } - - // index out of range - return Property::NONE; -} - Property::Value PathConstrainer::GetDefaultProperty( Property::Index index ) const { if( index == Dali::PathConstrainer::Property::FORWARD ) @@ -202,36 +156,6 @@ void PathConstrainer::SetDefaultProperty( Property::Index index, const Property: } } -bool PathConstrainer::IsDefaultPropertyWritable(Property::Index index) const -{ - if( index < DEFAULT_PROPERTY_COUNT ) - { - return DEFAULT_PROPERTY_DETAILS[index].writable; - } - - return false; -} - -bool PathConstrainer::IsDefaultPropertyAnimatable(Property::Index index) const -{ - if( index < DEFAULT_PROPERTY_COUNT ) - { - return DEFAULT_PROPERTY_DETAILS[index].animatable; - } - - return false; -} - -bool PathConstrainer::IsDefaultPropertyAConstraintInput( Property::Index index ) const -{ - if( index < DEFAULT_PROPERTY_COUNT ) - { - return DEFAULT_PROPERTY_DETAILS[index].constraintInput; - } - - return false; -} - void PathConstrainer::Apply( Property target, Property source, const Vector2& range, const Vector2& wrap) { Dali::Property::Type propertyType = target.object.GetPropertyType( target.propertyIndex); diff --git a/dali/internal/event/animation/path-constrainer-impl.h b/dali/internal/event/animation/path-constrainer-impl.h index 5cbf034..c1cd898 100644 --- a/dali/internal/event/animation/path-constrainer-impl.h +++ b/dali/internal/event/animation/path-constrainer-impl.h @@ -2,7 +2,7 @@ #define __DALI_INTERNAL_PATH_CONSTRAINER_H__ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -136,46 +136,6 @@ protected: private: /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyCount() - */ - virtual unsigned int GetDefaultPropertyCount() const; - - /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyIndices() - */ - virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const; - - /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyName() - */ - virtual const char* GetDefaultPropertyName(Property::Index index) const; - - /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyIndex() - */ - virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const; - - /** - * @copydoc Dali::Internal::Object::IsDefaultPropertyWritable() - */ - virtual bool IsDefaultPropertyWritable(Property::Index index) const; - - /** - * @copydoc Dali::Internal::Object::IsDefaultPropertyAnimatable() - */ - virtual bool IsDefaultPropertyAnimatable(Property::Index index) const; - - /** - * @copydoc Dali::Internal::Object::IsDefaultPropertyAConstraintInput() - */ - virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const; - - /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyType() - */ - virtual Property::Type GetDefaultPropertyType(Property::Index index) const; - - /** * @copydoc Dali::Internal::Object::SetDefaultProperty() */ virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue); diff --git a/dali/internal/event/animation/path-impl.cpp b/dali/internal/event/animation/path-impl.cpp index 9722198..5881c36 100644 --- a/dali/internal/event/animation/path-impl.cpp +++ b/dali/internal/event/animation/path-impl.cpp @@ -22,9 +22,9 @@ #include // for strcmp // INTERNAL INCLUDES -#include #include #include +#include namespace Dali { @@ -41,7 +41,7 @@ namespace DALI_PROPERTY_TABLE_BEGIN DALI_PROPERTY( "points", ARRAY, true, false, false, Dali::Path::Property::POINTS ) DALI_PROPERTY( "controlPoints", ARRAY, true, false, false, Dali::Path::Property::CONTROL_POINTS ) -DALI_PROPERTY_TABLE_END( DEFAULT_OBJECT_PROPERTY_START_INDEX ) +DALI_PROPERTY_TABLE_END( DEFAULT_OBJECT_PROPERTY_START_INDEX, PathDefaultProperties ) /** * These coefficient arise from the cubic polynomial equations for @@ -67,7 +67,7 @@ Dali::BaseHandle Create() return Dali::Path::New(); } -Dali::TypeRegistration mType( typeid(Dali::Path), typeid(Dali::Handle), Create ); +TypeRegistration mType( typeid(Dali::Path), typeid(Dali::Handle), Create, PathDefaultProperties ); inline bool PathIsComplete(const Dali::Vector& point, const Dali::Vector& controlPoint) { @@ -99,60 +99,6 @@ Path* Path::Clone(const Path& path) return clone; } -unsigned int Path::GetDefaultPropertyCount() const -{ - return DEFAULT_PROPERTY_COUNT; -} - -void Path::GetDefaultPropertyIndices( Property::IndexContainer& indices ) const -{ - indices.Reserve( DEFAULT_PROPERTY_COUNT ); - - for ( Property::Index i = 0; i < DEFAULT_PROPERTY_COUNT; ++i ) - { - indices.PushBack( i ); - } -} - -const char* Path::GetDefaultPropertyName(Property::Index index) const -{ - if ( ( index >= 0 ) && ( index < DEFAULT_PROPERTY_COUNT ) ) - { - return DEFAULT_PROPERTY_DETAILS[index].name; - } - - // index out of range - return NULL; -} - -Property::Index Path::GetDefaultPropertyIndex(const std::string& name) const -{ - Property::Index index = Property::INVALID_INDEX; - - // Look for name in default properties - for( Property::Index i = 0; i < DEFAULT_PROPERTY_COUNT; ++i ) - { - const Internal::PropertyDetails* property = &DEFAULT_PROPERTY_DETAILS[ i ]; - if( 0 == strcmp( name.c_str(), property->name ) ) // dont want to convert rhs to string - { - index = i; - break; - } - } - return index; -} - -Property::Type Path::GetDefaultPropertyType(Property::Index index) const -{ - if( index < DEFAULT_PROPERTY_COUNT ) - { - return DEFAULT_PROPERTY_DETAILS[index].type; - } - - // index out of range - return Property::NONE; -} - Property::Value Path::GetDefaultProperty( Property::Index index ) const { if( index == Dali::Path::Property::POINTS ) @@ -225,36 +171,6 @@ void Path::SetDefaultProperty(Property::Index index, const Property::Value& prop } } -bool Path::IsDefaultPropertyWritable(Property::Index index) const -{ - if( index < DEFAULT_PROPERTY_COUNT ) - { - return DEFAULT_PROPERTY_DETAILS[index].writable; - } - - return false; -} - -bool Path::IsDefaultPropertyAnimatable(Property::Index index) const -{ - if( index < DEFAULT_PROPERTY_COUNT ) - { - return DEFAULT_PROPERTY_DETAILS[index].animatable; - } - - return false; -} - -bool Path::IsDefaultPropertyAConstraintInput( Property::Index index ) const -{ - if( index < DEFAULT_PROPERTY_COUNT ) - { - return DEFAULT_PROPERTY_DETAILS[index].constraintInput; - } - - return false; -} - void Path::AddPoint(const Vector3& point ) { mPoint.PushBack( point ); diff --git a/dali/internal/event/animation/path-impl.h b/dali/internal/event/animation/path-impl.h index c12883b..bc000c5 100644 --- a/dali/internal/event/animation/path-impl.h +++ b/dali/internal/event/animation/path-impl.h @@ -73,46 +73,6 @@ private: virtual void ObjectDestroyed(Object& object){} /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyCount() - */ - virtual unsigned int GetDefaultPropertyCount() const; - - /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyIndices() - */ - virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const; - - /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyName() - */ - virtual const char* GetDefaultPropertyName(Property::Index index) const; - - /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyIndex() - */ - virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const; - - /** - * @copydoc Dali::Internal::Object::IsDefaultPropertyWritable() - */ - virtual bool IsDefaultPropertyWritable(Property::Index index) const; - - /** - * @copydoc Dali::Internal::Object::IsDefaultPropertyAnimatable() - */ - virtual bool IsDefaultPropertyAnimatable(Property::Index index) const; - - /** - * @copydoc Dali::Internal::Object::IsDefaultPropertyAConstraintInput() - */ - virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const; - - /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyType() - */ - virtual Property::Type GetDefaultPropertyType(Property::Index index) const; - - /** * @copydoc Dali::Internal::Object::SetDefaultProperty() */ virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue); diff --git a/dali/internal/event/common/event-thread-services.cpp b/dali/internal/event/common/event-thread-services.cpp index 2f1ae09..66e87e9 100644 --- a/dali/internal/event/common/event-thread-services.cpp +++ b/dali/internal/event/common/event-thread-services.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,8 +14,10 @@ * limitations under the License. */ -#include "event-thread-services.h" +// CLASS HEADER +#include +// INTERNAL INCLUDES #include namespace Dali diff --git a/dali/internal/event/common/object-impl-helper.h b/dali/internal/event/common/object-impl-helper.h index 44ac750..830def7 100644 --- a/dali/internal/event/common/object-impl-helper.h +++ b/dali/internal/event/common/object-impl-helper.h @@ -23,9 +23,7 @@ // INTERNAL INCLUDES #include // Dali::Property -#include // DEFAULT_DERIVED_HANDLE_PROPERTY_START_INDEX -#include // Dali::Internal::PropertyDetails -#include +#include #include #include #include @@ -45,129 +43,22 @@ namespace SceneGraph class PropertyBase; class PropertyOwner; - } // namespace SceneGraph -// Typedefs to allow object methods to be passed via parameter -typedef AnimatablePropertyMetadata* (Object::*FindAnimatablePropertyMethod)( Property::Index index ) const; -typedef CustomPropertyMetadata* (Object::*FindCustomPropertyMethod)( Property::Index index ) const; - +// methods needed as parameters +using FindAnimatablePropertyMethod = AnimatablePropertyMetadata* (Object::*)(Property::Index index) const; +using FindCustomPropertyMethod = CustomPropertyMetadata* (Object::*)(Property::Index index) const; /** - * Helper template class to be used by class that implement Object - * - * Example: - *
- * typename ObjectImplHelper MyObjectImpl;
- *
- * MyObjectImpl::GetDefaultPropertyCount();
- * 
+ * Helper utilities to be used by class that implement Object */ -template -struct ObjectImplHelper +namespace ObjectImplHelper { - const PropertyDetails* DEFAULT_PROPERTY_DETAILS; - const int DEFAULT_PROPERTY_START_INDEX; - - unsigned int GetDefaultPropertyCount() const - { - return DEFAULT_PROPERTY_COUNT; - } - - void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const - { - indices.Reserve( DEFAULT_PROPERTY_COUNT ); - - for( int i = 0; i < DEFAULT_PROPERTY_COUNT; ++i ) - { - indices.PushBack( DEFAULT_PROPERTY_START_INDEX + i ); - } - } - - const char* GetDefaultPropertyName( Property::Index index ) const - { - const char* name = NULL; - - if( index >= DEFAULT_PROPERTY_START_INDEX && index < DEFAULT_PROPERTY_START_INDEX + DEFAULT_PROPERTY_MAX_COUNT ) - { - name = DEFAULT_PROPERTY_DETAILS[index - DEFAULT_PROPERTY_START_INDEX].name; - } - - return name; - } - - Property::Index GetDefaultPropertyIndex( const std::string& name ) const - { - Property::Index index = Property::INVALID_INDEX; - - // Look for name in default properties - for( int i = 0; i < DEFAULT_PROPERTY_COUNT; ++i ) - { - const Internal::PropertyDetails* property = &DEFAULT_PROPERTY_DETAILS[ i ]; - if( 0 == strcmp( name.c_str(), property->name ) ) // dont want to convert rhs to string - { - index = i; - break; - } - } - - return index; - } - - bool IsDefaultPropertyWritable( Property::Index index ) const - { - bool isWritable = false; - - if( index >= DEFAULT_PROPERTY_START_INDEX && index < DEFAULT_PROPERTY_START_INDEX + DEFAULT_PROPERTY_MAX_COUNT ) - { - isWritable = DEFAULT_PROPERTY_DETAILS[index - DEFAULT_PROPERTY_START_INDEX].writable; - } - - return isWritable; - } - - bool IsDefaultPropertyAnimatable( Property::Index index ) const - { - bool isAnimatable = false; - - if( index >= DEFAULT_PROPERTY_START_INDEX && index < DEFAULT_PROPERTY_START_INDEX + DEFAULT_PROPERTY_MAX_COUNT ) - { - isAnimatable = DEFAULT_PROPERTY_DETAILS[index - DEFAULT_PROPERTY_START_INDEX].animatable; - } - - return isAnimatable; - } - - bool IsDefaultPropertyAConstraintInput( Property::Index index ) const - { - bool isConstraintInput = false; - - if( index >= DEFAULT_PROPERTY_START_INDEX && index < DEFAULT_PROPERTY_START_INDEX + DEFAULT_PROPERTY_MAX_COUNT ) - { - isConstraintInput = DEFAULT_PROPERTY_DETAILS[index - DEFAULT_PROPERTY_START_INDEX].constraintInput; - } - - return isConstraintInput; - } - - Property::Type GetDefaultPropertyType( Property::Index index ) const - { - Property::Type type = Property::NONE; - - if( index >= DEFAULT_PROPERTY_START_INDEX && index < DEFAULT_PROPERTY_START_INDEX + DEFAULT_PROPERTY_MAX_COUNT ) - { - type = DEFAULT_PROPERTY_DETAILS[index - DEFAULT_PROPERTY_START_INDEX].type; - } - - return type; - } - // Get the (animatable) scene graph property. (All registered scene graph properties are animatable) - const SceneGraph::PropertyBase* GetRegisteredSceneGraphProperty( - const Object* object, - FindAnimatablePropertyMethod findAnimatablePropertyMethod, - FindCustomPropertyMethod findCustomPropertyMethod, - Property::Index index ) const + inline const SceneGraph::PropertyBase* GetRegisteredSceneGraphProperty( const Object* object, + FindAnimatablePropertyMethod findAnimatablePropertyMethod, + FindCustomPropertyMethod findCustomPropertyMethod, + Property::Index index ) { const SceneGraph::PropertyBase* property = NULL; if ( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX && index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX ) @@ -186,11 +77,11 @@ struct ObjectImplHelper return property; } - void SetSceneGraphProperty( EventThreadServices& eventThreadServices, - const Object* object, - Property::Index index, - const PropertyMetadata& entry, - const Property::Value& value ) const + inline void SetSceneGraphProperty( EventThreadServices& eventThreadServices, + const Object* object, + Property::Index index, + const PropertyMetadata& entry, + const Property::Value& value ) { const SceneGraph::PropertyOwner* sceneObject = object->GetSceneObject(); diff --git a/dali/internal/event/common/object-impl.cpp b/dali/internal/event/common/object-impl.cpp index 38ba17b..33c05da 100644 --- a/dali/internal/event/common/object-impl.cpp +++ b/dali/internal/event/common/object-impl.cpp @@ -29,8 +29,9 @@ #include #include #include -#include +#include #include +#include #include using Dali::Internal::SceneGraph::AnimatableProperty; @@ -45,13 +46,12 @@ namespace Internal namespace // unnamed namespace { const int SUPPORTED_CAPABILITIES = Dali::Handle::DYNAMIC_PROPERTIES; // Object provides this capability -typedef Dali::Vector::Iterator ObserverIter; -typedef Dali::Vector::ConstIterator ConstObserverIter; #if defined(DEBUG_ENABLED) Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_OBJECT" ); #endif +constexpr Property::Index MAX_PER_CLASS_PROPERTY_INDEX = ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX; } // unnamed namespace @@ -75,8 +75,8 @@ void Object::AddObserver(Observer& observer) void Object::RemoveObserver(Observer& observer) { // Find the observer... - const ConstObserverIter endIter = mObservers.End(); - for( ObserverIter iter = mObservers.Begin(); iter != endIter; ++iter) + const auto endIter = mObservers.End(); + for( auto iter = mObservers.Begin(); iter != endIter; ++iter) { if( (*iter) == &observer) { @@ -87,49 +87,6 @@ void Object::RemoveObserver(Observer& observer) DALI_ASSERT_DEBUG(endIter != mObservers.End()); } -void Object::OnSceneObjectAdd() -{ - // Notification for observers - for( ConstObserverIter iter = mObservers.Begin(), endIter = mObservers.End(); iter != endIter; ++iter) - { - (*iter)->SceneObjectAdded(*this); - } - - // enable property notifications in scene graph - EnablePropertyNotifications(); -} - -void Object::OnSceneObjectRemove() -{ - // Notification for observers - for( ConstObserverIter iter = mObservers.Begin(), endIter = mObservers.End(); iter != endIter; ++iter ) - { - (*iter)->SceneObjectRemoved(*this); - } - - // disable property notifications in scene graph - DisablePropertyNotifications(); -} - -int Object::GetPropertyComponentIndex( Property::Index index ) const -{ - int componentIndex = Property::INVALID_COMPONENT_INDEX; - - const TypeInfo* typeInfo( GetTypeInfo() ); - if ( typeInfo ) - { - componentIndex = typeInfo->GetComponentIndex(index); - } - - // For animatable property, check whether it is registered already and register it if not yet. - if ( ( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX ) && ( NULL == RegisterAnimatableProperty(index) ) ) - { - componentIndex = Property::INVALID_COMPONENT_INDEX; - } - - return componentIndex; -} - bool Object::Supports( Capability capability ) const { return (capability & SUPPORTED_CAPABILITIES); @@ -137,17 +94,13 @@ bool Object::Supports( Capability capability ) const uint32_t Object::GetPropertyCount() const { - uint32_t count = GetDefaultPropertyCount(); - - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Default Properties: %d\n", count ); - + uint32_t count = 0u; const TypeInfo* typeInfo( GetTypeInfo() ); if ( typeInfo ) { - uint32_t manual( typeInfo->GetPropertyCount() ); - count += manual; + count = typeInfo->GetPropertyCount(); - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Manual Properties: %d\n", manual ); + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Registered Properties: %d\n", count ); } uint32_t custom = static_cast( mCustomProperties.Count() ); @@ -163,66 +116,42 @@ std::string Object::GetPropertyName( Property::Index index ) const { DALI_ASSERT_ALWAYS( index > Property::INVALID_INDEX && "Property index out of bounds" ); - if ( index < DEFAULT_PROPERTY_MAX_COUNT ) - { - std::string string; - - const char * propertyName = GetDefaultPropertyName( index ); - if( propertyName ) - { - string = propertyName; - } - return string; - } - - if ( ( ( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX ) ) - || ( ( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX ) ) ) + // is this a per class or per instance property + if ( index < MAX_PER_CLASS_PROPERTY_INDEX ) { const TypeInfo* typeInfo( GetTypeInfo() ); if ( typeInfo ) { return typeInfo->GetPropertyName( index ); } - else + } + else // child property or custom property + { + CustomPropertyMetadata* custom = FindCustomProperty( index ); + if( custom ) { - DALI_ASSERT_ALWAYS( ! "Property index is invalid" ); + return custom->name; } } - CustomPropertyMetadata* custom = FindCustomProperty( index ); - if( custom ) - { - return custom->name; - } - return ""; + DALI_LOG_ERROR( "Property index %d not found\n", index ); + return std::string(); } -Property::Index Object::GetPropertyIndex(const std::string& name) const +Property::Index Object::GetPropertyIndex( const std::string& name ) const { - Property::Index index = GetDefaultPropertyIndex( name ); + Property::Index index = Property::INVALID_INDEX; - if(index == Property::INVALID_INDEX) + const TypeInfo* typeInfo( GetTypeInfo() ); + if ( typeInfo ) { - const TypeInfo* typeInfo( GetTypeInfo() ); - if ( typeInfo ) - { - index = typeInfo->GetPropertyIndex( name ); - if ( ( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX ) ) - { - // check whether the animatable property is registered already, if not then register one. - if ( NULL == RegisterAnimatableProperty(index) ) - { - index = Property::INVALID_INDEX; - } - } - } + index = typeInfo->GetPropertyIndex( name ); } - if( (index == Property::INVALID_INDEX)&&( mCustomProperties.Count() > 0 ) ) { Property::Index count = PROPERTY_CUSTOM_START_INDEX; - const PropertyMetadataLookup::ConstIterator end = mCustomProperties.End(); - for( PropertyMetadataLookup::ConstIterator iter = mCustomProperties.Begin(); iter != end; ++iter, ++count ) + const auto end = mCustomProperties.End(); + for( auto iter = mCustomProperties.Begin(); iter != end; ++iter, ++count ) { CustomPropertyMetadata* custom = static_cast(*iter); if ( custom->name == name ) @@ -251,8 +180,8 @@ Property::Index Object::GetPropertyIndex( Property::Index key ) const if( mCustomProperties.Count() > 0 ) { Property::Index count = PROPERTY_CUSTOM_START_INDEX; - const PropertyMetadataLookup::ConstIterator end = mCustomProperties.End(); - for( PropertyMetadataLookup::ConstIterator iter = mCustomProperties.Begin(); iter != end; ++iter, ++count ) + const auto end = mCustomProperties.End(); + for( auto iter = mCustomProperties.Begin(); iter != end; ++iter, ++count ) { CustomPropertyMetadata* custom = static_cast(*iter); if( custom->key == key ) @@ -294,26 +223,14 @@ bool Object::IsPropertyWritable( Property::Index index ) const bool writable = false; - if ( index < DEFAULT_PROPERTY_MAX_COUNT ) - { - writable = IsDefaultPropertyWritable( index ); - } - else if ( ( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX ) ) + // is this a per class or per instance property + if ( index < MAX_PER_CLASS_PROPERTY_INDEX ) { const TypeInfo* typeInfo( GetTypeInfo() ); if ( typeInfo ) { writable = typeInfo->IsPropertyWritable( index ); } - else - { - DALI_ASSERT_ALWAYS( ! "Invalid property index" ); - } - } - else if ( ( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX ) ) - { - // Type Registry scene-graph properties are writable. - writable = true; } else { @@ -333,19 +250,14 @@ bool Object::IsPropertyAnimatable( Property::Index index ) const bool animatable = false; - if ( index < DEFAULT_PROPERTY_MAX_COUNT ) - { - animatable = IsDefaultPropertyAnimatable( index ); - } - else if ( ( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX ) ) - { - // Type Registry event-thread only properties are not animatable. - animatable = false; - } - else if ( ( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX ) ) + // is this a per class or per instance property + if ( index < MAX_PER_CLASS_PROPERTY_INDEX ) { - // Type Registry scene-graph properties are animatable. - animatable = true; + const TypeInfo* typeInfo( GetTypeInfo() ); + if ( typeInfo ) + { + animatable = typeInfo->IsPropertyAnimatable( index ); + } } else { @@ -365,19 +277,14 @@ bool Object::IsPropertyAConstraintInput( Property::Index index ) const bool isConstraintInput = false; - if ( index < DEFAULT_PROPERTY_MAX_COUNT ) - { - isConstraintInput = IsDefaultPropertyAConstraintInput( index ); - } - else 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. - isConstraintInput = false; - } - else if ( ( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX ) ) + // is this a per class or per instance property + if ( index < MAX_PER_CLASS_PROPERTY_INDEX ) { - // scene graph properties can be used as input to a constraint. - isConstraintInput = true; + const TypeInfo* typeInfo( GetTypeInfo() ); + if ( typeInfo ) + { + isConstraintInput = typeInfo->IsPropertyAConstraintInput( index ); + } } else { @@ -396,23 +303,14 @@ Property::Type Object::GetPropertyType( Property::Index index ) const { DALI_ASSERT_ALWAYS(index > Property::INVALID_INDEX && "Property index is out of bounds" ); - if ( index < DEFAULT_PROPERTY_MAX_COUNT ) - { - return GetDefaultPropertyType( index ); - } - - if ( ( ( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX ) ) - || ( ( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX ) ) ) + // is this a per class or per instance property + if ( index < MAX_PER_CLASS_PROPERTY_INDEX ) { const TypeInfo* typeInfo( GetTypeInfo() ); if ( typeInfo ) { return typeInfo->GetPropertyType( index ); } - else - { - DALI_ASSERT_ALWAYS( ! "Cannot find property index" ); - } } CustomPropertyMetadata* custom = FindCustomProperty( index ); @@ -424,11 +322,6 @@ Property::Type Object::GetPropertyType( Property::Index index ) const return Property::NONE; } -DevelHandle::PropertySetSignalType& Object::PropertySetSignal() -{ - return mPropertySetSignal; -} - void Object::SetProperty( Property::Index index, const Property::Value& propertyValue ) { DALI_ASSERT_ALWAYS(index > Property::INVALID_INDEX && "Property index is out of bounds" ); @@ -448,17 +341,19 @@ void Object::SetProperty( Property::Index index, const Property::Value& property } else { - DALI_LOG_ERROR("Cannot find property index\n"); + // cannot register this property as there is no setter for it. + // event side properties must have a setter for now so need to be registered + DALI_LOG_ERROR( "Property index %d not found\n", index ); propertySet = false; } } else if ( ( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX ) ) { // check whether the animatable property is registered already, if not then register one. - AnimatablePropertyMetadata* animatableProperty = RegisterAnimatableProperty( index ); - if(!animatableProperty) + AnimatablePropertyMetadata* animatableProperty = GetSceneAnimatableProperty( index, &propertyValue ); + if( !animatableProperty ) { - DALI_LOG_ERROR("Cannot find property index\n"); + DALI_LOG_ERROR( "Property index %d not found\n", index ); propertySet = false; } else @@ -520,7 +415,7 @@ void Object::SetProperty( Property::Index index, const Property::Value& property } else { - DALI_LOG_ERROR("Invalid property index\n"); + DALI_LOG_ERROR( "Property index %d not found\n", index ); propertySet = false; } } @@ -554,21 +449,22 @@ Property::Value Object::GetProperty(Property::Index index) const } else { - DALI_LOG_ERROR("Cannot find property index\n"); + DALI_LOG_ERROR( "Property index %d not found\n", index ); } } else if ( ( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX ) ) { // check whether the animatable property is registered already, if not then register one. - AnimatablePropertyMetadata* animatableProperty = RegisterAnimatableProperty( index ); - if(!animatableProperty) + // this is needed because property value may have been set as full property and get as a property component + AnimatablePropertyMetadata* animatableProperty = GetSceneAnimatableProperty( index, nullptr ); + if( animatableProperty ) { - DALI_LOG_ERROR("Cannot find property index\n"); + // get the cached animatable property value + value = animatableProperty->GetPropertyValue(); } else { - // get the cached animatable property value - value = animatableProperty->GetPropertyValue(); + DALI_LOG_ERROR( "Property index %d not found\n", index ); } } else if(mCustomProperties.Count() > 0) @@ -581,7 +477,7 @@ Property::Value Object::GetProperty(Property::Index index) const } else { - DALI_LOG_ERROR("Invalid property index\n"); + DALI_LOG_ERROR( "Property index %d not found\n", index ); } } // if custom @@ -607,21 +503,22 @@ Property::Value Object::GetCurrentProperty( Property::Index index ) const } else { - DALI_LOG_ERROR("Cannot find property index\n"); + DALI_LOG_ERROR( "Property index %d not found\n", index ); } } else if ( ( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX ) ) { // check whether the animatable property is registered already, if not then register one. - AnimatablePropertyMetadata* animatableProperty = RegisterAnimatableProperty( index ); - if(!animatableProperty) + // this is needed because property value may have been set as full property and get as a property component + AnimatablePropertyMetadata* animatableProperty = GetSceneAnimatableProperty( index, nullptr ); + if( animatableProperty ) { - DALI_LOG_ERROR("Cannot find property index\n"); + // get the animatable property value + value = GetCurrentPropertyValue( *animatableProperty ); } else { - // get the animatable property value - value = GetCurrentPropertyValue( animatableProperty ); + DALI_LOG_ERROR( "Property index %d not found\n", index ); } } else if(mCustomProperties.Count() > 0) @@ -630,11 +527,11 @@ Property::Value Object::GetCurrentProperty( Property::Index index ) const if(custom) { // get the custom property value - value = GetCurrentPropertyValue( custom ); + value = GetCurrentPropertyValue( *custom ); } else { - DALI_LOG_ERROR("Invalid property index\n"); + DALI_LOG_ERROR( "Property index %d not found\n", index ); } } // if custom @@ -645,9 +542,6 @@ void Object::GetPropertyIndices( Property::IndexContainer& indices ) const { indices.Clear(); - // Default Properties - GetDefaultPropertyIndices( indices ); - // Manual Properties const TypeInfo* typeInfo( GetTypeInfo() ); if ( typeInfo ) @@ -660,9 +554,9 @@ void Object::GetPropertyIndices( Property::IndexContainer& indices ) const { indices.Reserve( indices.Size() + mCustomProperties.Count() ); - PropertyMetadataLookup::ConstIterator iter = mCustomProperties.Begin(); - const PropertyMetadataLookup::ConstIterator endIter = mCustomProperties.End(); - int i=0; + auto iter = mCustomProperties.Begin(); + const auto endIter = mCustomProperties.End(); + int32_t i = 0; for ( ; iter != endIter; ++iter, ++i ) { CustomPropertyMetadata* custom = static_cast( *iter ); @@ -679,115 +573,6 @@ void Object::GetPropertyIndices( Property::IndexContainer& indices ) const } } -bool Object::DoesCustomPropertyExist( Property::Index index ) -{ - auto metadata = FindCustomProperty( index ); - return metadata != nullptr; -} - -Property::Index Object::RegisterSceneGraphProperty(const std::string& name, Property::Index key, Property::Index index, const Property::Value& propertyValue) const -{ - // Create a new property - Dali::Internal::OwnerPointer newProperty; - - switch ( propertyValue.GetType() ) - { - case Property::BOOLEAN: - { - newProperty = new AnimatableProperty( propertyValue.Get() ); - break; - } - - case Property::INTEGER: - { - newProperty = new AnimatableProperty( propertyValue.Get() ); - break; - } - - case Property::FLOAT: - { - newProperty = new AnimatableProperty( propertyValue.Get() ); - break; - } - - case Property::VECTOR2: - { - newProperty = new AnimatableProperty( propertyValue.Get() ); - break; - } - - case Property::VECTOR3: - { - newProperty = new AnimatableProperty( propertyValue.Get() ); - break; - } - - case Property::VECTOR4: - { - newProperty = new AnimatableProperty( propertyValue.Get() ); - break; - } - - case Property::MATRIX: - { - newProperty = new AnimatableProperty( propertyValue.Get() ); - break; - } - - case Property::MATRIX3: - { - newProperty = new AnimatableProperty( propertyValue.Get() ); - break; - } - - case Property::ROTATION: - { - newProperty = new AnimatableProperty( propertyValue.Get() ); - break; - } - - case Property::RECTANGLE: - case Property::STRING: - case Property::ARRAY: - case Property::MAP: - case Property::EXTENTS: - case Property::NONE: - { - DALI_ASSERT_ALWAYS( !"PropertyType is not animatable" ); - break; - } - } - - // get the scene property owner from derived class - const SceneGraph::PropertyOwner* scenePropertyOwner = GetPropertyOwner(); - // we can only pass properties to scene graph side if there is a scene object - if( scenePropertyOwner ) - { - // keep a local pointer to the property as the OwnerPointer will pass its copy to the message - const PropertyBase* property = newProperty.Get(); - if(index >= PROPERTY_CUSTOM_START_INDEX) - { - DALI_ASSERT_ALWAYS( index <= PROPERTY_CUSTOM_MAX_INDEX && "Too many custom properties have been registered" ); - - mCustomProperties.PushBack( new CustomPropertyMetadata( name, key, propertyValue, property ) ); - } - else - { - mAnimatableProperties.PushBack( new AnimatablePropertyMetadata( index, propertyValue, property ) ); - } - - // queue a message to add the property - InstallCustomPropertyMessage( const_cast(GetEventThreadServices()), *scenePropertyOwner, newProperty ); // Message takes ownership - - return index; - } - else - { - // property was orphaned and killed so return invalid index - return Property::INVALID_INDEX; - } -} - Property::Index Object::RegisterProperty( const std::string& name, const Property::Value& propertyValue ) { return RegisterProperty( name, Property::INVALID_KEY, propertyValue, Property::ANIMATABLE ); @@ -859,9 +644,15 @@ Property::Index Object::RegisterProperty( const std::string& name, Property::Ind return index; } -Dali::PropertyNotification Object::AddPropertyNotification(Property::Index index, - int componentIndex, - const Dali::PropertyCondition& condition) +bool Object::DoesCustomPropertyExist( Property::Index index ) +{ + auto metadata = FindCustomProperty( index ); + return metadata != nullptr; +} + +Dali::PropertyNotification Object::AddPropertyNotification( Property::Index index, + int32_t componentIndex, + const Dali::PropertyCondition& condition) { if ( index >= DEFAULT_PROPERTY_MAX_COUNT ) { @@ -872,7 +663,7 @@ Dali::PropertyNotification Object::AddPropertyNotification(Property::Index index else if ( ( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX ) ) { // check whether the animatable property is registered already, if not then register one. - AnimatablePropertyMetadata* animatable = RegisterAnimatableProperty( index ); + AnimatablePropertyMetadata* animatable = GetSceneAnimatableProperty( index, nullptr ); DALI_ASSERT_ALWAYS( animatable && "Property index is invalid" ); } else if ( mCustomProperties.Count() > 0 ) @@ -902,7 +693,7 @@ void Object::RemovePropertyNotification(Dali::PropertyNotification propertyNotif { if( mPropertyNotifications ) { - PropertyNotificationContainerIter iter = mPropertyNotifications->begin(); + auto iter = mPropertyNotifications->begin(); while(iter != mPropertyNotifications->end() ) { if(*iter == propertyNotification) @@ -922,7 +713,7 @@ void Object::RemovePropertyNotifications() { if( mPropertyNotifications ) { - PropertyNotificationContainerIter iter = mPropertyNotifications->begin(); + auto iter = mPropertyNotifications->begin(); while(iter != mPropertyNotifications->end() ) { // As we can't ensure all references are removed, we can just disable @@ -979,34 +770,6 @@ void Object::NotifyPropertyAnimation( Animation& animation, Property::Index inde } } -void Object::EnablePropertyNotifications() -{ - if( mPropertyNotifications ) - { - PropertyNotificationContainerIter iter = mPropertyNotifications->begin(); - PropertyNotificationContainerIter endIter = mPropertyNotifications->end(); - - for( ; iter != endIter; ++iter ) - { - GetImplementation(*iter).Enable(); - } - } -} - -void Object::DisablePropertyNotifications() -{ - if( mPropertyNotifications ) - { - PropertyNotificationContainerIter iter = mPropertyNotifications->begin(); - PropertyNotificationContainerIter endIter = mPropertyNotifications->end(); - - for( ; iter != endIter; ++iter ) - { - GetImplementation(*iter).Disable(); - } - } -} - void Object::AddUniformMapping( Property::Index propertyIndex, const std::string& uniformName ) const { // Get the address of the property if it's a scene property @@ -1054,25 +817,430 @@ void Object::RemoveUniformMapping( const std::string& uniformName ) RemoveUniformMapMessage( GetEventThreadServices(), *sceneObject, uniformName); } -Property::Value Object::GetCurrentPropertyValue( const PropertyMetadata* entry ) const +void Object::ApplyConstraint( ConstraintBase& constraint ) { - Property::Value value; + if( !mConstraints ) + { + mConstraints = new ConstraintContainer; + } + mConstraints->push_back( Dali::Constraint( &constraint ) ); +} + +void Object::RemoveConstraint( ConstraintBase& constraint ) +{ + // NULL if the Constraint sources are destroyed before Constraint::Apply() + if( mConstraints ) + { + ConstraintIter it( std::find( mConstraints->begin(), mConstraints->end(), Dali::Constraint( &constraint ) ) ); + if( it != mConstraints->end() ) + { + mConstraints->erase( it ); + } + } +} + +void Object::RemoveConstraints() +{ + // guard against constraint sending messages during core destruction + if( mConstraints && Stage::IsInstalled() ) + { + // If we have nothing in the scene-graph, just clear constraint containers + const SceneGraph::PropertyOwner* propertyOwner = GetSceneObject(); + if ( NULL != propertyOwner ) + { + const auto endIter = mConstraints->end(); + for ( auto iter = mConstraints->begin(); endIter != iter; ++iter ) + { + GetImplementation( *iter ).RemoveInternal(); + } + } + + delete mConstraints; + mConstraints = NULL; + } +} + +void Object::RemoveConstraints( uint32_t tag ) +{ + // guard against constraint sending messages during core destruction + if( mConstraints && Stage::IsInstalled() ) + { + auto iter( mConstraints->begin() ); + while(iter != mConstraints->end() ) + { + ConstraintBase& constraint = GetImplementation( *iter ); + if( constraint.GetTag() == tag ) + { + GetImplementation( *iter ).RemoveInternal(); + iter = mConstraints->erase( iter ); + } + else + { + ++iter; + } + } + + if ( mConstraints->empty() ) + { + delete mConstraints; + mConstraints = NULL; + } + } +} + +void Object::SetTypeInfo( const TypeInfo* typeInfo ) +{ + mTypeInfo = typeInfo; +} + +int32_t Object::GetPropertyComponentIndex( Property::Index index ) const +{ + int32_t componentIndex = Property::INVALID_COMPONENT_INDEX; + + const TypeInfo* typeInfo( GetTypeInfo() ); + if ( typeInfo ) + { + componentIndex = typeInfo->GetComponentIndex(index); + } + + return componentIndex; +} + +DevelHandle::PropertySetSignalType& Object::PropertySetSignal() +{ + return mPropertySetSignal; +} + +Object::~Object() +{ + // Notification for observers + for( auto iter = mObservers.Begin(), endIter = mObservers.End(); iter != endIter; ++iter) + { + (*iter)->ObjectDestroyed(*this); + } + + delete mConstraints; + delete mPropertyNotifications; +} + +void Object::OnSceneObjectAdd() +{ + // Notification for observers + for( auto iter = mObservers.Begin(), endIter = mObservers.End(); iter != endIter; ++iter) + { + (*iter)->SceneObjectAdded(*this); + } + + // enable property notifications in scene graph + EnablePropertyNotifications(); +} + +void Object::OnSceneObjectRemove() +{ + // Notification for observers + for( auto iter = mObservers.Begin(), endIter = mObservers.End(); iter != endIter; ++iter ) + { + (*iter)->SceneObjectRemoved(*this); + } + + // disable property notifications in scene graph + DisablePropertyNotifications(); +} + +const TypeInfo* Object::GetTypeInfo() const +{ + if ( !mTypeInfo ) + { + // This uses a dynamic_cast so can be quite expensive so we only really want to do it once + // especially as the type-info does not change during the life-time of an application + + Dali::TypeInfo typeInfoHandle = TypeRegistry::Get()->GetTypeInfo( this ); + if ( typeInfoHandle ) + { + mTypeInfo = &GetImplementation( typeInfoHandle ); + } + } + + return mTypeInfo; +} + +CustomPropertyMetadata* Object::FindCustomProperty( Property::Index index ) const +{ + CustomPropertyMetadata* property( NULL ); + if ( ( index >= CHILD_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX ) ) + { + for ( std::size_t arrayIndex = 0; arrayIndex < mCustomProperties.Count(); arrayIndex++ ) + { + CustomPropertyMetadata* custom = static_cast( mCustomProperties[ arrayIndex ] ); + if( custom->childPropertyIndex == index ) + { + property = custom; + } + } + } + else + { + int arrayIndex = index - PROPERTY_CUSTOM_START_INDEX; + if( arrayIndex >= 0 ) + { + if( arrayIndex < static_cast( mCustomProperties.Count() ) ) // we can only access the first 2 billion custom properties + { + property = static_cast(mCustomProperties[ arrayIndex ]); + } + } + } + return property; +} + +AnimatablePropertyMetadata* Object::FindAnimatableProperty( Property::Index index ) const +{ + for( auto&& entry : mAnimatableProperties ) + { + AnimatablePropertyMetadata* property = static_cast( entry ); + if( property->index == index ) + { + return property; + } + } + return NULL; +} + +Property::Index Object::RegisterSceneGraphProperty(const std::string& name, Property::Index key, Property::Index index, const Property::Value& propertyValue) const +{ + // Create a new property + Dali::Internal::OwnerPointer newProperty; + + switch ( propertyValue.GetType() ) + { + case Property::BOOLEAN: + { + newProperty = new AnimatableProperty( propertyValue.Get() ); + break; + } + + case Property::INTEGER: + { + newProperty = new AnimatableProperty( propertyValue.Get() ); + break; + } + + case Property::FLOAT: + { + newProperty = new AnimatableProperty( propertyValue.Get() ); + break; + } + + case Property::VECTOR2: + { + newProperty = new AnimatableProperty( propertyValue.Get() ); + break; + } + + case Property::VECTOR3: + { + newProperty = new AnimatableProperty( propertyValue.Get() ); + break; + } + + case Property::VECTOR4: + { + newProperty = new AnimatableProperty( propertyValue.Get() ); + break; + } + + case Property::MATRIX: + { + newProperty = new AnimatableProperty( propertyValue.Get() ); + break; + } + + case Property::MATRIX3: + { + newProperty = new AnimatableProperty( propertyValue.Get() ); + break; + } + + case Property::ROTATION: + { + newProperty = new AnimatableProperty( propertyValue.Get() ); + break; + } + + case Property::RECTANGLE: + case Property::STRING: + case Property::ARRAY: + case Property::MAP: + case Property::EXTENTS: + case Property::NONE: + { + DALI_ASSERT_ALWAYS( !"PropertyType is not animatable" ); + break; + } + } + + // get the scene property owner from derived class + const SceneGraph::PropertyOwner* scenePropertyOwner = GetPropertyOwner(); + // we can only pass properties to scene graph side if there is a scene object + if( scenePropertyOwner ) + { + // keep a local pointer to the property as the OwnerPointer will pass its copy to the message + const PropertyBase* property = newProperty.Get(); + if(index >= PROPERTY_CUSTOM_START_INDEX) + { + DALI_ASSERT_ALWAYS( index <= PROPERTY_CUSTOM_MAX_INDEX && "Too many custom properties have been registered" ); + + mCustomProperties.PushBack( new CustomPropertyMetadata( name, key, propertyValue, property ) ); + } + else + { + mAnimatableProperties.PushBack( new AnimatablePropertyMetadata( index, propertyValue, property ) ); + } + + // queue a message to add the property + InstallCustomPropertyMessage( const_cast(GetEventThreadServices()), *scenePropertyOwner, newProperty ); // Message takes ownership + + return index; + } + else + { + // property was orphaned and killed so return invalid index + return Property::INVALID_INDEX; + } +} + +void Object::RegisterAnimatableProperty( const TypeInfo& typeInfo, + Property::Index index, + const Property::Value* value) const +{ + // If the property is not a component of a base property, register the whole property itself. + const std::string& propertyName = typeInfo.GetPropertyName( index ); + Property::Value initialValue; + if( value ) + { + initialValue = *value; + } + else + { + initialValue = typeInfo.GetPropertyDefaultValue( index ); + } + RegisterSceneGraphProperty( propertyName, Property::INVALID_KEY, index, initialValue ); + AddUniformMapping( index, propertyName ); +} + +AnimatablePropertyMetadata* Object::GetSceneAnimatableProperty( Property::Index index, const Property::Value* value ) const +{ + // property range already checked by calling methods + // check whether the animatable property is registered already, if not then register one. + AnimatablePropertyMetadata* animatableProperty = FindAnimatableProperty( index ); + if( !animatableProperty ) + { + const TypeInfo* typeInfo( GetTypeInfo() ); + if( typeInfo ) + { + Property::Index basePropertyIndex = typeInfo->GetBasePropertyIndex( index ); + if( basePropertyIndex == Property::INVALID_INDEX ) + { + // If the property is not a component of a base property, register the whole property itself. + RegisterAnimatableProperty( *typeInfo, index, value ); + } + else + { + // Since the property is a component of a base property, check whether the base property is registered. + animatableProperty = FindAnimatableProperty( basePropertyIndex ); + if( !animatableProperty ) + { + // If the base property is not registered yet, register the base property first. + RegisterAnimatableProperty( *typeInfo, basePropertyIndex, value ); + animatableProperty = static_cast(mAnimatableProperties[mAnimatableProperties.Size()-1]); + } + + // Create the metadata for the property component. + mAnimatableProperties.PushBack( new AnimatablePropertyMetadata( index, typeInfo->GetComponentIndex(index), animatableProperty->value, animatableProperty->GetSceneGraphProperty() ) ); + } + + // The metadata has just been added and therefore should be in the end of the vector. + animatableProperty = static_cast(mAnimatableProperties[mAnimatableProperties.Size()-1]); + } + } + + return animatableProperty; +} + +void Object::ResolveChildProperties() +{ + // Resolve index for the child property + Object* parent = GetParentObject(); + if( parent ) + { + const TypeInfo* parentTypeInfo( parent->GetTypeInfo() ); + if( parentTypeInfo ) + { + // Go through each custom property + for( auto&& entry : mCustomProperties ) + { + CustomPropertyMetadata* customProperty = static_cast( entry ); + + if( customProperty->name.empty() ) + { + if( customProperty->childPropertyIndex != Property::INVALID_INDEX ) + { + // Resolve name for any child property with no name + customProperty->name = parentTypeInfo->GetChildPropertyName( customProperty->childPropertyIndex ); + } + } + else + { + Property::Index childPropertyIndex = parentTypeInfo->GetChildPropertyIndex( customProperty->name ); + if( childPropertyIndex != Property::INVALID_INDEX ) + { + // Resolve index for any property with a name that matches the parent's child property name + customProperty->childPropertyIndex = childPropertyIndex; + } + } + } + } + } +} + +void Object::EnablePropertyNotifications() +{ + if( mPropertyNotifications ) + { + for( auto&& element : *mPropertyNotifications ) + { + GetImplementation( element ).Enable(); + } + } +} + +void Object::DisablePropertyNotifications() +{ + if( mPropertyNotifications ) + { + for( auto&& element : *mPropertyNotifications ) + { + GetImplementation( element ).Disable(); + } + } +} - DALI_ASSERT_ALWAYS( entry && "Invalid property metadata" ); +Property::Value Object::GetCurrentPropertyValue( const PropertyMetadata& entry ) const +{ + Property::Value value; - if( !entry->IsAnimatable() ) + if( !entry.IsAnimatable() ) { - value = entry->GetPropertyValue(); + value = entry.GetPropertyValue(); } else { BufferIndex bufferIndex( GetEventThreadServices().GetEventBufferIndex() ); - switch ( entry->GetType() ) + switch ( entry.GetType() ) { case Property::BOOLEAN: { - const AnimatableProperty* property = static_cast< const AnimatableProperty* >( entry->GetSceneGraphProperty() ); + const AnimatableProperty* property = static_cast< const AnimatableProperty* >( entry.GetSceneGraphProperty() ); DALI_ASSERT_DEBUG( NULL != property ); value = (*property)[ bufferIndex ]; @@ -1081,7 +1249,7 @@ Property::Value Object::GetCurrentPropertyValue( const PropertyMetadata* entry ) case Property::INTEGER: { - const AnimatableProperty* property = static_cast< const AnimatableProperty* >( entry->GetSceneGraphProperty() ); + const AnimatableProperty* property = static_cast< const AnimatableProperty* >( entry.GetSceneGraphProperty() ); DALI_ASSERT_DEBUG( NULL != property ); value = (*property)[ bufferIndex ]; @@ -1090,7 +1258,7 @@ Property::Value Object::GetCurrentPropertyValue( const PropertyMetadata* entry ) case Property::FLOAT: { - const AnimatableProperty* property = static_cast< const AnimatableProperty* >( entry->GetSceneGraphProperty() ); + const AnimatableProperty* property = static_cast< const AnimatableProperty* >( entry.GetSceneGraphProperty() ); DALI_ASSERT_DEBUG( NULL != property ); value = (*property)[ bufferIndex ]; @@ -1099,14 +1267,14 @@ Property::Value Object::GetCurrentPropertyValue( const PropertyMetadata* entry ) case Property::VECTOR2: { - const AnimatableProperty* property = static_cast< const AnimatableProperty* >( entry->GetSceneGraphProperty() ); + const AnimatableProperty* property = static_cast< const AnimatableProperty* >( entry.GetSceneGraphProperty() ); DALI_ASSERT_DEBUG( NULL != property ); - if(entry->componentIndex == 0) + if(entry.componentIndex == 0) { value = (*property)[ bufferIndex ].x; } - else if(entry->componentIndex == 1) + else if(entry.componentIndex == 1) { value = (*property)[ bufferIndex ].y; } @@ -1119,18 +1287,18 @@ Property::Value Object::GetCurrentPropertyValue( const PropertyMetadata* entry ) case Property::VECTOR3: { - const AnimatableProperty* property = static_cast< const AnimatableProperty* >( entry->GetSceneGraphProperty() ); + const AnimatableProperty* property = static_cast< const AnimatableProperty* >( entry.GetSceneGraphProperty() ); DALI_ASSERT_DEBUG( NULL != property ); - if(entry->componentIndex == 0) + if(entry.componentIndex == 0) { value = (*property)[ bufferIndex ].x; } - else if(entry->componentIndex == 1) + else if(entry.componentIndex == 1) { value = (*property)[ bufferIndex ].y; } - else if(entry->componentIndex == 2) + else if(entry.componentIndex == 2) { value = (*property)[ bufferIndex ].z; } @@ -1143,22 +1311,22 @@ Property::Value Object::GetCurrentPropertyValue( const PropertyMetadata* entry ) case Property::VECTOR4: { - const AnimatableProperty* property = static_cast< const AnimatableProperty* >( entry->GetSceneGraphProperty() ); + const AnimatableProperty* property = static_cast< const AnimatableProperty* >( entry.GetSceneGraphProperty() ); DALI_ASSERT_DEBUG( NULL != property ); - if(entry->componentIndex == 0) + if(entry.componentIndex == 0) { value = (*property)[ bufferIndex ].x; } - else if(entry->componentIndex == 1) + else if(entry.componentIndex == 1) { value = (*property)[ bufferIndex ].y; } - else if(entry->componentIndex == 2) + else if(entry.componentIndex == 2) { value = (*property)[ bufferIndex ].z; } - else if(entry->componentIndex == 3) + else if(entry.componentIndex == 3) { value = (*property)[ bufferIndex ].w; } @@ -1171,7 +1339,7 @@ Property::Value Object::GetCurrentPropertyValue( const PropertyMetadata* entry ) case Property::MATRIX: { - const AnimatableProperty* property = static_cast< const AnimatableProperty* >( entry->GetSceneGraphProperty() ); + const AnimatableProperty* property = static_cast< const AnimatableProperty* >( entry.GetSceneGraphProperty() ); DALI_ASSERT_DEBUG( NULL != property ); value = (*property)[ bufferIndex ]; @@ -1180,7 +1348,7 @@ Property::Value Object::GetCurrentPropertyValue( const PropertyMetadata* entry ) case Property::MATRIX3: { - const AnimatableProperty* property = static_cast< const AnimatableProperty* >( entry->GetSceneGraphProperty() ); + const AnimatableProperty* property = static_cast< const AnimatableProperty* >( entry.GetSceneGraphProperty() ); DALI_ASSERT_DEBUG( NULL != property ); value = (*property)[ bufferIndex ]; @@ -1189,7 +1357,7 @@ Property::Value Object::GetCurrentPropertyValue( const PropertyMetadata* entry ) case Property::ROTATION: { - const AnimatableProperty* property = static_cast< const AnimatableProperty* >( entry->GetSceneGraphProperty() ); + const AnimatableProperty* property = static_cast< const AnimatableProperty* >( entry.GetSceneGraphProperty() ); DALI_ASSERT_DEBUG( NULL != property ); value = (*property)[ bufferIndex ]; @@ -1353,241 +1521,6 @@ void Object::SetSceneGraphProperty( Property::Index index, const PropertyMetadat } } -const TypeInfo* Object::GetTypeInfo() const -{ - if ( !mTypeInfo ) - { - // This uses a dynamic_cast so can be quite expensive so we only really want to do it once - // especially as the type-info does not change during the life-time of an application - - Dali::TypeInfo typeInfoHandle = TypeRegistry::Get()->GetTypeInfo( this ); - if ( typeInfoHandle ) - { - mTypeInfo = &GetImplementation( typeInfoHandle ); - } - } - - return mTypeInfo; -} - -void Object::ApplyConstraint( ConstraintBase& constraint ) -{ - if( !mConstraints ) - { - mConstraints = new ConstraintContainer; - } - mConstraints->push_back( Dali::Constraint( &constraint ) ); -} - -void Object::RemoveConstraint( ConstraintBase& constraint ) -{ - // NULL if the Constraint sources are destroyed before Constraint::Apply() - if( mConstraints ) - { - ConstraintIter it( std::find( mConstraints->begin(), mConstraints->end(), Dali::Constraint( &constraint ) ) ); - if( it != mConstraints->end() ) - { - mConstraints->erase( it ); - } - } -} - -void Object::RemoveConstraints() -{ - // guard against constraint sending messages during core destruction - if( mConstraints && Stage::IsInstalled() ) - { - // If we have nothing in the scene-graph, just clear constraint containers - const SceneGraph::PropertyOwner* propertyOwner = GetSceneObject(); - if ( NULL != propertyOwner ) - { - const ConstraintConstIter endIter = mConstraints->end(); - for ( ConstraintIter iter = mConstraints->begin(); endIter != iter; ++iter ) - { - GetImplementation( *iter ).RemoveInternal(); - } - } - - delete mConstraints; - mConstraints = NULL; - } -} - -void Object::RemoveConstraints( uint32_t tag ) -{ - // guard against constraint sending messages during core destruction - if( mConstraints && Stage::IsInstalled() ) - { - ConstraintIter iter( mConstraints->begin() ); - while(iter != mConstraints->end() ) - { - ConstraintBase& constraint = GetImplementation( *iter ); - if( constraint.GetTag() == tag ) - { - GetImplementation( *iter ).RemoveInternal(); - iter = mConstraints->erase( iter ); - } - else - { - ++iter; - } - } - - if ( mConstraints->empty() ) - { - delete mConstraints; - mConstraints = NULL; - } - } -} - -void Object::SetTypeInfo( const TypeInfo* typeInfo ) -{ - mTypeInfo = typeInfo; -} - -Object::~Object() -{ - // Notification for observers - for( ConstObserverIter iter = mObservers.Begin(), endIter = mObservers.End(); iter != endIter; ++iter) - { - (*iter)->ObjectDestroyed(*this); - } - - delete mConstraints; - delete mPropertyNotifications; -} - -CustomPropertyMetadata* Object::FindCustomProperty( Property::Index index ) const -{ - CustomPropertyMetadata* property( NULL ); - if ( ( index >= CHILD_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX ) ) - { - for ( std::size_t arrayIndex = 0; arrayIndex < mCustomProperties.Count(); arrayIndex++ ) - { - CustomPropertyMetadata* custom = static_cast( mCustomProperties[ arrayIndex ] ); - if( custom->childPropertyIndex == index ) - { - property = custom; - } - } - } - else - { - int arrayIndex = index - PROPERTY_CUSTOM_START_INDEX; - if( arrayIndex >= 0 ) - { - if( arrayIndex < static_cast( mCustomProperties.Count() ) ) // we can only access the first 2 billion custom properties - { - property = static_cast(mCustomProperties[ arrayIndex ]); - } - } - } - return property; -} - -AnimatablePropertyMetadata* Object::FindAnimatableProperty( Property::Index index ) const -{ - const PropertyMetadataLookup::SizeType count = mAnimatableProperties.Count(); - for ( PropertyMetadataLookup::SizeType arrayIndex = 0; arrayIndex < count; ++arrayIndex ) - { - AnimatablePropertyMetadata* property = static_cast( mAnimatableProperties[ arrayIndex ] ); - if( property->index == index ) - { - return property; - } - } - return NULL; -} - -AnimatablePropertyMetadata* Object::RegisterAnimatableProperty(Property::Index index) const -{ - DALI_ASSERT_ALWAYS( (( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )) - && "Property index is out of bounds" ); - - // check whether the animatable property is registered already, if not then register one. - AnimatablePropertyMetadata* animatableProperty = FindAnimatableProperty( index ); - if( !animatableProperty ) - { - const TypeInfo* typeInfo( GetTypeInfo() ); - if( typeInfo ) - { - Property::Index basePropertyIndex = typeInfo->GetBasePropertyIndex(index); - if( basePropertyIndex == Property::INVALID_INDEX ) - { - // If the property is not a component of a base property, register the whole property itself. - const std::string& propertyName = typeInfo->GetPropertyName(index); - RegisterSceneGraphProperty(propertyName, Property::INVALID_KEY, index, typeInfo->GetPropertyDefaultValue(index)); - AddUniformMapping( index, propertyName ); - } - else - { - // Since the property is a component of a base property, check whether the base property is registered. - animatableProperty = FindAnimatableProperty( basePropertyIndex ); - if( !animatableProperty ) - { - // If the base property is not registered yet, register the base property first. - const std::string& basePropertyName = typeInfo->GetPropertyName(basePropertyIndex); - - if( Property::INVALID_INDEX != RegisterSceneGraphProperty( basePropertyName, Property::INVALID_KEY, basePropertyIndex, typeInfo->GetPropertyDefaultValue( basePropertyIndex ) ) ) - { - animatableProperty = static_cast(mAnimatableProperties[mAnimatableProperties.Size()-1]); - AddUniformMapping( basePropertyIndex, basePropertyName ); - } - } - - if(animatableProperty) - { - // Create the metadata for the property component. - mAnimatableProperties.PushBack( new AnimatablePropertyMetadata( index, typeInfo->GetComponentIndex(index), animatableProperty->value, animatableProperty->GetSceneGraphProperty() ) ); - } - } - - // The metadata has just been added and therefore should be in the end of the vector. - animatableProperty = static_cast(mAnimatableProperties[mAnimatableProperties.Size()-1]); - } - } - - return animatableProperty; -} - -void Object::ResolveChildProperties() -{ - // Resolve index for the child property - Object* parent = GetParentObject(); - if( parent ) - { - const TypeInfo* parentTypeInfo( parent->GetTypeInfo() ); - if( parentTypeInfo ) - { - // Go through each custom property - const PropertyMetadataLookup::SizeType count = mCustomProperties.Count(); - for ( PropertyMetadataLookup::SizeType arrayIndex = 0; arrayIndex < count; ++arrayIndex ) - { - CustomPropertyMetadata* customProperty = static_cast( mCustomProperties[ arrayIndex ] ); - - if( customProperty->name == "" ) - { - if( customProperty->childPropertyIndex != Property::INVALID_INDEX ) - { - // Resolve name for any child property with no name - customProperty->name = parentTypeInfo->GetChildPropertyName( customProperty->childPropertyIndex ); - } - } - else - { - Property::Index childPropertyIndex = parentTypeInfo->GetChildPropertyIndex( customProperty->name ); - if( childPropertyIndex != Property::INVALID_INDEX ) - { - // Resolve index for any property with a name that matches the parent's child property name - customProperty->childPropertyIndex = childPropertyIndex; - } - } - } - } - } -} - } // namespace Internal } // namespace Dali diff --git a/dali/internal/event/common/object-impl.h b/dali/internal/event/common/object-impl.h index 195197b..889d589 100644 --- a/dali/internal/event/common/object-impl.h +++ b/dali/internal/event/common/object-impl.h @@ -18,6 +18,9 @@ * */ +// EXTERNAL INCLUDES +#include // uint32_t + // INTERNAL INCLUDES #include #include @@ -122,106 +125,106 @@ public: * Add an observer to the object. * @param[in] observer The observer to add. */ - virtual void AddObserver( Observer& observer ); + void AddObserver( Observer& observer ); /** * Remove an observer from the object * @pre The observer has already been added. * @param[in] observer The observer to remove. */ - virtual void RemoveObserver( Observer& observer ); + void RemoveObserver( Observer& observer ); /** * @copydoc Dali::Handle::Supports() */ - virtual bool Supports( Capability capability ) const; + bool Supports( Capability capability ) const; /** * @copydoc Dali::Handle::GetPropertyCount() */ - virtual uint32_t GetPropertyCount() const; + uint32_t GetPropertyCount() const; /** * @copydoc Dali::Handle::GetPropertyName() */ - virtual std::string GetPropertyName( Property::Index index ) const; + std::string GetPropertyName( Property::Index index ) const; /** * @copydoc Dali::Handle::GetPropertyIndex() */ - virtual Property::Index GetPropertyIndex( const std::string& name ) const; + Property::Index GetPropertyIndex( const std::string& name ) const; /** * @copydoc Dali::Handle::GetPropertyIndex() */ - virtual Property::Index GetPropertyIndex( Property::Index key ) const; + Property::Index GetPropertyIndex( Property::Index key ) const; /** * @copydoc Dali::Handle::GetPropertyIndex() */ - virtual Property::Index GetPropertyIndex( Property::Key key ) const; + Property::Index GetPropertyIndex( Property::Key key ) const; /** * @copydoc Dali::Handle::IsPropertyWritable() */ - virtual bool IsPropertyWritable( Property::Index index ) const; + bool IsPropertyWritable( Property::Index index ) const; /** * @copydoc Dali::Handle::IsPropertyAnimatable() */ - virtual bool IsPropertyAnimatable( Property::Index index ) const; + bool IsPropertyAnimatable( Property::Index index ) const; /** * @copydoc Dali::Handle::IsPropertyAConstraintInput() */ - virtual bool IsPropertyAConstraintInput( Property::Index index ) const; + bool IsPropertyAConstraintInput( Property::Index index ) const; /** * @copydoc Dali::Handle::GetPropertyType() */ - virtual Property::Type GetPropertyType( Property::Index index ) const; + Property::Type GetPropertyType( Property::Index index ) const; /** * @copydoc Dali::Handle::SetProperty() */ - virtual void SetProperty( Property::Index index, const Property::Value& propertyValue ); + void SetProperty( Property::Index index, const Property::Value& propertyValue ); /** * @copydoc Dali::Handle::GetProperty() */ - virtual Property::Value GetProperty( Property::Index index ) const; + Property::Value GetProperty( Property::Index index ) const; /** * @brief Retrieves the latest value of the property on the scene-graph. * @param[in] index The index of the property required. * @return The latest value of the property on the scene-graph. */ - virtual Property::Value GetCurrentProperty( Property::Index index ) const; + Property::Value GetCurrentProperty( Property::Index index ) const; /** * @copydoc Dali::Handle::GetPropertyIndices() */ - virtual void GetPropertyIndices( Property::IndexContainer& indices ) const; + void GetPropertyIndices( Property::IndexContainer& indices ) const; /** * @copydoc Dali::Handle::RegisterProperty() */ - virtual Property::Index RegisterProperty( const std::string& name, const Property::Value& propertyValue ); + Property::Index RegisterProperty( const std::string& name, const Property::Value& propertyValue ); /** * @copydoc Dali::Handle::RegisterProperty() */ - virtual Property::Index RegisterProperty( const std::string& name, Property::Index key, const Property::Value& propertyValue ); + Property::Index RegisterProperty( const std::string& name, Property::Index key, const Property::Value& propertyValue ); /** * @copydoc Dali::Handle::RegisterProperty(std::string name, Property::Value propertyValue, Property::AccessMode accessMode) */ - virtual Property::Index RegisterProperty( const std::string& name, const Property::Value& propertyValue, Property::AccessMode accessMode ); + Property::Index RegisterProperty( const std::string& name, const Property::Value& propertyValue, Property::AccessMode accessMode ); /** * @brief Implementing method for this override */ - virtual Property::Index RegisterProperty( const std::string& name, Property::Index key, const Property::Value& propertyValue, Property::AccessMode accessMode ); + Property::Index RegisterProperty( const std::string& name, Property::Index key, const Property::Value& propertyValue, Property::AccessMode accessMode ); /** * @brief returns true if the custom property exists on this object. @@ -239,19 +242,19 @@ public: /** * @copydoc Dali::Handle::AddPropertyNotification() */ - virtual Dali::PropertyNotification AddPropertyNotification( Property::Index index, - int componentIndex, - const Dali::PropertyCondition& condition ); + Dali::PropertyNotification AddPropertyNotification( Property::Index index, + int32_t componentIndex, + const Dali::PropertyCondition& condition ); /** * @copydoc Dali::Handle::RemovePropertyNotification() */ - virtual void RemovePropertyNotification( Dali::PropertyNotification propertyNotification ); + void RemovePropertyNotification( Dali::PropertyNotification propertyNotification ); /** * @copydoc Dali::Handle::RemovePropertyNotifications() */ - virtual void RemovePropertyNotifications(); + void RemovePropertyNotifications(); /** * Notifies that a property is being animated. @@ -342,7 +345,7 @@ public: * @param[in] index The index of the property. * @return The index or Property::INVALID_COMPONENT_INDEX. */ - virtual int GetPropertyComponentIndex( Property::Index index ) const; + virtual int32_t GetPropertyComponentIndex( Property::Index index ) const; /** * @copydoc Dali::Handle::PropertySetSignal() @@ -415,11 +418,20 @@ protected: Property::Index RegisterSceneGraphProperty(const std::string& name, Property::Index key, Property::Index index, const Property::Value& propertyValue) const; /** - * Check whether the animatable property is registered already, if not then register one. + * Registers animatable scene property + * @param typeInfo to check the default value + * @param index of the property to register + * @param value initial value or nullptr + */ + void RegisterAnimatableProperty( const TypeInfo& typeInfo, Property::Index index, const Property::Value* value ) const; + + /** + * Check whether the animatable property is registered already, if not then register on. * @param [in] index The index of the property - * @return pointer to the property. + * @param [in] value optional value for the property + * @return pointer to the property metadata */ - AnimatablePropertyMetadata* RegisterAnimatableProperty(Property::Index index) const; + AnimatablePropertyMetadata* GetSceneAnimatableProperty( Property::Index index, const Property::Value* value ) const; /** * Resolve the index and name of child properties if any. @@ -429,62 +441,6 @@ protected: private: // Default property extensions for derived classes /** - * Query how many default properties the derived class supports. - * @return The number of default properties. - */ - virtual uint32_t GetDefaultPropertyCount() const = 0; - - /** - * Retrieve all the indices that are associated with the default properties supported by the derived class. - * @return A container of default property indices. - * @note The deriving class must not modify the existing elements in the container. - */ - virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const = 0; - - /** - * Query how many default properties the derived class supports. - * @return The number of default properties. - */ - virtual const char* GetDefaultPropertyName( Property::Index index ) const = 0; - - /** - * Query the index of a default property. - * @param [in] name The name of the property. - * @return The index of the property, or Property::INVALID_INDEX if no default property exists with the given name. - */ - virtual Property::Index GetDefaultPropertyIndex( const std::string& name ) const = 0; - - /** - * Query whether a default property is writable. - * @param [in] index The index of the property. - * @return True if the property is animatable. - */ - virtual bool IsDefaultPropertyWritable( Property::Index index ) const = 0; - - /** - * Query whether a default property is animatable. - * This determines whether the property can be the target of an animation or constraint. - * @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. - * @param [in] index The index of the property. - * @return The type of the property. - */ - virtual Property::Type GetDefaultPropertyType( Property::Index index ) const = 0; - - /** * Set the value of a default property. * @pre The property types match i.e. propertyValue.GetType() is equal to GetPropertyType(index). * @param [in] index The index of the property. @@ -547,7 +503,7 @@ private: * @param[in] entry An entry from the property lookup container. * @return The latest value of the property. */ - Property::Value GetCurrentPropertyValue( const PropertyMetadata* entry ) const; + Property::Value GetCurrentPropertyValue( const PropertyMetadata& entry ) const; /** * Set the value of scene graph property. @@ -585,25 +541,23 @@ protected: } private: + EventThreadServices& mEventThreadServices; private: - typedef OwnerContainer PropertyMetadataLookup; - mutable PropertyMetadataLookup mCustomProperties; ///< Used for accessing custom Node properties - mutable PropertyMetadataLookup mAnimatableProperties; ///< Used for accessing animatable Node properties - mutable TypeInfo const * mTypeInfo; ///< The type-info for this object, mutable so it can be lazy initialized from const method if it is required - Dali::Vector mObservers; + mutable OwnerContainer mCustomProperties; ///< Used for accessing custom Node properties + mutable OwnerContainer mAnimatableProperties; ///< Used for accessing animatable Node properties + mutable TypeInfo const * mTypeInfo; ///< The type-info for this object, mutable so it can be lazy initialized from const method if it is required ConstraintContainer* mConstraints; ///< Container of owned -constraints. - typedef std::vector< Dali::PropertyNotification > PropertyNotificationContainer; - typedef PropertyNotificationContainer::iterator PropertyNotificationContainerIter; - typedef PropertyNotificationContainer::const_iterator PropertyNotificationContainerConstIter; + using PropertyNotificationContainer = std::vector< Dali::PropertyNotification >; PropertyNotificationContainer* mPropertyNotifications; ///< Container of owned property notifications. DevelHandle::PropertySetSignalType mPropertySetSignal; }; + } // namespace Internal // Helpers for public-api forwarding methods diff --git a/dali/internal/event/common/property-helper.h b/dali/internal/event/common/property-helper.h index 4157452..74484ba 100644 --- a/dali/internal/event/common/property-helper.h +++ b/dali/internal/event/common/property-helper.h @@ -24,6 +24,7 @@ // INTERNAL INCLUDES #include #include +#include namespace Dali { @@ -32,28 +33,14 @@ namespace Internal { /** - * @brief Structure for setting up default properties and their details. - */ -struct PropertyDetails -{ - const char* 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. -#ifdef DEBUG_ENABLED - Property::Index enumIndex; ///< Used to check the index is correct within a debug build. -#endif -}; - -/** - * These macros are used to define a table of property details per Actor object. + * These macros are used to define a table of property details per object. * The index property is only compiled in for DEBUG_ENABLED builds and allows checking the table index VS the property enum index. * DALI_PROPERTY_TABLE_END Forces a run-time check that will happen once. + * the macros define an instance of PropertyMetadata with the name that is passed to DALI_PROPERTY_TABLE_END */ -#define DALI_PROPERTY_TABLE_BEGIN const Internal::PropertyDetails DEFAULT_PROPERTY_DETAILS[] = { +#define DALI_PROPERTY_TABLE_BEGIN const Dali::PropertyDetails DEFAULT_PROPERTY_DETAILS[] = { #ifdef DEBUG_ENABLED -#define DALI_PROPERTY_TABLE_END( startIndex ) }; const Property::Index DEFAULT_PROPERTY_COUNT = static_cast( sizeof( DEFAULT_PROPERTY_DETAILS ) / sizeof( Internal::PropertyDetails ) ); \ +#define DALI_PROPERTY_TABLE_END( startIndex, constantName ) }; const Property::Index DEFAULT_PROPERTY_COUNT = static_cast( sizeof( DEFAULT_PROPERTY_DETAILS ) / sizeof( Dali::PropertyDetails ) ); \ struct PROPERTY_CHECK \ { \ PROPERTY_CHECK() \ @@ -69,15 +56,13 @@ struct PropertyDetails } \ } \ }; \ + constexpr Dali::DefaultPropertyMetadata constantName{ DEFAULT_PROPERTY_DETAILS, DEFAULT_PROPERTY_COUNT }; \ static PROPERTY_CHECK PROPERTY_CHECK_INSTANCE; #else -#define DALI_PROPERTY_TABLE_END( startIndex ) }; const Property::Index DEFAULT_PROPERTY_COUNT = static_cast( sizeof( DEFAULT_PROPERTY_DETAILS ) / sizeof( Internal::PropertyDetails ) ); -#endif -#ifdef DEBUG_ENABLED -#define DALI_PROPERTY( text, type, writable, animatable, constraint, index ) { text, Dali::Property::type, writable, animatable, constraint, index }, -#else -#define DALI_PROPERTY( text, type, writable, animatable, constraint, index ) { text, Dali::Property::type, writable, animatable, constraint }, +#define DALI_PROPERTY_TABLE_END( startIndex, constantName ) }; const Property::Index DEFAULT_PROPERTY_COUNT = static_cast( sizeof( DEFAULT_PROPERTY_DETAILS ) / sizeof( Dali::PropertyDetails ) );\ + constexpr Dali::DefaultPropertyMetadata constantName{ DEFAULT_PROPERTY_DETAILS, DEFAULT_PROPERTY_COUNT }; #endif +#define DALI_PROPERTY( text, type, writable, animatable, constraint, index ) { text, index, Dali::Property::type, writable, animatable, constraint }, /** * @brief Case insensitive string comparison. diff --git a/dali/internal/event/common/property-metadata.h b/dali/internal/event/common/property-metadata.h index b845eaa..09b62ab 100644 --- a/dali/internal/event/common/property-metadata.h +++ b/dali/internal/event/common/property-metadata.h @@ -2,7 +2,7 @@ #define __DALI_INTERNAL_PROPERTY_METADATA_H__ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -148,7 +148,7 @@ protected: * @param[in] baseValueRef A reference to the metadata of the base animatable property * @param[in] propertyComponentIndex The component index of the property */ - PropertyMetadata( const SceneGraph::PropertyBase* sceneGraphProperty, bool writable, Property::Value& baseValueRef, int propertyComponentIndex ) + PropertyMetadata( const SceneGraph::PropertyBase* sceneGraphProperty, bool writable, Property::Value& baseValueRef, int32_t propertyComponentIndex ) : value( baseValueRef ), componentIndex( propertyComponentIndex ), mStoredValue(), @@ -177,7 +177,7 @@ public: // Data /** * @brief The index of the property component. */ - int componentIndex; + int32_t componentIndex; private: diff --git a/dali/internal/event/common/type-info-impl.cpp b/dali/internal/event/common/type-info-impl.cpp index cb69d1f..19ff51d 100644 --- a/dali/internal/event/common/type-info-impl.cpp +++ b/dali/internal/event/common/type-info-impl.cpp @@ -29,6 +29,9 @@ using std::find_if; +namespace Dali +{ + namespace { @@ -80,7 +83,7 @@ private: template struct PropertyComponentFinder { - PropertyComponentFinder( Dali::Property::Index basePropertyIndex, const int find ) + PropertyComponentFinder( Property::Index basePropertyIndex, const int find ) : mBasePropertyIndex( basePropertyIndex ), mFind( find ) { @@ -93,27 +96,46 @@ struct PropertyComponentFinder private: - Dali::Property::Index mBasePropertyIndex; + Property::Index mBasePropertyIndex; const int mFind; }; -} // namespace anon - -namespace Dali +/** + * Helper function to find the right default property with given index and return the desired detail of it + */ +template< typename Parameter, typename Member > +inline bool GetDefaultPropertyField( const Dali::PropertyDetails* propertyTable, Property::Index count, Property::Index index, Member member, Parameter& parameter ) { + bool found = false; + // is index inside this table (bigger than first index but smaller than first + count) + if( ( index >= propertyTable->enumIndex ) && ( index < ( propertyTable->enumIndex + count ) ) ) + { + // return the match. we're assuming here that there is no gaps between the indices in a table + parameter = propertyTable[ index - propertyTable->enumIndex ].*member; + found = true; + } + // should never really get here + return found; +} + +} // unnamed namespace namespace Internal { -TypeInfo::TypeInfo(const std::string &name, const std::string &baseTypeName, Dali::TypeInfo::CreateFunction creator) - : mTypeName(name), mBaseTypeName(baseTypeName), mCSharpType(false), mCreate(creator) +TypeInfo::TypeInfo( const std::string &name, const std::string &baseTypeName, Dali::TypeInfo::CreateFunction creator, + const Dali::PropertyDetails* defaultProperties, Property::Index defaultPropertyCount ) +: mTypeRegistry( *TypeRegistry::Get() ), + mTypeName(name), mBaseTypeName(baseTypeName), mCreate(creator), mDefaultProperties( defaultProperties ), + mDefaultPropertyCount( defaultPropertyCount ), mCSharpType(false) { DALI_ASSERT_ALWAYS(!name.empty() && "Type info construction must have a name"); DALI_ASSERT_ALWAYS(!baseTypeName.empty() && "Type info construction must have a base type name"); } TypeInfo::TypeInfo(const std::string &name, const std::string &baseTypeName, Dali::CSharpTypeInfo::CreateFunction creator) - : mTypeName(name), mBaseTypeName(baseTypeName), mCSharpType(true), mCSharpCreate(creator) +: mTypeRegistry( *TypeRegistry::Get() ), + mTypeName(name), mBaseTypeName(baseTypeName), mCSharpCreate(creator), mCSharpType(true) { DALI_ASSERT_ALWAYS(!name.empty() && "Type info construction must have a name"); DALI_ASSERT_ALWAYS(!baseTypeName.empty() && "Type info construction must have a base type name"); @@ -154,7 +176,7 @@ BaseHandle TypeInfo::CreateInstance() const return ret; } - bool TypeInfo::DoActionTo(BaseObject *object, const std::string &actionName, const Property::Map &properties) +bool TypeInfo::DoActionTo(BaseObject *object, const std::string &actionName, const Property::Map &properties) { bool done = false; @@ -164,14 +186,10 @@ BaseHandle TypeInfo::CreateInstance() const { done = (iter->second)(object, actionName, properties); } - else - { - DALI_LOG_WARNING("Type '%s' cannot do action '%s'\n", mTypeName.c_str(), actionName.c_str()); - } - if(!done) + if( !done ) { - Dali::TypeInfo base = Dali::TypeRegistry::Get().GetTypeInfo( mBaseTypeName ); + Dali::TypeInfo base = mTypeRegistry.GetTypeInfo( mBaseTypeName ); while( base ) { done = GetImplementation(base).DoActionTo(object, actionName, properties); @@ -179,7 +197,7 @@ BaseHandle TypeInfo::CreateInstance() const { break; } - base = Dali::TypeRegistry::Get().GetTypeInfo( base.GetBaseName() ); + base = mTypeRegistry.GetTypeInfo( base.GetBaseName() ); } } @@ -220,11 +238,11 @@ size_t TypeInfo::GetActionCount() const { size_t count = mActions.size(); - Dali::TypeInfo base = Dali::TypeRegistry::Get().GetTypeInfo( mBaseTypeName ); + Dali::TypeInfo base = mTypeRegistry.GetTypeInfo( mBaseTypeName ); while( base ) { count += GetImplementation(base).mActions.size(); - base = Dali::TypeRegistry::Get().GetTypeInfo( base.GetBaseName() ); + base = mTypeRegistry.GetTypeInfo( base.GetBaseName() ); } return count; @@ -242,7 +260,7 @@ std::string TypeInfo::GetActionName(size_t index) const { size_t count = mActions.size(); - Dali::TypeInfo base = Dali::TypeRegistry::Get().GetTypeInfo( mBaseTypeName ); + Dali::TypeInfo base = mTypeRegistry.GetTypeInfo( mBaseTypeName ); while( base ) { size_t baseCount = GetImplementation(base).mActions.size(); @@ -255,7 +273,7 @@ std::string TypeInfo::GetActionName(size_t index) const count += baseCount; - base = Dali::TypeRegistry::Get().GetTypeInfo( base.GetBaseName() ); + base = mTypeRegistry.GetTypeInfo( base.GetBaseName() ); } } @@ -266,11 +284,11 @@ size_t TypeInfo::GetSignalCount() const { size_t count = mSignalConnectors.size(); - Dali::TypeInfo base = Dali::TypeRegistry::Get().GetTypeInfo( mBaseTypeName ); + Dali::TypeInfo base = mTypeRegistry.GetTypeInfo( mBaseTypeName ); while( base ) { count += GetImplementation(base).mSignalConnectors.size(); - base = Dali::TypeRegistry::Get().GetTypeInfo( base.GetBaseName() ); + base = mTypeRegistry.GetTypeInfo( base.GetBaseName() ); } return count; @@ -288,7 +306,7 @@ std::string TypeInfo::GetSignalName(size_t index) const { size_t count = mSignalConnectors.size(); - Dali::TypeInfo base = Dali::TypeRegistry::Get().GetTypeInfo( mBaseTypeName ); + Dali::TypeInfo base = mTypeRegistry.GetTypeInfo( mBaseTypeName ); while( base ) { size_t baseCount = GetImplementation(base).mSignalConnectors.size(); @@ -301,7 +319,7 @@ std::string TypeInfo::GetSignalName(size_t index) const count += baseCount; - base = Dali::TypeRegistry::Get().GetTypeInfo( base.GetBaseName() ); + base = mTypeRegistry.GetTypeInfo( base.GetBaseName() ); } } @@ -310,7 +328,17 @@ std::string TypeInfo::GetSignalName(size_t index) const void TypeInfo::GetPropertyIndices( Property::IndexContainer& indices ) const { - Dali::TypeInfo base = TypeRegistry::Get()->GetTypeInfo( mBaseTypeName ); + // Default Properties + if( mDefaultProperties ) + { + indices.Reserve( indices.Size() + mDefaultPropertyCount ); + for( Property::Index index = 0; index < mDefaultPropertyCount; ++index ) + { + indices.PushBack( mDefaultProperties[ index ].enumIndex ); + } + } + + Dali::TypeInfo base = mTypeRegistry.GetTypeInfo( mBaseTypeName ); if ( base ) { const TypeInfo& baseImpl( GetImplementation( base ) ); @@ -322,7 +350,7 @@ void TypeInfo::GetPropertyIndices( Property::IndexContainer& indices ) const void TypeInfo::GetChildPropertyIndices( Property::IndexContainer& indices ) const { - Dali::TypeInfo base = TypeRegistry::Get()->GetTypeInfo( mBaseTypeName ); + Dali::TypeInfo base = mTypeRegistry.GetTypeInfo( mBaseTypeName ); if ( base ) { const TypeInfo& baseImpl( GetImplementation( base ) ); @@ -349,23 +377,55 @@ void TypeInfo::AppendProperties( Dali::Property::IndexContainer& indices, } } -const std::string& TypeInfo::GetPropertyName( Property::Index index ) const +const std::string& TypeInfo::GetRegisteredPropertyName( Property::Index index ) const { RegisteredPropertyContainer::const_iterator iter = find_if( mRegisteredProperties.begin(), mRegisteredProperties.end(), PairFinder< Property::Index, RegisteredPropertyPair >( index ) ); - if ( iter != mRegisteredProperties.end() ) { return iter->second.name; } - Dali::TypeInfo base = TypeRegistry::Get()->GetTypeInfo( mBaseTypeName ); if ( base ) { - return GetImplementation(base).GetPropertyName( index ); + return GetImplementation(base).GetRegisteredPropertyName( index ); + } + static std::string empty; + return empty; +} + +std::string TypeInfo::GetPropertyName( Property::Index index ) const +{ + std::string propertyName; + // default or custom + if ( mDefaultProperties && ( index < DEFAULT_PROPERTY_MAX_COUNT ) ) + { + const char* name = nullptr; + if( GetDefaultPropertyField( mDefaultProperties, mDefaultPropertyCount,index, &Dali::PropertyDetails::name, name ) ) + { + propertyName = name; + } + } + else + { + RegisteredPropertyContainer::const_iterator iter = find_if( mRegisteredProperties.begin(), mRegisteredProperties.end(), + PairFinder< Property::Index, RegisteredPropertyPair >( index ) ); + if ( iter != mRegisteredProperties.end() ) + { + return iter->second.name; + } + } + // if not our property, go to parent + if( propertyName.empty() ) + { + Dali::TypeInfo base = mTypeRegistry.GetTypeInfo( mBaseTypeName ); + if ( base ) + { + return GetImplementation(base).GetPropertyName( index ); + } } - DALI_ASSERT_ALWAYS( ! "Cannot find property index" ); // use the same assert as Object + return propertyName; } void TypeInfo::AddActionFunction( const std::string &actionName, Dali::TypeInfo::ActionFunction function ) @@ -494,7 +554,7 @@ void TypeInfo::AddAnimatableProperty( const std::string& name, Property::Index i } } -void TypeInfo::AddAnimatablePropertyComponent( const std::string& name, Property::Index index, Property::Index baseIndex, unsigned int componentIndex ) +void TypeInfo::AddAnimatablePropertyComponent( const std::string& name, Property::Index index, Property::Index baseIndex, uint32_t componentIndex ) { Property::Type type = GetPropertyType( baseIndex ); DALI_ASSERT_ALWAYS( ( type == Property::VECTOR2 || type == Property::VECTOR3 || type == Property::VECTOR4 ) && "Base property does not support component" ); @@ -536,14 +596,14 @@ void TypeInfo::AddChildProperty( const std::string& name, Property::Index index, uint32_t TypeInfo::GetPropertyCount() const { - uint32_t count = static_cast( mRegisteredProperties.size() ); + uint32_t count = mDefaultPropertyCount + static_cast( mRegisteredProperties.size() ); - Dali::TypeInfo base = TypeRegistry::Get()->GetTypeInfo( mBaseTypeName ); + Dali::TypeInfo base = mTypeRegistry.GetTypeInfo( mBaseTypeName ); while ( base ) { const TypeInfo& baseImpl( GetImplementation(base) ); - count += static_cast( baseImpl.mRegisteredProperties.size() ); - base = TypeRegistry::Get()->GetTypeInfo( baseImpl.mBaseTypeName ); + count += baseImpl.mDefaultPropertyCount + static_cast( baseImpl.mRegisteredProperties.size() ); + base = mTypeRegistry.GetTypeInfo( baseImpl.mBaseTypeName ); } return count; @@ -552,21 +612,37 @@ uint32_t TypeInfo::GetPropertyCount() const Property::Index TypeInfo::GetPropertyIndex( const std::string& name ) const { Property::Index index = Property::INVALID_INDEX; + bool found = false; - // Slow but should not be done that often - RegisteredPropertyContainer::const_iterator iter = find_if( mRegisteredProperties.begin(), mRegisteredProperties.end(), - PropertyNameFinder< RegisteredPropertyPair >( name ) ); - - if ( iter != mRegisteredProperties.end() ) + // check default properties + if( mDefaultProperties ) { - index = iter->first; + for( Property::Index tableIndex = 0; tableIndex < mDefaultPropertyCount; ++tableIndex ) + { + if( 0 == name.compare( mDefaultProperties[ tableIndex ].name ) ) + { + index = mDefaultProperties[ tableIndex ].enumIndex; + found = true; + break; + } + } } - else + if( !found ) { - Dali::TypeInfo base = TypeRegistry::Get()->GetTypeInfo( mBaseTypeName ); - if ( base ) + // Slow but should not be done that often + RegisteredPropertyContainer::const_iterator iter = find_if( mRegisteredProperties.begin(), mRegisteredProperties.end(), + PropertyNameFinder< RegisteredPropertyPair >( name ) ); + if ( iter != mRegisteredProperties.end() ) + { + index = iter->first; + } + else { - index = GetImplementation(base).GetPropertyIndex( name ); + Dali::TypeInfo base = mTypeRegistry.GetTypeInfo( mBaseTypeName ); + if ( base ) + { + index = GetImplementation(base).GetPropertyIndex( name ); + } } } @@ -586,7 +662,7 @@ Property::Index TypeInfo::GetBasePropertyIndex( Property::Index index ) const } else { - Dali::TypeInfo base = TypeRegistry::Get()->GetTypeInfo( mBaseTypeName ); + Dali::TypeInfo base = mTypeRegistry.GetTypeInfo( mBaseTypeName ); if ( base ) { basePropertyIndex = GetImplementation(base).GetBasePropertyIndex( index ); @@ -609,7 +685,7 @@ int TypeInfo::GetComponentIndex( Property::Index index ) const } else { - Dali::TypeInfo base = TypeRegistry::Get()->GetTypeInfo( mBaseTypeName ); + Dali::TypeInfo base = mTypeRegistry.GetTypeInfo( mBaseTypeName ); if ( base ) { componentIndex = GetImplementation(base).GetComponentIndex( index ); @@ -633,7 +709,7 @@ Property::Index TypeInfo::GetChildPropertyIndex( const std::string& name ) const } else { - Dali::TypeInfo base = TypeRegistry::Get()->GetTypeInfo( mBaseTypeName ); + Dali::TypeInfo base = mTypeRegistry.GetTypeInfo( mBaseTypeName ); if ( base ) { index = GetImplementation(base).GetChildPropertyIndex( name ); @@ -653,16 +729,16 @@ const std::string& TypeInfo::GetChildPropertyName( Property::Index index ) const return iter->second.name; } - Dali::TypeInfo base = TypeRegistry::Get()->GetTypeInfo( mBaseTypeName ); + Dali::TypeInfo base = mTypeRegistry.GetTypeInfo( mBaseTypeName ); if ( base ) { return GetImplementation(base).GetChildPropertyName( index ); } - DALI_LOG_WARNING("Cannot find property index"); + DALI_LOG_ERROR( "Property index %d not found\n", index ); - static std::string emptyString; - return emptyString; + static std::string empty; + return empty; } Property::Type TypeInfo::GetChildPropertyType( Property::Index index ) const @@ -678,14 +754,14 @@ Property::Type TypeInfo::GetChildPropertyType( Property::Index index ) const } else { - Dali::TypeInfo base = TypeRegistry::Get()->GetTypeInfo( mBaseTypeName ); + Dali::TypeInfo base = mTypeRegistry.GetTypeInfo( mBaseTypeName ); if ( base ) { type = GetImplementation(base).GetChildPropertyType( index ); } else { - DALI_ASSERT_ALWAYS( ! "Cannot find property index" ); // use the same assert as Object + DALI_LOG_ERROR( "Property index %d not found\n", index ); } } @@ -694,67 +770,167 @@ Property::Type TypeInfo::GetChildPropertyType( Property::Index index ) const bool TypeInfo::IsPropertyWritable( Property::Index index ) const { - bool writable( false ); + bool writable = false; + bool found = false; - RegisteredPropertyContainer::const_iterator iter = find_if( mRegisteredProperties.begin(), mRegisteredProperties.end(), - PairFinder< Property::Index, RegisteredPropertyPair >( index ) ); + // default property? + if ( ( index < DEFAULT_PROPERTY_MAX_COUNT ) && mDefaultProperties ) + { + found = GetDefaultPropertyField( mDefaultProperties, mDefaultPropertyCount,index, &Dali::PropertyDetails::writable, writable ); + } + else if( ( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX ) ) + { + writable = true; // animatable property is writable + found = true; + } + else + { + RegisteredPropertyContainer::const_iterator iter = find_if( mRegisteredProperties.begin(), mRegisteredProperties.end(), + PairFinder< Property::Index, RegisteredPropertyPair >( index ) ); + if ( iter != mRegisteredProperties.end() ) + { + writable = iter->second.setFunc ? true : false; + found = true; + } + } - if ( iter != mRegisteredProperties.end() ) + // if not found, continue to base + if( !found ) { - if( ( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX ) ) + Dali::TypeInfo base = mTypeRegistry.GetTypeInfo( mBaseTypeName ); + if ( base ) { - writable = true; // animatable property is writable + writable = GetImplementation(base).IsPropertyWritable( index ); } else { - writable = iter->second.setFunc ? true : false; + DALI_LOG_ERROR( "Property index %d not found\n", index ); } } - else + + return writable; +} + +bool TypeInfo::IsPropertyAnimatable( Property::Index index ) const +{ + bool animatable = false; + bool found = false; + + // default property? + if ( ( index < DEFAULT_PROPERTY_MAX_COUNT ) && mDefaultProperties ) + { + found = GetDefaultPropertyField( mDefaultProperties, mDefaultPropertyCount,index, &Dali::PropertyDetails::animatable, animatable ); + } + else if ( ( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX ) ) + { + // Type Registry event-thread only properties are not animatable. + animatable = false; + found = true; + } + else if( ( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX ) ) { - Dali::TypeInfo base = TypeRegistry::Get()->GetTypeInfo( mBaseTypeName ); + animatable = true; + found = true; + } + + // if not found, continue to base + if( !found ) + { + Dali::TypeInfo base = mTypeRegistry.GetTypeInfo( mBaseTypeName ); if ( base ) { - writable = GetImplementation(base).IsPropertyWritable( index ); + animatable = GetImplementation(base).IsPropertyAnimatable( index ); } else { - DALI_ASSERT_ALWAYS( ! "Cannot find property index" ); // use the same assert as Object + DALI_LOG_ERROR( "Property index %d not found\n", index ); } } - return writable; + return animatable; } -Property::Type TypeInfo::GetPropertyType( Property::Index index ) const +bool TypeInfo::IsPropertyAConstraintInput( Property::Index index ) const { - Property::Type type( Property::NONE ); + bool constraintInput = false; + bool found = false; - RegisteredPropertyContainer::const_iterator iter = find_if( mRegisteredProperties.begin(), mRegisteredProperties.end(), - PairFinder< Property::Index, RegisteredPropertyPair >( index ) ); + // default property? + if ( ( index < DEFAULT_PROPERTY_MAX_COUNT ) && mDefaultProperties ) + { + found = GetDefaultPropertyField( mDefaultProperties, mDefaultPropertyCount,index, &Dali::PropertyDetails::constraintInput, constraintInput ); + } + else if ( ( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX ) ) + { + // Type Registry event-thread only properties cannot be used as constraint input + constraintInput = false; + found = true; + } + else if( ( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX ) ) + { + constraintInput = true; + found = true; + } - if ( iter != mRegisteredProperties.end() ) + // if not found, continue to base + if( !found ) { - if( iter->second.componentIndex == Property::INVALID_COMPONENT_INDEX ) + Dali::TypeInfo base = mTypeRegistry.GetTypeInfo( mBaseTypeName ); + if ( base ) { - type = iter->second.type; + constraintInput = GetImplementation(base).IsPropertyAConstraintInput( index ); } else { - // If component index is set, then we should return FLOAT - type = Property::FLOAT; + DALI_LOG_ERROR( "Property index %d not found\n", index ); } } + + return constraintInput; +} + + +Property::Type TypeInfo::GetPropertyType( Property::Index index ) const +{ + Property::Type type( Property::NONE ); + bool found = false; + + // default property? + if ( ( index < DEFAULT_PROPERTY_MAX_COUNT ) && mDefaultProperties ) + { + found = GetDefaultPropertyField( mDefaultProperties, mDefaultPropertyCount,index, &Dali::PropertyDetails::type, type ); + } else { - Dali::TypeInfo base = TypeRegistry::Get()->GetTypeInfo( mBaseTypeName ); + RegisteredPropertyContainer::const_iterator iter = find_if( mRegisteredProperties.begin(), mRegisteredProperties.end(), + PairFinder< Property::Index, RegisteredPropertyPair >( index ) ); + + if ( iter != mRegisteredProperties.end() ) + { + if( iter->second.componentIndex == Property::INVALID_COMPONENT_INDEX ) + { + type = iter->second.type; + found = true; + } + else + { + // If component index is set, then we should return FLOAT + type = Property::FLOAT; + found = true; + } + } + } + + if( !found ) + { + Dali::TypeInfo base = mTypeRegistry.GetTypeInfo( mBaseTypeName ); if ( base ) { type = GetImplementation(base).GetPropertyType( index ); } else { - DALI_ASSERT_ALWAYS( ! "Cannot find property index" ); // use the same assert as Object + DALI_LOG_ERROR( "Property index %d not found\n", index ); } } @@ -798,14 +974,14 @@ void TypeInfo::SetProperty( BaseObject *object, Property::Index index, const Pro } else { - Dali::TypeInfo base = TypeRegistry::Get()->GetTypeInfo( mBaseTypeName ); + Dali::TypeInfo base = mTypeRegistry.GetTypeInfo( mBaseTypeName ); if ( base ) { GetImplementation(base).SetProperty( object, index, value ); } else { - DALI_ASSERT_ALWAYS( ! "Cannot find property index" ); // use the same assert as Object + DALI_LOG_ERROR( "Property index %d not found\n", index ); } } } @@ -830,14 +1006,14 @@ void TypeInfo::SetProperty( BaseObject *object, const std::string& name, const P } else { - Dali::TypeInfo base = TypeRegistry::Get()->GetTypeInfo( mBaseTypeName ); + Dali::TypeInfo base = mTypeRegistry.GetTypeInfo( mBaseTypeName ); if ( base ) { GetImplementation(base).SetProperty( object, name, value ); } else { - DALI_ASSERT_ALWAYS( ! "Cannot find property name" ); + DALI_LOG_ERROR( "Property %s not found", name.c_str() ); } } } @@ -865,13 +1041,14 @@ Property::Value TypeInfo::GetProperty( const BaseObject *object, Property::Index } } - Dali::TypeInfo base = TypeRegistry::Get()->GetTypeInfo( mBaseTypeName ); + Dali::TypeInfo base = mTypeRegistry.GetTypeInfo( mBaseTypeName ); if ( base ) { return GetImplementation( base ).GetProperty( object, index ); } - DALI_ASSERT_ALWAYS( ! "Cannot find property index" ); // use the same assert as Object + DALI_LOG_ERROR( "Property index %d not found\n", index ); + return Property::Value(); } Property::Value TypeInfo::GetProperty( const BaseObject *object, const std::string& name ) const @@ -898,13 +1075,14 @@ Property::Value TypeInfo::GetProperty( const BaseObject *object, const std::stri } } - Dali::TypeInfo base = TypeRegistry::Get()->GetTypeInfo( mBaseTypeName ); + Dali::TypeInfo base = mTypeRegistry.GetTypeInfo( mBaseTypeName ); if ( base ) { return GetImplementation( base ).GetProperty( object, name ); } - DALI_ASSERT_ALWAYS( ! "Cannot find property name" ); + DALI_LOG_ERROR( "Property %s not found", name.c_str() ); + return Property::Value(); } } // namespace Internal diff --git a/dali/internal/event/common/type-info-impl.h b/dali/internal/event/common/type-info-impl.h index d3fcfda..06fd0a1 100644 --- a/dali/internal/event/common/type-info-impl.h +++ b/dali/internal/event/common/type-info-impl.h @@ -25,13 +25,17 @@ #include #include #include +#include #include +#include namespace Dali { namespace Internal { +class PropertyDetails; +class TypeRegistry; /** * A TypeInfo class to support registered type creation, and introspection of available @@ -43,13 +47,15 @@ namespace Internal class TypeInfo : public BaseObject { public: + /** * Create TypeInfo * @param [name] the registered name * @param [baseName] the base type registered name * @param [creator] the creator function for this type */ - TypeInfo(const std::string& name, const std::string& baseName, Dali::TypeInfo::CreateFunction creator); + TypeInfo( const std::string& name, const std::string& baseName, Dali::TypeInfo::CreateFunction creator, + const Dali::PropertyDetails* defaultProperties, Property::Index defaultPropertyCount ); /** * Create TypeInfo for a csharp object @@ -57,7 +63,7 @@ public: * @param [baseName] the base type registered name * @param [creator] the creator function for this type */ - TypeInfo(const std::string& name, const std::string& baseName, Dali::CSharpTypeInfo::CreateFunction creator); + TypeInfo( const std::string& name, const std::string& baseName, Dali::CSharpTypeInfo::CreateFunction creator ); /** * Destructor @@ -117,8 +123,17 @@ public: /** * @copydoc Dali::TypeInfo::GetPropertyName() const + * this API exists to keep the old public API, which cannot be changed */ - const std::string& GetPropertyName( Property::Index index ) const; + const std::string& GetRegisteredPropertyName( Property::Index index ) const; + + /** + * Returns the property name for given index + * + * @param index of the property + * @return name or empty string + */ + std::string GetPropertyName( Property::Index index ) const; /* * Add an action function @@ -137,7 +152,7 @@ public: * @param[in] name The name of the property. * @param[in] index The index of the property. * @param[in] type The Property::Type. - * @param[in] setFunc The function to call to set the property (Can be NULL). + * @param[in] setFunc The function to call to set the property (Can be nullptr). * @param[in] getFunc The function to call to retrieve the value of the property. */ void AddProperty( const std::string& name, Property::Index index, Property::Type type, Dali::TypeInfo::SetPropertyFunction setFunc, Dali::TypeInfo::GetPropertyFunction getFunc ); @@ -147,7 +162,7 @@ public: * @param[in] name The name of the property. * @param[in] index The index of the property. * @param[in] type The Property::Type. - * @param[in] setFunc The function to call to set the property (Can be NULL). + * @param[in] setFunc The function to call to set the property (Can be nullptr). * @param[in] getFunc The function to call to retrieve the value of the property. */ void AddProperty( const std::string& name, Property::Index index, Property::Type type, Dali::CSharpTypeInfo::SetPropertyFunction setFunc, Dali::CSharpTypeInfo::GetPropertyFunction getFunc); @@ -228,13 +243,24 @@ public: int32_t GetComponentIndex( Property::Index index ) const; /** - * Checks if there is a setter for the property. If there is then it is writable. * @param[in] index The property index. * @return True, if writable, false otherwise. */ bool IsPropertyWritable( Property::Index index ) const; /** + * @param[in] index The property index. + * @return True, if animatable, false otherwise. + */ + bool IsPropertyAnimatable( Property::Index index ) const; + + /** + * @param[in] index The property index. + * @return True, if a constraint input, false otherwise. + */ + bool IsPropertyAConstraintInput( Property::Index index ) const; + + /** * Retrieve the Property::Type of the property at the given index. * @param[in] index The property index. * @return The Property::Type at that index. @@ -311,20 +337,10 @@ private: struct RegisteredProperty { - RegisteredProperty() - : type( Property::NONE ), - setFunc( NULL ), - getFunc( NULL ), - name(), - basePropertyIndex(Property::INVALID_INDEX), - componentIndex(Property::INVALID_COMPONENT_INDEX) - { - } - RegisteredProperty( Property::Type propType, const std::string& propName, Property::Index basePropertyIndex, int32_t componentIndex ) : type( propType ), - setFunc( NULL ), - getFunc( NULL ), + setFunc( nullptr ), + getFunc( nullptr ), name( propName ), basePropertyIndex(basePropertyIndex), componentIndex(componentIndex) @@ -352,21 +368,20 @@ private: { } - - Property::Type type; + Property::Type type = Property::NONE; union { - Dali::TypeInfo::SetPropertyFunction setFunc; - Dali::CSharpTypeInfo::SetPropertyFunction cSharpSetFunc; + Dali::TypeInfo::SetPropertyFunction setFunc = nullptr; + Dali::CSharpTypeInfo::SetPropertyFunction cSharpSetFunc; // only one field can be initialized but this will have same value anyways }; union { - Dali::TypeInfo::GetPropertyFunction getFunc; - Dali::CSharpTypeInfo::GetPropertyFunction cSharpGetFunc; + Dali::TypeInfo::GetPropertyFunction getFunc = nullptr; + Dali::CSharpTypeInfo::GetPropertyFunction cSharpGetFunc; // only one field can be initialized but this will have same value anyways }; std::string name; - Property::Index basePropertyIndex; - int32_t componentIndex; + Property::Index basePropertyIndex = Property::INVALID_INDEX; + int32_t componentIndex = Property::INVALID_COMPONENT_INDEX; }; typedef std::pair ConnectionPair; @@ -379,7 +394,6 @@ private: typedef std::vector< RegisteredPropertyPair > RegisteredPropertyContainer; typedef std::vector< PropertyDefaultValuePair > PropertyDefaultValueContainer; - /** * Append properties from registeredProperties onto indices. * @param[in,out] indices The vector to append indices onto @@ -390,19 +404,22 @@ private: private: + TypeRegistry& mTypeRegistry; std::string mTypeName; std::string mBaseTypeName; - bool mCSharpType:1; ///< Whether this type info is for a CSharp control (instead of C++) union { - Dali::TypeInfo::CreateFunction mCreate; - Dali::CSharpTypeInfo::CreateFunction mCSharpCreate; + Dali::TypeInfo::CreateFunction mCreate = nullptr; + Dali::CSharpTypeInfo::CreateFunction mCSharpCreate; // only one field can be initialized but this will have same value anyways }; ActionContainer mActions; ConnectorContainer mSignalConnectors; RegisteredPropertyContainer mRegisteredProperties; RegisteredPropertyContainer mRegisteredChildProperties; PropertyDefaultValueContainer mPropertyDefaultValues; + const Dali::PropertyDetails* mDefaultProperties = nullptr; + Property::Index mDefaultPropertyCount = 0; + bool mCSharpType = false; ///< Whether this type info is for a CSharp control (instead of C++) }; } // namespace Internal diff --git a/dali/internal/event/common/type-registry-impl.cpp b/dali/internal/event/common/type-registry-impl.cpp index 66b9fcb..20a69b8 100644 --- a/dali/internal/event/common/type-registry-impl.cpp +++ b/dali/internal/event/common/type-registry-impl.cpp @@ -89,7 +89,6 @@ size_t TypeRegistry::GetTypeNameCount() const return mRegistryLut.size(); } - std::string TypeRegistry::GetTypeName( size_t index ) const { std::string name; @@ -102,8 +101,7 @@ std::string TypeRegistry::GetTypeName( size_t index ) const return name; } - -bool TypeRegistry::Register( const std::type_info& theTypeInfo, const std::type_info& baseTypeInfo, +std::string TypeRegistry::Register( const std::type_info& theTypeInfo, const std::type_info& baseTypeInfo, Dali::TypeInfo::CreateFunction createInstance, bool callCreateOnInit ) { std::string uniqueTypeName = DemangleClassName( theTypeInfo.name() ); @@ -111,8 +109,18 @@ bool TypeRegistry::Register( const std::type_info& theTypeInfo, const std::type_ return Register( uniqueTypeName, baseTypeInfo, createInstance, callCreateOnInit ); } -bool TypeRegistry::Register( const std::string& uniqueTypeName, const std::type_info& baseTypeInfo, - Dali::TypeInfo::CreateFunction createInstance, bool callCreateOnInit ) +std::string TypeRegistry::Register( const std::type_info& theTypeInfo, const std::type_info& baseTypeInfo, + Dali::TypeInfo::CreateFunction createInstance, bool callCreateOnInit, + const Dali::PropertyDetails* defaultProperties, Property::Index defaultPropertyCount ) +{ + std::string uniqueTypeName = DemangleClassName( theTypeInfo.name() ); + + return Register( uniqueTypeName, baseTypeInfo, createInstance, callCreateOnInit, defaultProperties, defaultPropertyCount ); +} + +std::string TypeRegistry::Register( const std::string& uniqueTypeName, const std::type_info& baseTypeInfo, + Dali::TypeInfo::CreateFunction createInstance, bool callCreateOnInit, + const Dali::PropertyDetails* defaultProperties, Property::Index defaultPropertyCount ) { std::string baseTypeName = DemangleClassName( baseTypeInfo.name() ); @@ -123,11 +131,11 @@ bool TypeRegistry::Register( const std::string& uniqueTypeName, const std::type_ { DALI_LOG_WARNING( "Duplicate name in TypeRegistry for '%s'\n", + uniqueTypeName.c_str() ); DALI_ASSERT_ALWAYS( !"Duplicate type name in Type Registration" ); - return false; + return uniqueTypeName; // never actually happening due to the assert } } - mRegistryLut.push_back( Dali::TypeInfo( new Internal::TypeInfo( uniqueTypeName, baseTypeName, createInstance ) ) ); + mRegistryLut.push_back( Dali::TypeInfo( new Internal::TypeInfo( uniqueTypeName, baseTypeName, createInstance, defaultProperties, defaultPropertyCount ) ) ); DALI_LOG_INFO( gLogFilter, Debug::Concise, "Type Registration %s(%s)\n", uniqueTypeName.c_str(), baseTypeName.c_str() ); if( callCreateOnInit ) @@ -135,10 +143,10 @@ bool TypeRegistry::Register( const std::string& uniqueTypeName, const std::type_ mInitFunctions.push_back(createInstance); } - return true; + return uniqueTypeName; } -bool TypeRegistry::Register( const std::string& uniqueTypeName, const std::type_info& baseTypeInfo, +void TypeRegistry::Register( const std::string& uniqueTypeName, const std::type_info& baseTypeInfo, Dali::CSharpTypeInfo::CreateFunction createInstance ) { std::string baseTypeName = DemangleClassName( baseTypeInfo.name() ); @@ -150,14 +158,12 @@ bool TypeRegistry::Register( const std::string& uniqueTypeName, const std::type_ { DALI_LOG_WARNING( "Duplicate name in TypeRegistry for '%s'\n", + uniqueTypeName.c_str() ); DALI_ASSERT_ALWAYS( !"Duplicate type name in Type Registration" ); - return false; + return; // never actually happening due to the assert } } mRegistryLut.push_back( Dali::TypeInfo( new Internal::TypeInfo( uniqueTypeName, baseTypeName, createInstance ) ) ); DALI_LOG_INFO( gLogFilter, Debug::Concise, "Type Registration %s(%s)\n", uniqueTypeName.c_str(), baseTypeName.c_str() ); - - return true; } void TypeRegistry::CallInitFunctions(void) const @@ -302,15 +308,13 @@ bool TypeRegistry::DoActionTo( BaseObject * const object, const std::string& act Dali::TypeInfo type = GetTypeInfo( object ); - while( type ) + auto&& impl = GetImplementation( type ); + // DoActionTo recurses through base classes + done = impl.DoActionTo( object, actionName, properties ); + + if( !done ) { - auto&& impl = GetImplementation( type ); - if( impl.DoActionTo( object, actionName, properties ) ) - { - done = true; - break; - } - type = GetTypeInfo( impl.GetBaseName() ); + DALI_LOG_WARNING("Type '%s' cannot do action '%s'\n", type.GetName().c_str(), actionName.c_str()); } return done; @@ -353,6 +357,12 @@ Dali::TypeInfo TypeRegistry::GetTypeInfo(const Dali::BaseObject * const pBaseObj { const Dali::CustomActorImpl& custom = pCustom->GetImplementation(); type = GetTypeInfo( typeid( custom ) ); + if( !type ) + { + // the most derived type is a descendant of custom actor but has not registered itself + // so we'll just treat it as a custom actor for now so it "inherits" all of actors properties, actions and signals + type = GetTypeInfo( typeid( Dali::Internal::CustomActor ) ); + } } else { diff --git a/dali/internal/event/common/type-registry-impl.h b/dali/internal/event/common/type-registry-impl.h index e097c76..2368d57 100644 --- a/dali/internal/event/common/type-registry-impl.h +++ b/dali/internal/event/common/type-registry-impl.h @@ -24,6 +24,7 @@ #include #include #include +#include namespace Dali { @@ -31,8 +32,7 @@ namespace Dali namespace Internal { -//////////////////////////////////////////////////////////////////////////////// -class TypeRegistry; +class PropertyDetails; /* * @copydoc Dali::TypeRegistry @@ -45,59 +45,75 @@ public: */ static TypeRegistry *Get(); - /* + /** * @copydoc Dali::TypeRegistry::GetTypeInfo */ Dali::TypeInfo GetTypeInfo( const std::string &uniqueTypeName ); - /* + /** * @copydoc Dali::TypeRegistry::GetTypeInfo */ Dali::TypeInfo GetTypeInfo( const std::type_info& registerType ); - /* + /** * @copydoc Dali::TypeRegistry::GetTypeNameCount */ size_t GetTypeNameCount() const; - /* + /** * @copydoc Dali::TypeRegistry::GetTypeName */ std::string GetTypeName(size_t index) const; - /* - * Register a creation function under a unique name. + /** + * Register a type + * * @param [in] theTypeInfo Type info for the type to be registered * @param [in] baseTypeInfo Type info for its base class * @param [in] createInstance Instance creation function - * @param [in] callCreateOnInit If true call createInstance on dali initialisation - * @return true if the name could be registered. + * @param [in] callCreateOnInit If true call createInstance on DALi initialisation + * @return the name of the registered type. */ - bool Register( const std::type_info& theTypeInfo, const std::type_info& baseTypeInfo, - Dali::TypeInfo::CreateFunction createInstance, bool callCreateOnInit ); + std::string Register( const std::type_info& theTypeInfo, const std::type_info& baseTypeInfo, + Dali::TypeInfo::CreateFunction createInstance, bool callCreateOnInit ); - /* - * Register a creation function under a unique name. - * @param [in] name The name type to be registered (must be unique) + /** + * Register a type + * + * @param [in] theTypeInfo Type info for the type to be registered * @param [in] baseTypeInfo Type info for its base class * @param [in] createInstance Instance creation function - * @param [in] callCreateOnInit If true call createInstance on dali initialisation - * @return true if the name could be registered. + * @param [in] callCreateOnInit If true call createInstance on DALi initialisation + * @param [in] defaultProperties the table of default property metadata + * @param [in] defaultPropertyCount count of default properties + * @return the name of the registered type. */ - bool Register( const std::string& name, const std::type_info& baseTypeInfo, - Dali::TypeInfo::CreateFunction createInstance, bool callCreateOnInit ); + std::string Register( const std::type_info& theTypeInfo, const std::type_info& baseTypeInfo, + Dali::TypeInfo::CreateFunction createInstance, bool callCreateOnInit, + const Dali::PropertyDetails* defaultProperties, Property::Index defaultPropertyCount ); - /* - * Register a creation function under a unique name (used by C# Custom controls). - * @param [in] name The name type to be registered (must be unique) + /** + * Register a type + * + * @param [in] theTypeInfo Type info for the type to be registered * @param [in] baseTypeInfo Type info for its base class * @param [in] createInstance Instance creation function - * @return true if the name could be registered. + * @param [in] callCreateOnInit If true call createInstance on DALi initialisation + * @param [in] defaultProperties the table of default property metadata + * @param [in] defaultPropertyCount count of default properties + * @return the name of the registered type. + */ + std::string Register( const std::string& name, const std::type_info& baseTypeInfo, + Dali::TypeInfo::CreateFunction createInstance, bool callCreateOnInit, + const Dali::PropertyDetails* defaultProperties = nullptr, Property::Index defaultPropertyCount = 0 ); + + /** + * @copydoc CSharpTypeRegistry::TypeRegistration( const std::string&, const std::type_info&, TypeInfo::CreateFunction ); */ - bool Register( const std::string& name, const std::type_info& baseTypeInfo, + void Register( const std::string& name, const std::type_info& baseTypeInfo, Dali::CSharpTypeInfo::CreateFunction createInstance ); - /* + /** * Register a signal connector function to a type * @param [in] typeRegistration TypeRegistration object used to register the type * @param [in] name Signal name @@ -105,14 +121,14 @@ public: */ void RegisterSignal( TypeRegistration& typeRegistration, const std::string& name, Dali::TypeInfo::SignalConnectorFunction func ); - /* + /** * Register an action function to a type * @param [in] registered TypeRegistration object used to register the type * @param [in] name Action name * @param [in] f Action function * @return true if registered */ - bool RegisterAction( TypeRegistration ®istered, const std::string &name, Dali::TypeInfo::ActionFunction f); + bool RegisterAction( TypeRegistration& registered, const std::string& name, Dali::TypeInfo::ActionFunction f ); /** * Register an event-thread only property with a type @@ -190,7 +206,7 @@ public: */ bool RegisterChildProperty( TypeRegistration& registered, const std::string& name, Property::Index index, Property::Type type ); - /* + /** * @copydoc Dali::Internal::TypeInfo::DoActionTo * Walks all base types until it finds a doer. */ @@ -201,14 +217,14 @@ public: */ bool ConnectSignal( BaseObject* object, ConnectionTrackerInterface* connectionTracker, const std::string& signalName, FunctorDelegate* functor ); - /* + /** * Return the type info for a given BaseObject pointer * @param [in] pBaseObject Pointer to a BaseObject * @return TypeInfo for the BaseObject. */ Dali::TypeInfo GetTypeInfo(const Dali::BaseObject * const pBaseObject); - /* + /** * Calls any type creation functions that have been flagged as initialization functions */ void CallInitFunctions(void) const; diff --git a/dali/internal/event/events/gesture-detector-impl.cpp b/dali/internal/event/events/gesture-detector-impl.cpp index ada5dff..fd2c395 100644 --- a/dali/internal/event/events/gesture-detector-impl.cpp +++ b/dali/internal/event/events/gesture-detector-impl.cpp @@ -196,45 +196,6 @@ void GestureDetector::ObjectDestroyed(Object& object) } } -unsigned int GestureDetector::GetDefaultPropertyCount() const -{ - return 0; -} - -void GestureDetector::GetDefaultPropertyIndices( Property::IndexContainer& ) const -{ -} - -const char* GestureDetector::GetDefaultPropertyName( Property::Index index ) const -{ - return NULL; -} - -Property::Index GestureDetector::GetDefaultPropertyIndex(const std::string& name) const -{ - return Property::INVALID_INDEX; -} - -bool GestureDetector::IsDefaultPropertyWritable(Property::Index index) const -{ - return false; -} - -bool GestureDetector::IsDefaultPropertyAnimatable(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; -} - void GestureDetector::SetDefaultProperty( Property::Index index, const Property::Value& property ) { // None of our properties should be settable from Public API diff --git a/dali/internal/event/events/gesture-detector-impl.h b/dali/internal/event/events/gesture-detector-impl.h index d136c6c..d18e4cb 100644 --- a/dali/internal/event/events/gesture-detector-impl.h +++ b/dali/internal/event/events/gesture-detector-impl.h @@ -168,46 +168,6 @@ private: private: // Default property extensions from Object /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyCount() - */ - virtual unsigned int GetDefaultPropertyCount() const; - - /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyIndices() - */ - virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const; - - /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyName() - */ - virtual const char* GetDefaultPropertyName(Property::Index index) const; - - /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyIndex() - */ - virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const; - - /** - * @copydoc Dali::Internal::Object::IsDefaultPropertyWritable() - */ - virtual bool IsDefaultPropertyWritable(Property::Index index) const; - - /** - * @copydoc Dali::Internal::Object::IsDefaultPropertyAnimatable() - */ - virtual bool IsDefaultPropertyAnimatable(Property::Index index) const; - - /** - * @copydoc Dali::Internal::Object::IsDefaultPropertyAConstraintInput() - */ - virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const; - - /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyType() - */ - virtual Property::Type GetDefaultPropertyType(Property::Index index) const; - - /** * @copydoc Dali::Internal::Object::SetDefaultProperty() */ virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue); diff --git a/dali/internal/event/events/pan-gesture-detector-impl.cpp b/dali/internal/event/events/pan-gesture-detector-impl.cpp index dc91220..d79d2d4 100644 --- a/dali/internal/event/events/pan-gesture-detector-impl.cpp +++ b/dali/internal/event/events/pan-gesture-detector-impl.cpp @@ -53,7 +53,7 @@ DALI_PROPERTY( "localPosition", VECTOR2, false, false, true, Dali::PanGe DALI_PROPERTY( "localDisplacement", VECTOR2, false, false, true, Dali::PanGestureDetector::Property::LOCAL_DISPLACEMENT ) DALI_PROPERTY( "localVelocity", VECTOR2, false, false, true, Dali::PanGestureDetector::Property::LOCAL_VELOCITY ) DALI_PROPERTY( "panning", BOOLEAN, false, false, true, Dali::PanGestureDetector::Property::PANNING ) -DALI_PROPERTY_TABLE_END( DEFAULT_GESTURE_DETECTOR_PROPERTY_START_INDEX ) +DALI_PROPERTY_TABLE_END( DEFAULT_GESTURE_DETECTOR_PROPERTY_START_INDEX, PanGestureDetectorDefaultProperties ) // Signals @@ -64,7 +64,7 @@ BaseHandle Create() return Dali::PanGestureDetector::New(); } -TypeRegistration mType( typeid(Dali::PanGestureDetector), typeid(Dali::GestureDetector), Create ); +TypeRegistration mType( typeid(Dali::PanGestureDetector), typeid(Dali::GestureDetector), Create, PanGestureDetectorDefaultProperties ); SignalConnectorType signalConnector1( mType, SIGNAL_PAN_DETECTED, &PanGestureDetector::DoConnectSignal ); @@ -326,82 +326,6 @@ void PanGestureDetector::OnActorDestroyed(Object& object) // Do nothing } -unsigned int PanGestureDetector::GetDefaultPropertyCount() const -{ - return DEFAULT_PROPERTY_COUNT; -} - -void PanGestureDetector::GetDefaultPropertyIndices( Property::IndexContainer& indices ) const -{ - indices.Reserve( DEFAULT_PROPERTY_COUNT ); - - int index = DEFAULT_GESTURE_DETECTOR_PROPERTY_START_INDEX; - for ( int i = 0; i < DEFAULT_PROPERTY_COUNT; ++i, ++index ) - { - indices.PushBack( index ); - } -} - -const char* PanGestureDetector::GetDefaultPropertyName( Property::Index index ) const -{ - index -= DEFAULT_GESTURE_DETECTOR_PROPERTY_START_INDEX; - if ( ( index >= 0 ) && ( index < DEFAULT_PROPERTY_COUNT ) ) - { - return DEFAULT_PROPERTY_DETAILS[ index ].name; - } - - return NULL; -} - -Property::Index PanGestureDetector::GetDefaultPropertyIndex(const std::string& name) const -{ - Property::Index index = Property::INVALID_INDEX; - - // Look for name in default properties - for( int i = 0; i < DEFAULT_PROPERTY_COUNT; ++i ) - { - const Internal::PropertyDetails* property = &DEFAULT_PROPERTY_DETAILS[ i ]; - if( 0 == strcmp( name.c_str(), property->name ) ) // dont want to convert rhs to string - { - index = DEFAULT_GESTURE_DETECTOR_PROPERTY_START_INDEX + i; - break; - } - } - return index; -} - -bool PanGestureDetector::IsDefaultPropertyWritable(Property::Index index) const -{ - // None of our properties should be writable through the Public API - return DEFAULT_PROPERTY_DETAILS[ index - DEFAULT_GESTURE_DETECTOR_PROPERTY_START_INDEX ].writable; -} - -bool PanGestureDetector::IsDefaultPropertyAnimatable(Property::Index index) const -{ - // None of our properties are animatable - return DEFAULT_PROPERTY_DETAILS[ index - DEFAULT_GESTURE_DETECTOR_PROPERTY_START_INDEX ].animatable; -} - -bool PanGestureDetector::IsDefaultPropertyAConstraintInput( Property::Index index ) const -{ - // All our properties can be used as an input to a constraint. - return DEFAULT_PROPERTY_DETAILS[ index - DEFAULT_GESTURE_DETECTOR_PROPERTY_START_INDEX ].constraintInput; -} - -Property::Type PanGestureDetector::GetDefaultPropertyType(Property::Index index) const -{ - index -= DEFAULT_GESTURE_DETECTOR_PROPERTY_START_INDEX; - if ( ( index >= 0 ) && ( index < DEFAULT_PROPERTY_COUNT ) ) - { - return DEFAULT_PROPERTY_DETAILS[ index ].type; - } - else - { - // Index out-of-range - return Property::NONE; - } -} - void PanGestureDetector::SetDefaultProperty( Property::Index index, const Property::Value& property ) { // None of our properties should be settable from Public API diff --git a/dali/internal/event/events/pan-gesture-detector-impl.h b/dali/internal/event/events/pan-gesture-detector-impl.h index 845b714..dc0eed7 100644 --- a/dali/internal/event/events/pan-gesture-detector-impl.h +++ b/dali/internal/event/events/pan-gesture-detector-impl.h @@ -214,46 +214,6 @@ private: // Default property extensions from Object /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyCount() - */ - virtual unsigned int GetDefaultPropertyCount() const; - - /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyIndices() - */ - virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const; - - /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyName() - */ - virtual const char* GetDefaultPropertyName(Property::Index index) const; - - /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyIndex() - */ - virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const; - - /** - * @copydoc Dali::Internal::Object::IsDefaultPropertyWritable() - */ - virtual bool IsDefaultPropertyWritable(Property::Index index) const; - - /** - * @copydoc Dali::Internal::Object::IsDefaultPropertyAnimatable() - */ - virtual bool IsDefaultPropertyAnimatable(Property::Index index) const; - - /** - * @copydoc Dali::Internal::Object::IsDefaultPropertyAConstraintInput() - */ - virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const; - - /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyType() - */ - virtual Property::Type GetDefaultPropertyType(Property::Index index) const; - - /** * @copydoc Dali::Internal::Object::SetDefaultProperty() */ virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue); diff --git a/dali/internal/event/object/custom-object-internal.cpp b/dali/internal/event/object/custom-object-internal.cpp index 0ea8d5b..3bd6bca 100644 --- a/dali/internal/event/object/custom-object-internal.cpp +++ b/dali/internal/event/object/custom-object-internal.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -58,45 +58,6 @@ const PropertyInputImpl* CustomObject::GetSceneObjectInputProperty( Property::In return GetSceneObjectAnimatableProperty( index ); } -unsigned int CustomObject::GetDefaultPropertyCount() const -{ - return 0u; -} - -void CustomObject::GetDefaultPropertyIndices( Property::IndexContainer& indices ) const -{ -} - -const char* CustomObject::GetDefaultPropertyName( Property::Index index ) const -{ - return NULL; -} - -Property::Index CustomObject::GetDefaultPropertyIndex(const std::string& name) const -{ - return Property::INVALID_INDEX; -} - -bool CustomObject::IsDefaultPropertyWritable(Property::Index index) const -{ - return false; -} - -bool CustomObject::IsDefaultPropertyAnimatable(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; -} - void CustomObject::SetDefaultProperty( Property::Index index, const Property::Value& property ) { // do nothing diff --git a/dali/internal/event/object/custom-object-internal.h b/dali/internal/event/object/custom-object-internal.h index 574426e..22877bd 100644 --- a/dali/internal/event/object/custom-object-internal.h +++ b/dali/internal/event/object/custom-object-internal.h @@ -58,46 +58,6 @@ public: virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const; /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyCount() - */ - virtual unsigned int GetDefaultPropertyCount() const; - - /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyIndices() - */ - virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const; - - /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyName() - */ - virtual const char* GetDefaultPropertyName(Property::Index index) const; - - /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyIndex() - */ - virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const; - - /** - * @copydoc Dali::Internal::Object::IsDefaultPropertyWritable() - */ - virtual bool IsDefaultPropertyWritable(Property::Index index) const; - - /** - * @copydoc Dali::Internal::Object::IsDefaultPropertyAnimatable() - */ - virtual bool IsDefaultPropertyAnimatable(Property::Index index) const; - - /** - * @copydoc Dali::Internal::Object::IsDefaultPropertyAConstraintInput() - */ - virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const; - - /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyType() - */ - virtual Property::Type GetDefaultPropertyType(Property::Index index) const; - - /** * @copydoc Dali::Internal::Object::SetDefaultProperty() */ virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue); diff --git a/dali/internal/event/object/default-property-metadata.h b/dali/internal/event/object/default-property-metadata.h new file mode 100644 index 0000000..a95a9cd --- /dev/null +++ b/dali/internal/event/object/default-property-metadata.h @@ -0,0 +1,55 @@ +#ifndef DALI_DEFAULT_PROPERTY_METADATA_H +#define DALI_DEFAULT_PROPERTY_METADATA_H + +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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. + * + */ + +// INTERNAL INCLUDES +#include + +namespace Dali +{ +/** + * @addtogroup dali_core_object + * @{ + */ + +/** + * @brief Structure for setting up default properties and their details. + */ +struct PropertyDetails +{ + const char* name; ///< The name of the property. + Property::Index enumIndex; ///< Used to check the index is correct within a debug build. + Property::Type type; ///< The property type. + bool writable; ///< Whether the property is writable + bool animatable; ///< Whether the property is animatable. + bool constraintInput; ///< Whether the property can be used as an input to a constraint. +}; + +/** + * Struct to capture the address of the default property table and count of them. + */ +struct DefaultPropertyMetadata +{ + const PropertyDetails* propertyTable; ///< address of the table defining property meta-data. + Property::Index propertyCount; ///< count of the default properties. +}; + +} // namespace Dali + +#endif // DALI_DEFAULT_PROPERTY_METADATA_H diff --git a/dali/internal/event/render-tasks/render-task-impl.cpp b/dali/internal/event/render-tasks/render-task-impl.cpp index 183d8eb..a95703f 100644 --- a/dali/internal/event/render-tasks/render-task-impl.cpp +++ b/dali/internal/event/render-tasks/render-task-impl.cpp @@ -59,13 +59,13 @@ DALI_PROPERTY( "viewportPosition", VECTOR2, true, true, true, Dali DALI_PROPERTY( "viewportSize", VECTOR2, true, true, true, Dali::RenderTask::Property::VIEWPORT_SIZE ) DALI_PROPERTY( "clearColor", VECTOR4, true, true, true, Dali::RenderTask::Property::CLEAR_COLOR ) DALI_PROPERTY( "requiresSync", BOOLEAN, true, false, false, Dali::RenderTask::Property::REQUIRES_SYNC ) -DALI_PROPERTY_TABLE_END( DEFAULT_OBJECT_PROPERTY_START_INDEX ) +DALI_PROPERTY_TABLE_END( DEFAULT_OBJECT_PROPERTY_START_INDEX, RenderTaskDefaultProperties ) // Signals const char* const SIGNAL_FINISHED = "finished"; -TypeRegistration mType( typeid( Dali::RenderTask ), typeid( Dali::BaseHandle ), NULL ); +TypeRegistration mType( typeid( Dali::RenderTask ), typeid( Dali::BaseHandle ), NULL, RenderTaskDefaultProperties ); SignalConnectorType signalConnector1( mType, SIGNAL_FINISHED, &RenderTask::DoConnectSignal ); @@ -506,76 +506,6 @@ void RenderTask::DiscardSceneObject() ******************************** PROPERTY METHODS ************************** ********************************************************************************/ -uint32_t RenderTask::GetDefaultPropertyCount() const -{ - return DEFAULT_PROPERTY_COUNT; -} - -void RenderTask::GetDefaultPropertyIndices( Property::IndexContainer& indices ) const -{ - indices.Reserve( DEFAULT_PROPERTY_COUNT ); - - for ( int i = 0; i < DEFAULT_PROPERTY_COUNT; ++i ) - { - indices.PushBack( i ); - } -} - -const char* RenderTask::GetDefaultPropertyName( Property::Index index ) const -{ - if( index < DEFAULT_PROPERTY_COUNT ) - { - return DEFAULT_PROPERTY_DETAILS[index].name; - } - else - { - return NULL; - } -} - -Property::Index RenderTask::GetDefaultPropertyIndex(const std::string& name) const -{ - Property::Index index = Property::INVALID_INDEX; - - // Look for name in default properties - for( int i = 0; i < DEFAULT_PROPERTY_COUNT; ++i ) - { - if( 0 == strcmp( name.c_str(), DEFAULT_PROPERTY_DETAILS[i].name ) ) // dont want to convert rhs to string - { - index = i; - break; - } - } - - return index; -} - -bool RenderTask::IsDefaultPropertyWritable(Property::Index index) const -{ - return DEFAULT_PROPERTY_DETAILS[ index ].writable; -} - -bool RenderTask::IsDefaultPropertyAnimatable(Property::Index index) const -{ - return DEFAULT_PROPERTY_DETAILS[ index ].animatable; -} - -bool RenderTask::IsDefaultPropertyAConstraintInput( Property::Index index ) const -{ - return DEFAULT_PROPERTY_DETAILS[ index ].constraintInput; -} - -Property::Type RenderTask::GetDefaultPropertyType(Property::Index index) const -{ - if( index < DEFAULT_PROPERTY_COUNT ) - { - return DEFAULT_PROPERTY_DETAILS[index].type; - } - - // index out of range...return Property::NONE - return Property::NONE; -} - void RenderTask::SetDefaultProperty( Property::Index index, const Property::Value& property ) { switch ( index ) diff --git a/dali/internal/event/render-tasks/render-task-impl.h b/dali/internal/event/render-tasks/render-task-impl.h index 8b57800..8b9f8aa 100644 --- a/dali/internal/event/render-tasks/render-task-impl.h +++ b/dali/internal/event/render-tasks/render-task-impl.h @@ -261,46 +261,6 @@ public: // Used by RenderTaskList, which owns the SceneGraph::RenderTasks public: // Implementation of Object /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyCount() - */ - virtual uint32_t GetDefaultPropertyCount() const; - - /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyIndices() - */ - virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const; - - /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyName() - */ - virtual const char* GetDefaultPropertyName(Property::Index index) const; - - /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyIndex() - */ - virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const; - - /** - * @copydoc Dali::Internal::Object::IsDefaultPropertyWritable() - */ - virtual bool IsDefaultPropertyWritable(Property::Index index) const; - - /** - * @copydoc Dali::Internal::Object::IsDefaultPropertyAnimatable() - */ - virtual bool IsDefaultPropertyAnimatable(Property::Index index) const; - - /** - * @copydoc Dali::Internal::Object::IsDefaultPropertyAConstraintInput() - */ - virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const; - - /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyType() - */ - virtual Property::Type GetDefaultPropertyType(Property::Index index) const; - - /** * @copydoc Dali::Internal::Object::SetDefaultProperty() */ virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue); diff --git a/dali/internal/event/rendering/geometry-impl.cpp b/dali/internal/event/rendering/geometry-impl.cpp index ef8131f..c27f7af 100644 --- a/dali/internal/event/rendering/geometry-impl.cpp +++ b/dali/internal/event/rendering/geometry-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,8 +20,7 @@ // INTERNAL INCLUDES #include - -#include // Dali::Internal::ObjectHelper +#include #include namespace Dali diff --git a/dali/internal/event/rendering/renderer-impl.cpp b/dali/internal/event/rendering/renderer-impl.cpp index 624a91a..2f66002 100644 --- a/dali/internal/event/rendering/renderer-impl.cpp +++ b/dali/internal/event/rendering/renderer-impl.cpp @@ -66,7 +66,7 @@ DALI_PROPERTY( "stencilOperationOnFail", INTEGER, true, false, false DALI_PROPERTY( "stencilOperationOnZFail", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL ) DALI_PROPERTY( "stencilOperationOnZPass", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_OPERATION_ON_Z_PASS ) DALI_PROPERTY( "opacity", FLOAT, true, true, true, Dali::DevelRenderer::Property::OPACITY ) -DALI_PROPERTY_TABLE_END( DEFAULT_RENDERER_PROPERTY_START_INDEX ) +DALI_PROPERTY_TABLE_END( DEFAULT_RENDERER_PROPERTY_START_INDEX, RendererDefaultProperties ) // Property string to enumeration tables: @@ -160,14 +160,12 @@ DALI_ENUM_TO_STRING_WITH_SCOPE( StencilOperation, INCREMENT_WRAP ) DALI_ENUM_TO_STRING_WITH_SCOPE( StencilOperation, DECREMENT_WRAP ) DALI_ENUM_TO_STRING_TABLE_END( STENCIL_OPERATION ) -const ObjectImplHelper RENDERER_IMPL = { DEFAULT_PROPERTY_DETAILS, DEFAULT_RENDERER_PROPERTY_START_INDEX }; - BaseHandle Create() { return Dali::BaseHandle(); } -TypeRegistration mType( typeid( Dali::Renderer ), typeid( Dali::Handle ), Create ); +TypeRegistration mType( typeid( Dali::Renderer ), typeid( Dali::Handle ), Create, RendererDefaultProperties ); } // unnamed namespace @@ -337,46 +335,6 @@ SceneGraph::Renderer* Renderer::GetRendererSceneObject() return mSceneObject; } -uint32_t Renderer::GetDefaultPropertyCount() const -{ - return RENDERER_IMPL.GetDefaultPropertyCount(); -} - -void Renderer::GetDefaultPropertyIndices( Property::IndexContainer& indices ) const -{ - RENDERER_IMPL.GetDefaultPropertyIndices( indices ); -} - -const char* Renderer::GetDefaultPropertyName(Property::Index index) const -{ - return RENDERER_IMPL.GetDefaultPropertyName( index ); -} - -Property::Index Renderer::GetDefaultPropertyIndex( const std::string& name ) const -{ - return RENDERER_IMPL.GetDefaultPropertyIndex( name ); -} - -bool Renderer::IsDefaultPropertyWritable( Property::Index index ) const -{ - return RENDERER_IMPL.IsDefaultPropertyWritable( index ); -} - -bool Renderer::IsDefaultPropertyAnimatable( Property::Index index ) const -{ - return RENDERER_IMPL.IsDefaultPropertyAnimatable( index ); -} - -bool Renderer::IsDefaultPropertyAConstraintInput( Property::Index index ) const -{ - return RENDERER_IMPL.IsDefaultPropertyAConstraintInput( index ); -} - -Property::Type Renderer::GetDefaultPropertyType( Property::Index index ) const -{ - return RENDERER_IMPL.GetDefaultPropertyType( index ); -} - void Renderer::SetDefaultProperty( Property::Index index, const Property::Value& propertyValue ) { @@ -649,7 +607,7 @@ void Renderer::SetSceneGraphProperty( Property::Index index, const PropertyMetadata& entry, const Property::Value& value ) { - RENDERER_IMPL.SetSceneGraphProperty( GetEventThreadServices(), this, index, entry, value ); + ObjectImplHelper::SetSceneGraphProperty( GetEventThreadServices(), this, index, entry, value ); OnPropertySet(index, value); } @@ -727,11 +685,10 @@ const SceneGraph::PropertyBase* Renderer::GetSceneObjectAnimatableProperty( Prop DALI_ASSERT_ALWAYS( IsPropertyAnimatable(index) && "Property is not animatable" ); const SceneGraph::PropertyBase* property = NULL; - property = RENDERER_IMPL.GetRegisteredSceneGraphProperty( - this, - &Renderer::FindAnimatableProperty, - &Renderer::FindCustomProperty, - index ); + property = ObjectImplHelper::GetRegisteredSceneGraphProperty( this, + &Renderer::FindAnimatableProperty, + &Renderer::FindCustomProperty, + index ); if( !property ) { @@ -748,11 +705,10 @@ const PropertyInputImpl* Renderer::GetSceneObjectInputProperty( Property::Index { const PropertyInputImpl* property = NULL; - const SceneGraph::PropertyBase* baseProperty = - RENDERER_IMPL.GetRegisteredSceneGraphProperty( this, - &Renderer::FindAnimatableProperty, - &Renderer::FindCustomProperty, - index ); + const SceneGraph::PropertyBase* baseProperty = ObjectImplHelper::GetRegisteredSceneGraphProperty( this, + &Renderer::FindAnimatableProperty, + &Renderer::FindCustomProperty, + index ); property = static_cast( baseProperty ); return property; @@ -843,12 +799,12 @@ bool Renderer::GetCachedPropertyValue( Property::Index index, Property::Value& v } case Dali::Renderer::Property::BLEND_EQUATION_RGB: { - value = static_cast( mBlendingOptions.GetBlendEquationRgb() ); + value = static_cast( mBlendingOptions.GetBlendEquationRgb() ); break; } case Dali::Renderer::Property::BLEND_EQUATION_ALPHA: { - value = static_cast( mBlendingOptions.GetBlendEquationAlpha() ); + value = static_cast( mBlendingOptions.GetBlendEquationAlpha() ); break; } case Dali::Renderer::Property::BLEND_FACTOR_SRC_RGB: @@ -858,7 +814,7 @@ bool Renderer::GetCachedPropertyValue( Property::Index index, Property::Value& v BlendFactor::Type srcFactorAlpha; BlendFactor::Type destFactorAlpha; GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha ); - value = static_cast( srcFactorRgb ); + value = static_cast( srcFactorRgb ); break; } case Dali::Renderer::Property::BLEND_FACTOR_DEST_RGB: @@ -868,7 +824,7 @@ bool Renderer::GetCachedPropertyValue( Property::Index index, Property::Value& v BlendFactor::Type srcFactorAlpha; BlendFactor::Type destFactorAlpha; GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha ); - value = static_cast( destFactorRgb ); + value = static_cast( destFactorRgb ); break; } case Dali::Renderer::Property::BLEND_FACTOR_SRC_ALPHA: @@ -878,7 +834,7 @@ bool Renderer::GetCachedPropertyValue( Property::Index index, Property::Value& v BlendFactor::Type srcFactorAlpha; BlendFactor::Type destFactorAlpha; GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha ); - value = static_cast( srcFactorAlpha ); + value = static_cast( srcFactorAlpha ); break; } case Dali::Renderer::Property::BLEND_FACTOR_DEST_ALPHA: @@ -888,7 +844,7 @@ bool Renderer::GetCachedPropertyValue( Property::Index index, Property::Value& v BlendFactor::Type srcFactorAlpha; BlendFactor::Type destFactorAlpha; GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha ); - value = static_cast( destFactorAlpha ); + value = static_cast( destFactorAlpha ); break; } case Dali::Renderer::Property::BLEND_COLOR: @@ -903,12 +859,12 @@ bool Renderer::GetCachedPropertyValue( Property::Index index, Property::Value& v } case Dali::Renderer::Property::INDEX_RANGE_FIRST: { - value = static_cast( mIndexedDrawFirstElement ); + value = static_cast( mIndexedDrawFirstElement ); break; } case Dali::Renderer::Property::INDEX_RANGE_COUNT: { - value = static_cast( mIndexedDrawElementCount ); + value = static_cast( mIndexedDrawElementCount ); break; } case Dali::Renderer::Property::DEPTH_WRITE_MODE: @@ -1008,7 +964,7 @@ bool Renderer::GetCurrentPropertyValue( Property::Index index, Property::Value& uint32_t bitMask = mSceneObject->GetBlendingOptions(); BlendingOptions blendingOptions; blendingOptions.SetBitmask( bitMask ); - value = static_cast( blendingOptions.GetBlendEquationRgb() ); + value = static_cast( blendingOptions.GetBlendEquationRgb() ); break; } case Dali::Renderer::Property::BLEND_EQUATION_ALPHA: @@ -1016,7 +972,7 @@ bool Renderer::GetCurrentPropertyValue( Property::Index index, Property::Value& uint32_t bitMask = mSceneObject->GetBlendingOptions(); BlendingOptions blendingOptions; blendingOptions.SetBitmask( bitMask ); - value = static_cast( blendingOptions.GetBlendEquationAlpha() ); + value = static_cast( blendingOptions.GetBlendEquationAlpha() ); break; } case Dali::Renderer::Property::BLEND_FACTOR_SRC_RGB: @@ -1024,7 +980,7 @@ bool Renderer::GetCurrentPropertyValue( Property::Index index, Property::Value& uint32_t bitMask = mSceneObject->GetBlendingOptions(); BlendingOptions blendingOptions; blendingOptions.SetBitmask( bitMask ); - value = static_cast( blendingOptions.GetBlendSrcFactorRgb() ); + value = static_cast( blendingOptions.GetBlendSrcFactorRgb() ); break; } case Dali::Renderer::Property::BLEND_FACTOR_DEST_RGB: @@ -1032,7 +988,7 @@ bool Renderer::GetCurrentPropertyValue( Property::Index index, Property::Value& uint32_t bitMask = mSceneObject->GetBlendingOptions(); BlendingOptions blendingOptions; blendingOptions.SetBitmask( bitMask ); - value = static_cast( blendingOptions.GetBlendDestFactorRgb() ); + value = static_cast( blendingOptions.GetBlendDestFactorRgb() ); break; } case Dali::Renderer::Property::BLEND_FACTOR_SRC_ALPHA: @@ -1040,7 +996,7 @@ bool Renderer::GetCurrentPropertyValue( Property::Index index, Property::Value& uint32_t bitMask = mSceneObject->GetBlendingOptions(); BlendingOptions blendingOptions; blendingOptions.SetBitmask( bitMask ); - value = static_cast( blendingOptions.GetBlendSrcFactorAlpha() ); + value = static_cast( blendingOptions.GetBlendSrcFactorAlpha() ); break; } case Dali::Renderer::Property::BLEND_FACTOR_DEST_ALPHA: @@ -1048,7 +1004,7 @@ bool Renderer::GetCurrentPropertyValue( Property::Index index, Property::Value& uint32_t bitMask = mSceneObject->GetBlendingOptions(); BlendingOptions blendingOptions; blendingOptions.SetBitmask( bitMask ); - value = static_cast( blendingOptions.GetBlendDestFactorAlpha() ); + value = static_cast( blendingOptions.GetBlendDestFactorAlpha() ); break; } case Dali::Renderer::Property::BLEND_COLOR: diff --git a/dali/internal/event/rendering/renderer-impl.h b/dali/internal/event/rendering/renderer-impl.h index 8323595..f02d39c 100755 --- a/dali/internal/event/rendering/renderer-impl.h +++ b/dali/internal/event/rendering/renderer-impl.h @@ -170,46 +170,6 @@ public: public: // Default property extensions from Object /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyCount() - */ - virtual unsigned int GetDefaultPropertyCount() const; - - /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyIndices() - */ - virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const; - - /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyName() - */ - virtual const char* GetDefaultPropertyName(Property::Index index) const; - - /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyIndex() - */ - virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const; - - /** - * @copydoc Dali::Internal::Object::IsDefaultPropertyWritable() - */ - virtual bool IsDefaultPropertyWritable(Property::Index index) const; - - /** - * @copydoc Dali::Internal::Object::IsDefaultPropertyAnimatable() - */ - virtual bool IsDefaultPropertyAnimatable(Property::Index index) const; - - /** - * @copydoc Dali::Internal::Object::IsDefaultPropertyAConstraintInput() - */ - virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const; - - /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyType() - */ - virtual Property::Type GetDefaultPropertyType(Property::Index index) const; - - /** * @copydoc Dali::Internal::Object::SetDefaultProperty() */ virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue); diff --git a/dali/internal/event/rendering/shader-impl.cpp b/dali/internal/event/rendering/shader-impl.cpp index 88b5483..1e670c9 100644 --- a/dali/internal/event/rendering/shader-impl.cpp +++ b/dali/internal/event/rendering/shader-impl.cpp @@ -40,9 +40,7 @@ namespace */ DALI_PROPERTY_TABLE_BEGIN DALI_PROPERTY( "program", MAP, true, false, false, Dali::Shader::Property::PROGRAM ) -DALI_PROPERTY_TABLE_END( DEFAULT_ACTOR_PROPERTY_START_INDEX ) - -const ObjectImplHelper SHADER_IMPL = { DEFAULT_PROPERTY_DETAILS, DEFAULT_ACTOR_PROPERTY_START_INDEX }; +DALI_PROPERTY_TABLE_END( DEFAULT_ACTOR_PROPERTY_START_INDEX, ShaderDefaultProperties ) Dali::Scripting::StringEnum ShaderHintsTable[] = { { "NONE", Dali::Shader::Hint::NONE}, @@ -57,7 +55,7 @@ BaseHandle Create() return Dali::BaseHandle(); } -TypeRegistration mType( typeid( Dali::Shader ), typeid( Dali::Handle ), Create ); +TypeRegistration mType( typeid( Dali::Shader ), typeid( Dali::Handle ), Create, ShaderDefaultProperties ); #define TOKEN_STRING(x) (#x) @@ -114,46 +112,6 @@ SceneGraph::Shader* Shader::GetShaderSceneObject() return mSceneObject; } -unsigned int Shader::GetDefaultPropertyCount() const -{ - return SHADER_IMPL.GetDefaultPropertyCount(); -} - -void Shader::GetDefaultPropertyIndices( Property::IndexContainer& indices ) const -{ - SHADER_IMPL.GetDefaultPropertyIndices( indices ); -} - -const char* Shader::GetDefaultPropertyName(Property::Index index) const -{ - return SHADER_IMPL.GetDefaultPropertyName( index ); -} - -Property::Index Shader::GetDefaultPropertyIndex( const std::string& name ) const -{ - return SHADER_IMPL.GetDefaultPropertyIndex( name ); -} - -bool Shader::IsDefaultPropertyWritable( Property::Index index ) const -{ - return SHADER_IMPL.IsDefaultPropertyWritable( index ); -} - -bool Shader::IsDefaultPropertyAnimatable( Property::Index index ) const -{ - return SHADER_IMPL.IsDefaultPropertyAnimatable( index ); -} - -bool Shader::IsDefaultPropertyAConstraintInput( Property::Index index ) const -{ - return SHADER_IMPL.IsDefaultPropertyAConstraintInput( index ); -} - -Property::Type Shader::GetDefaultPropertyType( Property::Index index ) const -{ - return SHADER_IMPL.GetDefaultPropertyType( index ); -} - void Shader::SetDefaultProperty( Property::Index index, const Property::Value& propertyValue ) { @@ -204,7 +162,7 @@ void Shader::SetSceneGraphProperty( Property::Index index, const PropertyMetadata& entry, const Property::Value& value ) { - SHADER_IMPL.SetSceneGraphProperty( GetEventThreadServices(), this, index, entry, value ); + ObjectImplHelper::SetSceneGraphProperty( GetEventThreadServices(), this, index, entry, value ); OnPropertySet(index, value); } @@ -251,10 +209,10 @@ const SceneGraph::PropertyBase* Shader::GetSceneObjectAnimatableProperty( Proper DALI_ASSERT_ALWAYS( IsPropertyAnimatable( index ) && "Property is not animatable" ); const SceneGraph::PropertyBase* property = NULL; - property = SHADER_IMPL.GetRegisteredSceneGraphProperty( this, - &Shader::FindAnimatableProperty, - &Shader::FindCustomProperty, - index ); + property = ObjectImplHelper::GetRegisteredSceneGraphProperty( this, + &Shader::FindAnimatableProperty, + &Shader::FindCustomProperty, + index ); if( property == NULL && index < DEFAULT_PROPERTY_MAX_COUNT ) { diff --git a/dali/internal/event/rendering/shader-impl.h b/dali/internal/event/rendering/shader-impl.h index a736103..9b01b2a 100644 --- a/dali/internal/event/rendering/shader-impl.h +++ b/dali/internal/event/rendering/shader-impl.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_SHADER_H /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -69,46 +69,6 @@ public: public: // Default property extensions from Object /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyCount() - */ - virtual unsigned int GetDefaultPropertyCount() const; - - /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyIndices() - */ - virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const; - - /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyName() - */ - virtual const char* GetDefaultPropertyName(Property::Index index) const; - - /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyIndex() - */ - virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const; - - /** - * @copydoc Dali::Internal::Object::IsDefaultPropertyWritable() - */ - virtual bool IsDefaultPropertyWritable(Property::Index index) const; - - /** - * @copydoc Dali::Internal::Object::IsDefaultPropertyAnimatable() - */ - virtual bool IsDefaultPropertyAnimatable(Property::Index index) const; - - /** - * @copydoc Dali::Internal::Object::IsDefaultPropertyAConstraintInput() - */ - virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const; - - /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyType() - */ - virtual Property::Type GetDefaultPropertyType(Property::Index index) const; - - /** * @copydoc Dali::Internal::Object::SetDefaultProperty() */ virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue); diff --git a/dali/internal/event/rendering/texture-set-impl.cpp b/dali/internal/event/rendering/texture-set-impl.cpp index b4d4793..349eaa6 100644 --- a/dali/internal/event/rendering/texture-set-impl.cpp +++ b/dali/internal/event/rendering/texture-set-impl.cpp @@ -20,7 +20,7 @@ // INTERNAL INCLUDES #include -#include // Dali::Internal::ObjectHelper +#include #include #include diff --git a/dali/public-api/object/base-handle.h b/dali/public-api/object/base-handle.h index 861e1e7..36b1887 100644 --- a/dali/public-api/object/base-handle.h +++ b/dali/public-api/object/base-handle.h @@ -158,8 +158,8 @@ public: * @brief Returns the type info for the Handle. * * @SINCE_1_0.0 - * @param[in] info The type information - * @return The type info + * @param[out] info The type information + * @return true if the type info exists */ bool GetTypeInfo(Dali::TypeInfo& info) const; diff --git a/dali/public-api/object/type-info.cpp b/dali/public-api/object/type-info.cpp index 92f1b67..c4fef99 100644 --- a/dali/public-api/object/type-info.cpp +++ b/dali/public-api/object/type-info.cpp @@ -98,7 +98,7 @@ void TypeInfo::GetPropertyIndices( Property::IndexContainer& indices ) const const std::string& TypeInfo::GetPropertyName( Property::Index index ) const { - return GetImplementation(*this).GetPropertyName( index ); + return GetImplementation(*this).GetRegisteredPropertyName( index ); } Property::Index TypeInfo::GetChildPropertyIndex( const std::string& name ) const diff --git a/dali/public-api/object/type-info.h b/dali/public-api/object/type-info.h index 1a8d702..53a1d91 100644 --- a/dali/public-api/object/type-info.h +++ b/dali/public-api/object/type-info.h @@ -220,7 +220,7 @@ public: * @param[in] index The property index * @return The name of the property at the given index * @exception DaliException If index is not valid. - * + * @note this method only works for custom registered properties */ const std::string& GetPropertyName( Property::Index index ) const; diff --git a/dali/public-api/object/type-registry.cpp b/dali/public-api/object/type-registry.cpp index 40686c9..48a1c45 100644 --- a/dali/public-api/object/type-registry.cpp +++ b/dali/public-api/object/type-registry.cpp @@ -23,6 +23,7 @@ // INTERNAL INCLUDES #include #include +#include namespace Dali { @@ -82,10 +83,7 @@ TypeRegistration::TypeRegistration( const std::type_info& registerType, const st { Internal::TypeRegistry *impl = Internal::TypeRegistry::Get(); - if( impl->Register( registerType, baseType, f, false ) ) - { - mName = impl->RegistrationName( registerType ); - } + mName = impl->Register( registerType, baseType, f, false ); } TypeRegistration::TypeRegistration( const std::type_info& registerType, const std::type_info& baseType, @@ -94,10 +92,15 @@ TypeRegistration::TypeRegistration( const std::type_info& registerType, const st { Internal::TypeRegistry *impl = Internal::TypeRegistry::Get(); - if( impl->Register( registerType, baseType, f, callCreateOnInit ) ) - { - mName = impl->RegistrationName( registerType ); - } + mName = impl->Register( registerType, baseType, f, callCreateOnInit ); +} + +TypeRegistration::TypeRegistration( const std::type_info& registerType, const std::type_info& baseType, + TypeInfo::CreateFunction f, const DefaultPropertyMetadata& defaultProperties ) +{ + Internal::TypeRegistry *impl = Internal::TypeRegistry::Get(); + + mName = impl->Register( registerType, baseType, f, false, defaultProperties.propertyTable, defaultProperties.propertyCount ); } TypeRegistration::TypeRegistration( const std::string& name, const std::type_info& baseType, @@ -106,10 +109,7 @@ TypeRegistration::TypeRegistration( const std::string& name, const std::type_inf { Internal::TypeRegistry *impl = Internal::TypeRegistry::Get(); - if( impl->Register( name, baseType, f, false ) ) - { - mName = name; - } + mName = impl->Register( name, baseType, f, false ); } diff --git a/dali/public-api/object/type-registry.h b/dali/public-api/object/type-registry.h index 7f5715d..f4f66f3 100644 --- a/dali/public-api/object/type-registry.h +++ b/dali/public-api/object/type-registry.h @@ -18,7 +18,6 @@ * */ - // EXTERNAL INCLUDES #include #include // uint32_t @@ -38,6 +37,7 @@ namespace Internal DALI_INTERNAL { class TypeRegistry; } +class DefaultPropertyMetadata; /** * @brief The TypeRegistry allows registration of type instance creation functions. @@ -213,6 +213,17 @@ public: TypeInfo::CreateFunction f, bool callCreateOnInit ); /** + * @brief Constructor registers the type creation function. + * + * @param[in] registerType the type info for the type to be registered + * @param[in] baseType the base type info of registerType + * @param[in] f registerType instance creation function + * @param[in] defaultProperties the default property meta-data + */ + TypeRegistration( const std::type_info& registerType, const std::type_info& baseType, + TypeInfo::CreateFunction f, const DefaultPropertyMetadata& defaultProperties ); + + /** * @brief Constructor registers the type creation function for a named class or type. * * This allows types to be created dynamically from script. The name must be