#include <stdlib.h>
#include <cmath>
#include <dali/public-api/dali-core.h>
+#include <dali/devel-api/actors/actor-devel.h>
+
#include "dali-test-suite-utils/dali-test-suite-utils.h"
" 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
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<Property::Index>(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;
END_TEST;
}
-
int utcDaliActorGetTypeInfo(void)
{
TestApplication application;
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<UnregisteredCustomActor*>(&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<bool>(), 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<Vector3>(), TEST_LOCATION );
+ DALI_TEST_EQUALS( Vector3( 100.0f, 150.0f, 200.0f ), custom.GetCurrentPosition(), TEST_LOCATION );
+
+ Dali::WeakHandle<UnregisteredCustomActorHandle> 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;
+}
+
test_return_value = TET_PASS;
}
-
int UtcDaliRendererNew01(void)
{
TestApplication application;
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<Property::Index>(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;
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;
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
// 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();
// 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();
// 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" );
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;
END_TEST;
}
-int UtcDaliPropertyRegistrationInvalidGetAndSet(void)
+int UtcDaliPropertyRegistrationUnregisteredGetAndSet(void)
{
TestApplication application;
int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 2000;
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<bool>(), 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<bool>(), 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;
}
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;
}
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;
}
{
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,
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
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 );
}
}
-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 )
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();
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();
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;
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
// 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 );
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 )
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
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)
#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.
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 );
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;
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
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 );
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 )
#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.
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()
#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.
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 ){}
/*
- * 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.
#include <cstring> // for strcmp
// INTERNAL INCLUDES
-#include <dali/internal/event/common/property-helper.h>
#include <dali/public-api/animation/constraint.h>
#include <dali/public-api/object/property-array.h>
+#include <dali/public-api/object/type-registry.h>
+#include <dali/internal/event/common/property-helper.h>
namespace Dali
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
{
}
-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 )
}
}
-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<float>( target.object, target.propertyIndex, LinearConstraintFunctor( mValue, mProgress, range, wrap ) );
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);
/*
- * 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.
#include <cstring> // for strcmp
// INTERNAL INCLUDES
-#include <dali/internal/event/common/property-helper.h>
#include <dali/public-api/animation/constraint.h>
#include <dali/public-api/object/property-array.h>
+#include <dali/public-api/object/type-registry.h>
+#include <dali/internal/event/common/property-helper.h>
namespace Dali
{
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
{
}
-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 )
}
}
-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);
#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.
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);
#include <cstring> // for strcmp
// INTERNAL INCLUDES
-#include <dali/internal/event/common/property-helper.h>
#include <dali/public-api/object/property-array.h>
#include <dali/public-api/object/type-registry.h>
+#include <dali/internal/event/common/property-helper.h>
namespace Dali
{
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
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<Vector3>& point, const Dali::Vector<Vector3>& controlPoint)
{
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 )
}
}
-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 );
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);
/*
- * 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.
* limitations under the License.
*/
-#include "event-thread-services.h"
+// CLASS HEADER
+#include <dali/internal/event/common/event-thread-services.h>
+// INTERNAL INCLUDES
#include <dali/internal/event/common/thread-local-storage.h>
namespace Dali
// INTERNAL INCLUDES
#include <dali/public-api/object/property.h> // Dali::Property
-#include <dali/public-api/object/property-index-ranges.h> // DEFAULT_DERIVED_HANDLE_PROPERTY_START_INDEX
-#include <dali/internal/event/common/property-helper.h> // Dali::Internal::PropertyDetails
-#include <dali/internal/event/common/stage-impl.h>
+#include <dali/internal/event/common/event-thread-services.h>
#include <dali/internal/update/common/animatable-property.h>
#include <dali/internal/update/common/property-owner-messages.h>
#include <dali/internal/update/manager/update-manager.h>
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:
- *<pre>
- * typename ObjectImplHelper<DEFAULT_PROPERTY_COUNT, DEFAULT_PROPERTY_DETAILS> MyObjectImpl;
- *
- * MyObjectImpl::GetDefaultPropertyCount();
- * </pre>
+ * Helper utilities to be used by class that implement Object
*/
-template<int DEFAULT_PROPERTY_COUNT>
-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 )
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();
#include <dali/internal/update/common/property-owner-messages.h>
#include <dali/internal/update/common/uniform-map.h>
#include <dali/internal/event/animation/constraint-impl.h>
-#include <dali/internal/event/common/stage-impl.h>
+#include <dali/internal/event/common/property-helper.h>
#include <dali/internal/event/common/property-notification-impl.h>
+#include <dali/internal/event/common/stage-impl.h>
#include <dali/internal/event/common/type-registry-impl.h>
using Dali::Internal::SceneGraph::AnimatableProperty;
namespace // unnamed namespace
{
const int SUPPORTED_CAPABILITIES = Dali::Handle::DYNAMIC_PROPERTIES; // Object provides this capability
-typedef Dali::Vector<Object::Observer*>::Iterator ObserverIter;
-typedef Dali::Vector<Object::Observer*>::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
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)
{
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);
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<uint32_t>( mCustomProperties.Count() );
{
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<CustomPropertyMetadata*>(*iter);
if ( custom->name == name )
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<CustomPropertyMetadata*>(*iter);
if( custom->key == key )
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
{
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
{
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
{
{
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 );
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" );
}
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
}
else
{
- DALI_LOG_ERROR("Invalid property index\n");
+ DALI_LOG_ERROR( "Property index %d not found\n", index );
propertySet = false;
}
}
}
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)
}
else
{
- DALI_LOG_ERROR("Invalid property index\n");
+ DALI_LOG_ERROR( "Property index %d not found\n", index );
}
} // if custom
}
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)
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
{
indices.Clear();
- // Default Properties
- GetDefaultPropertyIndices( indices );
-
// Manual Properties
const TypeInfo* typeInfo( GetTypeInfo() );
if ( typeInfo )
{
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<CustomPropertyMetadata*>( *iter );
}
}
-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<PropertyBase> newProperty;
-
- switch ( propertyValue.GetType() )
- {
- case Property::BOOLEAN:
- {
- newProperty = new AnimatableProperty<bool>( propertyValue.Get<bool>() );
- break;
- }
-
- case Property::INTEGER:
- {
- newProperty = new AnimatableProperty<int>( propertyValue.Get<int>() );
- break;
- }
-
- case Property::FLOAT:
- {
- newProperty = new AnimatableProperty<float>( propertyValue.Get<float>() );
- break;
- }
-
- case Property::VECTOR2:
- {
- newProperty = new AnimatableProperty<Vector2>( propertyValue.Get<Vector2>() );
- break;
- }
-
- case Property::VECTOR3:
- {
- newProperty = new AnimatableProperty<Vector3>( propertyValue.Get<Vector3>() );
- break;
- }
-
- case Property::VECTOR4:
- {
- newProperty = new AnimatableProperty<Vector4>( propertyValue.Get<Vector4>() );
- break;
- }
-
- case Property::MATRIX:
- {
- newProperty = new AnimatableProperty<Matrix>( propertyValue.Get<Matrix>() );
- break;
- }
-
- case Property::MATRIX3:
- {
- newProperty = new AnimatableProperty<Matrix3>( propertyValue.Get<Matrix3>() );
- break;
- }
-
- case Property::ROTATION:
- {
- newProperty = new AnimatableProperty<Quaternion>( propertyValue.Get<Quaternion>() );
- 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<EventThreadServices&>(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 );
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 )
{
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 )
{
if( mPropertyNotifications )
{
- PropertyNotificationContainerIter iter = mPropertyNotifications->begin();
+ auto iter = mPropertyNotifications->begin();
while(iter != mPropertyNotifications->end() )
{
if(*iter == propertyNotification)
{
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
}
}
-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
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<CustomPropertyMetadata*>( mCustomProperties[ arrayIndex ] );
+ if( custom->childPropertyIndex == index )
+ {
+ property = custom;
+ }
+ }
+ }
+ else
+ {
+ int arrayIndex = index - PROPERTY_CUSTOM_START_INDEX;
+ if( arrayIndex >= 0 )
+ {
+ if( arrayIndex < static_cast<int>( mCustomProperties.Count() ) ) // we can only access the first 2 billion custom properties
+ {
+ property = static_cast<CustomPropertyMetadata*>(mCustomProperties[ arrayIndex ]);
+ }
+ }
+ }
+ return property;
+}
+
+AnimatablePropertyMetadata* Object::FindAnimatableProperty( Property::Index index ) const
+{
+ for( auto&& entry : mAnimatableProperties )
+ {
+ AnimatablePropertyMetadata* property = static_cast<AnimatablePropertyMetadata*>( 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<PropertyBase> newProperty;
+
+ switch ( propertyValue.GetType() )
+ {
+ case Property::BOOLEAN:
+ {
+ newProperty = new AnimatableProperty<bool>( propertyValue.Get<bool>() );
+ break;
+ }
+
+ case Property::INTEGER:
+ {
+ newProperty = new AnimatableProperty<int>( propertyValue.Get<int>() );
+ break;
+ }
+
+ case Property::FLOAT:
+ {
+ newProperty = new AnimatableProperty<float>( propertyValue.Get<float>() );
+ break;
+ }
+
+ case Property::VECTOR2:
+ {
+ newProperty = new AnimatableProperty<Vector2>( propertyValue.Get<Vector2>() );
+ break;
+ }
+
+ case Property::VECTOR3:
+ {
+ newProperty = new AnimatableProperty<Vector3>( propertyValue.Get<Vector3>() );
+ break;
+ }
+
+ case Property::VECTOR4:
+ {
+ newProperty = new AnimatableProperty<Vector4>( propertyValue.Get<Vector4>() );
+ break;
+ }
+
+ case Property::MATRIX:
+ {
+ newProperty = new AnimatableProperty<Matrix>( propertyValue.Get<Matrix>() );
+ break;
+ }
+
+ case Property::MATRIX3:
+ {
+ newProperty = new AnimatableProperty<Matrix3>( propertyValue.Get<Matrix3>() );
+ break;
+ }
+
+ case Property::ROTATION:
+ {
+ newProperty = new AnimatableProperty<Quaternion>( propertyValue.Get<Quaternion>() );
+ 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<EventThreadServices&>(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<AnimatablePropertyMetadata*>(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<AnimatablePropertyMetadata*>(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<CustomPropertyMetadata*>( 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<bool>* property = static_cast< const AnimatableProperty<bool>* >( entry->GetSceneGraphProperty() );
+ const AnimatableProperty<bool>* property = static_cast< const AnimatableProperty<bool>* >( entry.GetSceneGraphProperty() );
DALI_ASSERT_DEBUG( NULL != property );
value = (*property)[ bufferIndex ];
case Property::INTEGER:
{
- const AnimatableProperty<int>* property = static_cast< const AnimatableProperty<int>* >( entry->GetSceneGraphProperty() );
+ const AnimatableProperty<int>* property = static_cast< const AnimatableProperty<int>* >( entry.GetSceneGraphProperty() );
DALI_ASSERT_DEBUG( NULL != property );
value = (*property)[ bufferIndex ];
case Property::FLOAT:
{
- const AnimatableProperty<float>* property = static_cast< const AnimatableProperty<float>* >( entry->GetSceneGraphProperty() );
+ const AnimatableProperty<float>* property = static_cast< const AnimatableProperty<float>* >( entry.GetSceneGraphProperty() );
DALI_ASSERT_DEBUG( NULL != property );
value = (*property)[ bufferIndex ];
case Property::VECTOR2:
{
- const AnimatableProperty<Vector2>* property = static_cast< const AnimatableProperty<Vector2>* >( entry->GetSceneGraphProperty() );
+ const AnimatableProperty<Vector2>* property = static_cast< const AnimatableProperty<Vector2>* >( 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;
}
case Property::VECTOR3:
{
- const AnimatableProperty<Vector3>* property = static_cast< const AnimatableProperty<Vector3>* >( entry->GetSceneGraphProperty() );
+ const AnimatableProperty<Vector3>* property = static_cast< const AnimatableProperty<Vector3>* >( 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;
}
case Property::VECTOR4:
{
- const AnimatableProperty<Vector4>* property = static_cast< const AnimatableProperty<Vector4>* >( entry->GetSceneGraphProperty() );
+ const AnimatableProperty<Vector4>* property = static_cast< const AnimatableProperty<Vector4>* >( 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;
}
case Property::MATRIX:
{
- const AnimatableProperty<Matrix>* property = static_cast< const AnimatableProperty<Matrix>* >( entry->GetSceneGraphProperty() );
+ const AnimatableProperty<Matrix>* property = static_cast< const AnimatableProperty<Matrix>* >( entry.GetSceneGraphProperty() );
DALI_ASSERT_DEBUG( NULL != property );
value = (*property)[ bufferIndex ];
case Property::MATRIX3:
{
- const AnimatableProperty<Matrix3>* property = static_cast< const AnimatableProperty<Matrix3>* >( entry->GetSceneGraphProperty() );
+ const AnimatableProperty<Matrix3>* property = static_cast< const AnimatableProperty<Matrix3>* >( entry.GetSceneGraphProperty() );
DALI_ASSERT_DEBUG( NULL != property );
value = (*property)[ bufferIndex ];
case Property::ROTATION:
{
- const AnimatableProperty<Quaternion>* property = static_cast< const AnimatableProperty<Quaternion>* >( entry->GetSceneGraphProperty() );
+ const AnimatableProperty<Quaternion>* property = static_cast< const AnimatableProperty<Quaternion>* >( entry.GetSceneGraphProperty() );
DALI_ASSERT_DEBUG( NULL != property );
value = (*property)[ bufferIndex ];
}
}
-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<CustomPropertyMetadata*>( mCustomProperties[ arrayIndex ] );
- if( custom->childPropertyIndex == index )
- {
- property = custom;
- }
- }
- }
- else
- {
- int arrayIndex = index - PROPERTY_CUSTOM_START_INDEX;
- if( arrayIndex >= 0 )
- {
- if( arrayIndex < static_cast<int>( mCustomProperties.Count() ) ) // we can only access the first 2 billion custom properties
- {
- property = static_cast<CustomPropertyMetadata*>(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<AnimatablePropertyMetadata*>( 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<AnimatablePropertyMetadata*>(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<AnimatablePropertyMetadata*>(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<CustomPropertyMetadata*>( 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
*
*/
+// EXTERNAL INCLUDES
+#include <cstdint> // uint32_t
+
// INTERNAL INCLUDES
#include <dali/public-api/animation/constraint.h>
#include <dali/public-api/common/dali-vector.h>
* 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.
/**
* @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.
* @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()
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.
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.
* @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.
}
private:
+
EventThreadServices& mEventThreadServices;
private:
- typedef OwnerContainer<PropertyMetadata*> 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<Observer*> mObservers;
+ mutable OwnerContainer<PropertyMetadata*> mCustomProperties; ///< Used for accessing custom Node properties
+ mutable OwnerContainer<PropertyMetadata*> 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
// INTERNAL INCLUDES
#include <dali/integration-api/bitmap.h>
#include <dali/devel-api/scripting/enum-helper.h>
+#include <dali/internal/event/object/default-property-metadata.h>
namespace Dali
{
{
/**
- * @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<Property::Index>( sizeof( DEFAULT_PROPERTY_DETAILS ) / sizeof( Internal::PropertyDetails ) ); \
+#define DALI_PROPERTY_TABLE_END( startIndex, constantName ) }; const Property::Index DEFAULT_PROPERTY_COUNT = static_cast<Property::Index>( sizeof( DEFAULT_PROPERTY_DETAILS ) / sizeof( Dali::PropertyDetails ) ); \
struct PROPERTY_CHECK \
{ \
PROPERTY_CHECK() \
} \
} \
}; \
+ 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<Property::Index>( 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<Property::Index>( 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.
#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.
* @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(),
/**
* @brief The index of the property component.
*/
- int componentIndex;
+ int32_t componentIndex;
private:
using std::find_if;
+namespace Dali
+{
+
namespace
{
template <typename T>
struct PropertyComponentFinder
{
- PropertyComponentFinder( Dali::Property::Index basePropertyIndex, const int find )
+ PropertyComponentFinder( Property::Index basePropertyIndex, const int find )
: mBasePropertyIndex( basePropertyIndex ),
mFind( find )
{
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");
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;
{
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);
{
break;
}
- base = Dali::TypeRegistry::Get().GetTypeInfo( base.GetBaseName() );
+ base = mTypeRegistry.GetTypeInfo( base.GetBaseName() );
}
}
{
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;
{
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();
count += baseCount;
- base = Dali::TypeRegistry::Get().GetTypeInfo( base.GetBaseName() );
+ base = mTypeRegistry.GetTypeInfo( base.GetBaseName() );
}
}
{
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;
{
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();
count += baseCount;
- base = Dali::TypeRegistry::Get().GetTypeInfo( base.GetBaseName() );
+ base = mTypeRegistry.GetTypeInfo( base.GetBaseName() );
}
}
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 ) );
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 ) );
}
}
-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 )
}
}
-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" );
uint32_t TypeInfo::GetPropertyCount() const
{
- uint32_t count = static_cast<uint32_t>( mRegisteredProperties.size() );
+ uint32_t count = mDefaultPropertyCount + static_cast<uint32_t>( 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<uint32_t>( baseImpl.mRegisteredProperties.size() );
- base = TypeRegistry::Get()->GetTypeInfo( baseImpl.mBaseTypeName );
+ count += baseImpl.mDefaultPropertyCount + static_cast<uint32_t>( baseImpl.mRegisteredProperties.size() );
+ base = mTypeRegistry.GetTypeInfo( baseImpl.mBaseTypeName );
}
return count;
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 );
+ }
}
}
}
else
{
- Dali::TypeInfo base = TypeRegistry::Get()->GetTypeInfo( mBaseTypeName );
+ Dali::TypeInfo base = mTypeRegistry.GetTypeInfo( mBaseTypeName );
if ( base )
{
basePropertyIndex = GetImplementation(base).GetBasePropertyIndex( index );
}
else
{
- Dali::TypeInfo base = TypeRegistry::Get()->GetTypeInfo( mBaseTypeName );
+ Dali::TypeInfo base = mTypeRegistry.GetTypeInfo( mBaseTypeName );
if ( base )
{
componentIndex = GetImplementation(base).GetComponentIndex( index );
}
else
{
- Dali::TypeInfo base = TypeRegistry::Get()->GetTypeInfo( mBaseTypeName );
+ Dali::TypeInfo base = mTypeRegistry.GetTypeInfo( mBaseTypeName );
if ( base )
{
index = GetImplementation(base).GetChildPropertyIndex( name );
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
}
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 );
}
}
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 );
}
}
}
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 );
}
}
}
}
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() );
}
}
}
}
}
- 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
}
}
- 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
#include <dali/public-api/object/base-handle.h>
#include <dali/public-api/object/base-object.h>
#include <dali/public-api/object/type-info.h>
+#include <dali/public-api/object/property.h>
#include <dali/devel-api/object/csharp-type-info.h>
+#include <dali/internal/event/object/default-property-metadata.h>
namespace Dali
{
namespace Internal
{
+class PropertyDetails;
+class TypeRegistry;
/**
* A TypeInfo class to support registered type creation, and introspection of available
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
* @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
/**
* @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
* @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 );
* @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);
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.
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)
{
}
-
- 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<std::string, Dali::TypeInfo::SignalConnectorFunction > ConnectionPair;
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
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
return mRegistryLut.size();
}
-
std::string TypeRegistry::GetTypeName( size_t index ) const
{
std::string name;
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() );
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() );
{
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 )
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() );
{
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
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;
{
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
{
#include <dali/public-api/object/base-handle.h>
#include <dali/public-api/object/base-object.h>
#include <dali/internal/event/common/type-info-impl.h>
+#include <dali/internal/event/object/default-property-metadata.h>
namespace Dali
{
namespace Internal
{
-////////////////////////////////////////////////////////////////////////////////
-class TypeRegistry;
+class PropertyDetails;
/*
* @copydoc Dali::TypeRegistry
*/
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
*/
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
*/
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.
*/
*/
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;
}
}
-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
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);
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
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 );
// 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
// 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);
/*
- * 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.
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
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);
--- /dev/null
+#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 <dali/public-api/object/property.h>
+
+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
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 );
******************************** 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 )
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);
/*
- * 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.
// INTERNAL INCLUDES
#include <dali/public-api/object/type-registry.h>
-
-#include <dali/internal/event/common/object-impl-helper.h> // Dali::Internal::ObjectHelper
+#include <dali/internal/event/common/stage-impl.h>
#include <dali/internal/update/manager/update-manager.h>
namespace Dali
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:
DALI_ENUM_TO_STRING_WITH_SCOPE( StencilOperation, DECREMENT_WRAP )
DALI_ENUM_TO_STRING_TABLE_END( STENCIL_OPERATION )
-const ObjectImplHelper<DEFAULT_PROPERTY_COUNT> 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
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 )
{
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);
}
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 )
{
{
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<const PropertyInputImpl*>( baseProperty );
return property;
}
case Dali::Renderer::Property::BLEND_EQUATION_RGB:
{
- value = static_cast<int>( mBlendingOptions.GetBlendEquationRgb() );
+ value = static_cast<int32_t>( mBlendingOptions.GetBlendEquationRgb() );
break;
}
case Dali::Renderer::Property::BLEND_EQUATION_ALPHA:
{
- value = static_cast<int>( mBlendingOptions.GetBlendEquationAlpha() );
+ value = static_cast<int32_t>( mBlendingOptions.GetBlendEquationAlpha() );
break;
}
case Dali::Renderer::Property::BLEND_FACTOR_SRC_RGB:
BlendFactor::Type srcFactorAlpha;
BlendFactor::Type destFactorAlpha;
GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
- value = static_cast<int>( srcFactorRgb );
+ value = static_cast<int32_t>( srcFactorRgb );
break;
}
case Dali::Renderer::Property::BLEND_FACTOR_DEST_RGB:
BlendFactor::Type srcFactorAlpha;
BlendFactor::Type destFactorAlpha;
GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
- value = static_cast<int>( destFactorRgb );
+ value = static_cast<int32_t>( destFactorRgb );
break;
}
case Dali::Renderer::Property::BLEND_FACTOR_SRC_ALPHA:
BlendFactor::Type srcFactorAlpha;
BlendFactor::Type destFactorAlpha;
GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
- value = static_cast<int>( srcFactorAlpha );
+ value = static_cast<int32_t>( srcFactorAlpha );
break;
}
case Dali::Renderer::Property::BLEND_FACTOR_DEST_ALPHA:
BlendFactor::Type srcFactorAlpha;
BlendFactor::Type destFactorAlpha;
GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
- value = static_cast<int>( destFactorAlpha );
+ value = static_cast<int32_t>( destFactorAlpha );
break;
}
case Dali::Renderer::Property::BLEND_COLOR:
}
case Dali::Renderer::Property::INDEX_RANGE_FIRST:
{
- value = static_cast<int>( mIndexedDrawFirstElement );
+ value = static_cast<int32_t>( mIndexedDrawFirstElement );
break;
}
case Dali::Renderer::Property::INDEX_RANGE_COUNT:
{
- value = static_cast<int>( mIndexedDrawElementCount );
+ value = static_cast<int32_t>( mIndexedDrawElementCount );
break;
}
case Dali::Renderer::Property::DEPTH_WRITE_MODE:
uint32_t bitMask = mSceneObject->GetBlendingOptions();
BlendingOptions blendingOptions;
blendingOptions.SetBitmask( bitMask );
- value = static_cast<int>( blendingOptions.GetBlendEquationRgb() );
+ value = static_cast<int32_t>( blendingOptions.GetBlendEquationRgb() );
break;
}
case Dali::Renderer::Property::BLEND_EQUATION_ALPHA:
uint32_t bitMask = mSceneObject->GetBlendingOptions();
BlendingOptions blendingOptions;
blendingOptions.SetBitmask( bitMask );
- value = static_cast<int>( blendingOptions.GetBlendEquationAlpha() );
+ value = static_cast<int32_t>( blendingOptions.GetBlendEquationAlpha() );
break;
}
case Dali::Renderer::Property::BLEND_FACTOR_SRC_RGB:
uint32_t bitMask = mSceneObject->GetBlendingOptions();
BlendingOptions blendingOptions;
blendingOptions.SetBitmask( bitMask );
- value = static_cast<int>( blendingOptions.GetBlendSrcFactorRgb() );
+ value = static_cast<int32_t>( blendingOptions.GetBlendSrcFactorRgb() );
break;
}
case Dali::Renderer::Property::BLEND_FACTOR_DEST_RGB:
uint32_t bitMask = mSceneObject->GetBlendingOptions();
BlendingOptions blendingOptions;
blendingOptions.SetBitmask( bitMask );
- value = static_cast<int>( blendingOptions.GetBlendDestFactorRgb() );
+ value = static_cast<int32_t>( blendingOptions.GetBlendDestFactorRgb() );
break;
}
case Dali::Renderer::Property::BLEND_FACTOR_SRC_ALPHA:
uint32_t bitMask = mSceneObject->GetBlendingOptions();
BlendingOptions blendingOptions;
blendingOptions.SetBitmask( bitMask );
- value = static_cast<int>( blendingOptions.GetBlendSrcFactorAlpha() );
+ value = static_cast<int32_t>( blendingOptions.GetBlendSrcFactorAlpha() );
break;
}
case Dali::Renderer::Property::BLEND_FACTOR_DEST_ALPHA:
uint32_t bitMask = mSceneObject->GetBlendingOptions();
BlendingOptions blendingOptions;
blendingOptions.SetBitmask( bitMask );
- value = static_cast<int>( blendingOptions.GetBlendDestFactorAlpha() );
+ value = static_cast<int32_t>( blendingOptions.GetBlendDestFactorAlpha() );
break;
}
case Dali::Renderer::Property::BLEND_COLOR:
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);
*/
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<DEFAULT_PROPERTY_COUNT> 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},
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)
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 )
{
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);
}
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 )
{
#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.
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);
// INTERNAL INCLUDES
#include <dali/public-api/object/type-registry.h>
-#include <dali/internal/event/common/object-impl-helper.h> // Dali::Internal::ObjectHelper
+#include <dali/internal/event/common/stage-impl.h>
#include <dali/internal/update/manager/update-manager.h>
#include <dali/internal/update/rendering/scene-graph-texture-set.h>
* @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;
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
* @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;
// INTERNAL INCLUDES
#include <dali/public-api/object/property-index-ranges.h>
#include <dali/internal/event/common/type-registry-impl.h>
+#include <dali/internal/event/object/default-property-metadata.h>
namespace Dali
{
{
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,
{
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,
{
Internal::TypeRegistry *impl = Internal::TypeRegistry::Get();
- if( impl->Register( name, baseType, f, false ) )
- {
- mName = name;
- }
+ mName = impl->Register( name, baseType, f, false );
}
*
*/
-
// EXTERNAL INCLUDES
#include <typeinfo>
#include <cstdint> // uint32_t
{
class TypeRegistry;
}
+class DefaultPropertyMetadata;
/**
* @brief The TypeRegistry allows registration of type instance creation functions.
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