}
};
+struct OrientationComponentConstraint
+{
+ OrientationComponentConstraint(){}
+
+ void operator()( Quaternion& orientation, const PropertyInputContainer& inputs )
+ {
+ const Quaternion& parentOrientation = inputs[0]->GetQuaternion();
+ Vector3 pos, scale;
+ Quaternion rot;
+ orientation = parentOrientation;
+ }
+};
// OnRelayout
static bool gOnRelayoutCallBackCalled = false;
DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
- // first test default, which is INHERIT_PARENT_POSITION
+ // first test default, which is to inherit position
DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::INHERIT_PARENT_POSITION, TEST_LOCATION );
application.SendNotification();
application.Render(0); // should only really call Update as Render is not required to update scene
DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
- // Change inheritance mode to use parent
- child.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION );
- DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::USE_PARENT_POSITION, TEST_LOCATION );
+
+ //Change child position
+ Vector3 childOffset( -1.0f, 1.0f, 0.0f );
+ child.SetPosition( childOffset );
+
+ // Change inheritance mode to not inherit
+ child.SetPositionInheritanceMode( Dali::DONT_INHERIT_POSITION );
+ DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::DONT_INHERIT_POSITION, TEST_LOCATION );
+ application.SendNotification();
+ application.Render(0); // should only really call Update as Render is not required to update scene
+ DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
+ DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
+ DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
+ DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliActorSetInheritPosition(void)
+{
+ tet_infoline("Testing Actor::SetInheritPosition");
+ TestApplication application;
+
+ Actor parent = Actor::New();
+ Vector3 parentPosition( 1.0f, 2.0f, 3.0f );
+ parent.SetPosition( parentPosition );
+ parent.SetParentOrigin( ParentOrigin::CENTER );
+ parent.SetAnchorPoint( AnchorPoint::CENTER );
+ Stage::GetCurrent().Add( parent );
+
+ Actor child = Actor::New();
+ child.SetParentOrigin( ParentOrigin::CENTER );
+ child.SetAnchorPoint( AnchorPoint::CENTER );
+ Vector3 childPosition( 10.0f, 11.0f, 12.0f );
+ child.SetPosition( childPosition );
+ parent.Add( child );
+
+ // The actors should not have a world position yet
+ DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
+ DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION );
+
+ // first test default, which is to inherit position
+ DALI_TEST_EQUALS( child.IsPositionInherited(), true, TEST_LOCATION );
application.SendNotification();
application.Render(0); // should only really call Update as Render is not required to update scene
DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION );
DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
+ DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION );
- // Change inheritance mode to use parent + offset
- child.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION_PLUS_LOCAL_POSITION );
+ //Change child position
Vector3 childOffset( -1.0f, 1.0f, 0.0f );
child.SetPosition( childOffset );
- DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
+
+ // Use local position as world postion
+ child.SetInheritPosition( false );
+ DALI_TEST_EQUALS( child.IsPositionInherited(), false, TEST_LOCATION );
application.SendNotification();
application.Render(0); // should only really call Update as Render is not required to update scene
DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childOffset, TEST_LOCATION );
+ DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
- // Change inheritance mode to not inherit
- child.SetPositionInheritanceMode( Dali::DONT_INHERIT_POSITION );
- DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::DONT_INHERIT_POSITION, TEST_LOCATION );
+ //Change back to inherit position from parent
+ child.SetInheritPosition( true );
+ DALI_TEST_EQUALS( child.IsPositionInherited(), true, TEST_LOCATION );
application.SendNotification();
application.Render(0); // should only really call Update as Render is not required to update scene
DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION );
DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION );
DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION );
+ DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childOffset, TEST_LOCATION );
END_TEST;
}
float localX;
float localY;
+ application.SendNotification();
+ application.Render();
+
DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, 50.0f, 50.0f) );
DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION);
BufferImage imageA = BufferImage::New(16, 16);
BufferImage imageB = BufferImage::New(16, 16);
BufferImage imageC = BufferImage::New(16, 16);
- ImageActor a = ImageActor::New( imageA );
- ImageActor b = ImageActor::New( imageB );
- ImageActor c = ImageActor::New( imageC );
+ Actor a = CreateRenderableActor( imageA );
+ Actor b = CreateRenderableActor( imageB );
+ Actor c = CreateRenderableActor( imageC );
// Render a,b,c as regular non-overlays. so order will be:
// a (8)
child.SetScale( childScale );
parent.Add( child );
- // The actors should not have a world matrix yet
- DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION );
-
app.SendNotification();
app.Render(0);
app.Render();
Matrix parentMatrix(false);
parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition);
- Vector3 childWorldPosition = parentPosition + parentRotation * parentScale * childPosition;
- Quaternion childWorldRotation = parentRotation * childRotation;
- Vector3 childWorldScale = parentScale * childScale;
+ Matrix childMatrix(false);
+ childMatrix.SetTransformComponents( childScale, childRotation, childPosition );
+ //Child matrix should be the composition of child and parent
Matrix childWorldMatrix(false);
- childWorldMatrix.SetTransformComponents(childWorldScale, childWorldRotation, childWorldPosition);
+ Matrix::Multiply( childWorldMatrix, childMatrix, parentMatrix);
DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION );
DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), childWorldMatrix, 0.001, TEST_LOCATION );
Stage::GetCurrent().Add( child );
- // The actors should not have a world matrix yet
- DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION );
- DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION );
-
app.SendNotification();
app.Render(0);
app.Render();
END_TEST;
}
+int UtcDaliActorConstrainedToOrientation(void)
+{
+ TestApplication app;
+ tet_infoline(" UtcDaliActorConstrainedToOrientation");
+
+ Actor parent = Actor::New();
+ parent.SetParentOrigin(ParentOrigin::CENTER);
+ parent.SetAnchorPoint(AnchorPoint::CENTER);
+ Vector3 parentPosition( 10.0f, 20.0f, 30.0f);
+ Radian rotationAngle(Degree(85.0f));
+ Quaternion parentRotation(rotationAngle, Vector3::ZAXIS);
+ Vector3 parentScale( 1.0f, 2.0f, 3.0f );
+ parent.SetPosition( parentPosition );
+ parent.SetOrientation( parentRotation );
+ parent.SetScale( parentScale );
+ Stage::GetCurrent().Add( parent );
+
+ Actor child = Actor::New();
+ child.SetParentOrigin(ParentOrigin::CENTER);
+ Constraint posConstraint = Constraint::New<Quaternion>( child, Actor::Property::ORIENTATION, OrientationComponentConstraint() );
+ posConstraint.AddSource( Source( parent, Actor::Property::ORIENTATION ) );
+ posConstraint.Apply();
+
+ Stage::GetCurrent().Add( child );
+
+ app.SendNotification();
+ app.Render(0);
+ app.Render();
+ app.SendNotification();
+
+ DALI_TEST_EQUALS( child.GetCurrentOrientation(), parent.GetCurrentOrientation(), 0.001, TEST_LOCATION );
+ END_TEST;
+}
+
int UtcDaliActorUnparent(void)
{
TestApplication app;
END_TEST;
}
+int UtcDaliActorAnchorPointPropertyAsString(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+
+ actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_LEFT" );
+ DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
+
+ actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_CENTER" );
+ DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
+
+ actor.SetProperty( Actor::Property::ANCHOR_POINT, "TOP_RIGHT" );
+ DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
+
+ actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_LEFT" );
+ DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
+
+ actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER" );
+ DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER, TEST_LOCATION );
+
+ actor.SetProperty( Actor::Property::ANCHOR_POINT, "CENTER_RIGHT" );
+ DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
+
+ actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_LEFT" );
+ DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
+
+ actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_CENTER" );
+ DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
+
+ actor.SetProperty( Actor::Property::ANCHOR_POINT, "BOTTOM_RIGHT" );
+ DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
+
+ // Invalid should not change anything
+ actor.SetProperty( Actor::Property::ANCHOR_POINT, "INVALID_ARG" );
+ DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliActorParentOriginPropertyAsString(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+
+ actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_LEFT" );
+ DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, TEST_LOCATION );
+
+ actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_CENTER" );
+ DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_CENTER, TEST_LOCATION );
+
+ actor.SetProperty( Actor::Property::PARENT_ORIGIN, "TOP_RIGHT" );
+ DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
+
+ actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_LEFT" );
+ DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_LEFT, TEST_LOCATION );
+
+ actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER" );
+ DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER, TEST_LOCATION );
+
+ actor.SetProperty( Actor::Property::PARENT_ORIGIN, "CENTER_RIGHT" );
+ DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::CENTER_RIGHT, TEST_LOCATION );
+
+ actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_LEFT" );
+ DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_LEFT, TEST_LOCATION );
+
+ actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_CENTER" );
+ DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_CENTER, TEST_LOCATION );
+
+ actor.SetProperty( Actor::Property::PARENT_ORIGIN, "BOTTOM_RIGHT" );
+ DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
+
+ // Invalid should not change anything
+ actor.SetProperty( Actor::Property::PARENT_ORIGIN, "INVALID_ARG" );
+ DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::BOTTOM_RIGHT, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliActorColorModePropertyAsString(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+
+ actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_COLOR" );
+ DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_COLOR, TEST_LOCATION );
+
+ actor.SetProperty( Actor::Property::COLOR_MODE, "USE_PARENT_COLOR" );
+ DALI_TEST_EQUALS( actor.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION );
+
+ actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_COLOR" );
+ DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
+
+ actor.SetProperty( Actor::Property::COLOR_MODE, "USE_OWN_MULTIPLY_PARENT_ALPHA" );
+ DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
+
+ // Invalid should not change anything
+ actor.SetProperty( Actor::Property::COLOR_MODE, "INVALID_ARG" );
+ DALI_TEST_EQUALS( actor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_ALPHA, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliActorPositionInheritancePropertyAsString(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+
+ actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INHERIT_PARENT_POSITION" );
+ DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), INHERIT_PARENT_POSITION, TEST_LOCATION );
+
+ actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION" );
+ DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION, TEST_LOCATION );
+
+ actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "USE_PARENT_POSITION_PLUS_LOCAL_POSITION" );
+ DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION );
+
+ actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "DONT_INHERIT_POSITION" );
+ DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
+
+ // Invalid should not change anything
+ actor.SetProperty( Actor::Property::POSITION_INHERITANCE, "INVALID_ARG" );
+ DALI_TEST_EQUALS( actor.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliActorDrawModePropertyAsString(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+
+ actor.SetProperty( Actor::Property::DRAW_MODE, "NORMAL" );
+ DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::NORMAL, TEST_LOCATION );
+
+ actor.SetProperty( Actor::Property::DRAW_MODE, "OVERLAY_2D" );
+ DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::OVERLAY_2D, TEST_LOCATION );
+
+ actor.SetProperty( Actor::Property::DRAW_MODE, "STENCIL" );
+ DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
+
+ // Invalid should not change anything
+ actor.SetProperty( Actor::Property::DRAW_MODE, "INVALID_ARG" );
+ DALI_TEST_EQUALS( actor.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION );
+
+ END_TEST;
+}