From 072daa0a9f932383c59c7cf2dcf6f913dc1e224a Mon Sep 17 00:00:00 2001 From: Tom Robinson Date: Mon, 9 Feb 2015 15:57:17 +0000 Subject: [PATCH] Size Relative feature: cluster-example uses feature for verification Change-Id: Ifa7e11edfa0945dc114fced855261a0eee3efb0e --- examples/cluster/cluster-example.cpp | 52 ++++++++++-------------------------- 1 file changed, 14 insertions(+), 38 deletions(-) diff --git a/examples/cluster/cluster-example.cpp b/examples/cluster/cluster-example.cpp index 6af3c8d..91921f8 100644 --- a/examples/cluster/cluster-example.cpp +++ b/examples/cluster/cluster-example.cpp @@ -226,27 +226,6 @@ struct RescaleConstraint }; /** - * ClusterImageBorderSizeConstraint - */ -struct ClusterImageBorderSizeConstraint -{ - ClusterImageBorderSizeConstraint() - : mSizeOffset(Vector3(CLUSTER_IMAGE_BORDER_INDENT - 1, CLUSTER_IMAGE_BORDER_INDENT - 1, 0.0f) * 2.0f) - { - } - - Vector3 operator()(const Vector3& current, - const PropertyInput& referenceSizeProperty) - { - const Vector3& referenceSize = referenceSizeProperty.GetVector3(); - - return referenceSize + mSizeOffset; - } - - Vector3 mSizeOffset; ///< The amount to offset the size from referenceSize -}; - -/** * ShearEffectConstraint * * Constrains ShearEffect's tilt to be a function of scrollview's @@ -620,32 +599,29 @@ public: shadowActor.SetAnchorPoint(AnchorPoint::CENTER); shadowActor.SetPosition(Vector3(0.0f, 0.0f, -1.0f)); - // Apply size constraint to the image shadow - shadowActor.ApplyConstraint( Constraint::New( Actor::SIZE, ParentSource( Actor::SIZE ), RelativeToConstraint( ShadowProperty::SIZE_SCALE ) ) ); - actor.Add(shadowActor); + // Apply size-relative mode to auto-size the image shadow + shadowActor.SetSizeMode( SIZE_RELATIVE_TO_PARENT ); + shadowActor.SetSizeModeFactor( ShadowProperty::SIZE_SCALE ); + actor.Add( shadowActor ); - // Add a picture image actor to actor. + // Add a picture image actor to actor (with equal size to the parent). Image image = Image::New( imagePath, attribs ); - ImageActor imageActor = ImageActor::New(image); + ImageActor imageActor = ImageActor::New( image ); imageActor.SetParentOrigin( ParentOrigin::CENTER ); imageActor.SetAnchorPoint( AnchorPoint::CENTER ); - imageActor.ApplyConstraint( Constraint::New( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) ); - actor.Add(imageActor); + imageActor.SetSizeMode( SIZE_EQUAL_TO_PARENT ); + actor.Add( imageActor ); - // Add a border image child actor - ImageActor borderActor = ImageActor::New(mClusterBorderImage); + // Add a border image child actor (with a fixed size offset from parent). + ImageActor borderActor = ImageActor::New( mClusterBorderImage ); borderActor.SetParentOrigin( ParentOrigin::CENTER ); borderActor.SetAnchorPoint( AnchorPoint::CENTER ); borderActor.SetStyle( ImageActor::STYLE_NINE_PATCH ); borderActor.SetNinePatchBorder( CLUSTER_IMAGE_BORDER_ABSOLUTE ); - borderActor.SetPosition(Vector3(0.0f, 0.0f, 1.0f)); - - // Apply size constraint to the image border - Constraint constraint = Constraint::New(Actor::SIZE, - ParentSource(Actor::SIZE), - ClusterImageBorderSizeConstraint()); - borderActor.ApplyConstraint(constraint); - actor.Add(borderActor); + borderActor.SetPosition( Vector3( 0.0f, 0.0f, 1.0f ) ); + borderActor.SetSizeMode( SIZE_FIXED_OFFSET_FROM_PARENT ); + borderActor.SetSizeModeFactor( Vector3( CLUSTER_IMAGE_BORDER_INDENT - 1.0f, CLUSTER_IMAGE_BORDER_INDENT - 1.0f, 0.0f ) * 2.0f ); + actor.Add( borderActor ); return actor; } -- 2.7.4