static bool gTestConstraintCalled;
+LayoutDirection::Type gLayoutDirectionType;
+
struct TestConstraint
{
void operator()( Vector4& color, const PropertyInputContainer& /* inputs */ )
END_TEST;
}
+int UtcDaliActorPropertyClippingActorDrawOrder(void)
+{
+ // This test checks that a hierarchy of actors are drawn in the correct order when clipping is enabled.
+ tet_infoline( "Testing Actor::Property::CLIPPING_MODE draw order" );
+ TestApplication application;
+ TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
+ TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
+
+ /* We create a small tree of actors as follows:
+
+ A
+ / \
+ Clipping enabled -> B D
+ | |
+ C E
+
+ The correct draw order is "ABCDE" (the same as if clipping was not enabled).
+ */
+ Actor actors[5];
+ for( int i = 0; i < 5; ++i )
+ {
+ BufferImage image = BufferImage::New( 16u, 16u );
+ Actor actor = CreateRenderableActor( image );
+
+ // Setup dimensions and position so actor is not skipped by culling.
+ actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
+ actor.SetSize( 16.0f, 16.0f );
+
+ if( i == 0 )
+ {
+ actor.SetParentOrigin( ParentOrigin::CENTER );
+ }
+ else
+ {
+ float b = i > 2 ? 1.0f : -1.0f;
+ actor.SetParentOrigin( Vector3( 0.5 + ( 0.2f * b ), 0.8f, 0.8f ) );
+ }
+
+ actors[i] = actor;
+ }
+
+ // Enable clipping on the actor at the top of the left branch.
+ actors[1].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
+
+ // Build the scene graph.
+ Stage::GetCurrent().Add( actors[0] );
+
+ // Left branch:
+ actors[0].Add( actors[1] );
+ actors[1].Add( actors[2] );
+
+ // Right branch:
+ actors[0].Add( actors[3] );
+ actors[3].Add( actors[4] );
+
+ // Gather the call trace.
+ enabledDisableTrace.Reset();
+ enabledDisableTrace.Enable( true );
+ application.SendNotification();
+ application.Render();
+ enabledDisableTrace.Enable( false );
+
+ /* Check stencil is enabled and disabled again (as right-hand branch of tree is drawn).
+
+ Note: Correct enable call trace: StackTrace: Index:0, Function:Enable, ParamList:3042 StackTrace: Index:1, Function:Enable, ParamList:2960 StackTrace: Index:2, Function:Disable, ParamList:2960
+ Incorrect enable call trace: StackTrace: Index:0, Function:Enable, ParamList:3042 StackTrace: Index:1, Function:Enable, ParamList:2960
+ */
+ size_t startIndex = 0u;
+ DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable", "3042", startIndex ) );
+ DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable", "2960", startIndex ) ); // 2960 is GL_STENCIL_TEST
+ DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Disable", "2960", startIndex ) );
+
+ // Swap the clipping actor from top of left branch to top of right branch.
+ actors[1].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
+ actors[3].SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
+
+ // Gather the call trace.
+ enabledDisableTrace.Reset();
+ enabledDisableTrace.Enable( true );
+ application.SendNotification();
+ application.Render();
+ enabledDisableTrace.Enable( false );
+
+ // Check stencil is enabled but NOT disabled again (as right-hand branch of tree is drawn).
+ // This proves the draw order has remained the same.
+ startIndex = 0u;
+ DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Enable", "2960", startIndex ) );
+ DALI_TEST_CHECK( !enabledDisableTrace.FindMethodAndParamsFromStartIndex( "Disable", "2960", startIndex ) );
+
+ END_TEST;
+}
+
int UtcDaliActorPropertyClippingActorWithRendererOverride(void)
{
// This test checks that an actor with clipping will be ignored if overridden by the Renderer properties.
Property::Value value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
value.Get( preActorOrder );
- DevelActor::Raise( actorB );
+ actorB.Raise();
// Ensure sort order is calculated before next touch event
application.SendNotification();
value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
value.Get( preActorOrder );
- DevelActor::Lower( actorB );
+ actorB.Lower();
application.SendNotification(); // ensure sort order calculated before next touch event
value = actorB.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER );
tet_printf( "RaiseToTop ActorA\n" );
- DevelActor::RaiseToTop( actorA );
+ actorA.RaiseToTop();
application.SendNotification(); // ensure sorting order is calculated before next touch event
application.ProcessEvent( touchEvent );
tet_printf( "RaiseToTop ActorB\n" );
- DevelActor::RaiseToTop( actorB );
+ actorB.RaiseToTop();
application.SendNotification(); // Ensure sort order is calculated before next touch event
application.ProcessEvent( touchEvent );
tet_printf( "LowerToBottom ActorA then ActorB leaving Actor C at Top\n" );
- DevelActor::LowerToBottom( actorA );
+ actorA.LowerToBottom();
application.SendNotification();
application.Render();
- DevelActor::LowerToBottom( actorB );
+ actorB.LowerToBottom();
application.SendNotification();
application.Render();
tet_printf( "Raise actor B Above Actor C\n" );
- DevelActor::RaiseAbove( actorB, actorC );
+ actorB.RaiseAbove( actorC );
// Ensure sorting happens at end of Core::ProcessEvents() before next touch
application.SendNotification();
tet_printf( "Raise actor A Above Actor B\n" );
- DevelActor::RaiseAbove( actorA, actorB );
+ actorA.RaiseAbove( actorB );
// Ensure sorting happens at end of Core::ProcessEvents() before next touch
application.SendNotification();
tet_printf( "Lower actor C below Actor B ( actor B and A on same level due to insertion order) so C is below both \n" );
- DevelActor::LowerBelow( actorC, actorB );
+ actorC.LowerBelow( actorB );
// Ensure sorting happens at end of Core::ProcessEvents() before next touch
application.SendNotification();
application.Render();
tet_printf( "Lower actor C below Actor A leaving B on top\n" );
- DevelActor::LowerBelow( actorC, actorA );
+ actorC.LowerBelow( actorA );
// Ensure sorting happens at end of Core::ProcessEvents() before next touch
application.SendNotification();
application.Render();
tet_printf( "Lower actor B below Actor C leaving A on top\n" );
- DevelActor::LowerBelow( actorB, actorC );
+ actorB.LowerBelow( actorC );
// Ensure sorting happens at end of Core::ProcessEvents() before next touch
application.SendNotification();
application.Render();
tet_printf( "Raise actor A Above Actor C which have different parents\n" );
- DevelActor::RaiseAbove( actorA, actorC );
+ actorA.RaiseAbove( actorC );
// Ensure sorting happens at end of Core::ProcessEvents() before next touch
application.SendNotification();
tet_printf( "Raise actor A Above Actor C which have no parents\n" );
- DevelActor::RaiseAbove( actorA, actorC );
+ actorA.RaiseAbove( actorC );
// Ensure sorting happens at end of Core::ProcessEvents() before next touch
application.SendNotification();
stage.Add ( actorB );
tet_printf( "Lower actor A below Actor C when only A is not on stage \n" );
- DevelActor::LowerBelow( actorA, actorC );
+ actorA.LowerBelow( actorC );
// Ensure sorting happens at end of Core::ProcessEvents() before next touch
application.SendNotification();
application.Render();
tet_printf( "Raise actor B Above Actor C when only B has a parent\n" );
- DevelActor::RaiseAbove( actorB, actorC );
+ actorB.RaiseAbove( actorC );
// Ensure sorting happens at end of Core::ProcessEvents() before next touch
application.SendNotification();
ResetTouchCallbacks();
tet_printf( "Lower actor A below Actor C when only A has a parent\n" );
- DevelActor::LowerBelow( actorA, actorC );
+ actorA.LowerBelow( actorC );
// Ensure sorting happens at end of Core::ProcessEvents() before next touch
application.SendNotification();
ResetTouchCallbacks();
stage.Add ( actorC );
- DevelActor::RaiseAbove( actorA, actorC );
+ actorA.RaiseAbove( actorC );
// Ensure sorting happens at end of Core::ProcessEvents() before next touch
application.SendNotification();
application.Render();
stage.Add ( actorA );
tet_printf( "Raise actor B Above Actor C but B not parented\n" );
- DevelActor::Raise( actorB );
+ actorB.Raise();
application.SendNotification();
application.Render();
tet_printf( "Raise actor B Above Actor C but B not parented\n" );
ResetTouchCallbacks();
- DevelActor::Lower( actorC );
+ actorC.Lower();
// Sort actor tree before next touch event
application.SendNotification();
application.Render();
tet_printf( "Lower actor C below B but C not parented\n" );
- DevelActor::Lower( actorB );
+ actorB.Lower();
// Sort actor tree before next touch event
application.SendNotification();
application.Render();
tet_printf( "Raise actor B to top\n" );
- DevelActor::RaiseToTop( actorB );
+ actorB.RaiseToTop();
// Sort actor tree before next touch event
application.SendNotification();
application.Render();
tet_printf( "Lower actor C to Bottom, B stays at top\n" );
- DevelActor::LowerToBottom( actorC );
+ actorC.LowerToBottom();
application.SendNotification();
application.Render();
tet_infoline( "Raise actor A Above Actor A which is the same actor!!\n" );
- DevelActor::RaiseAbove( actorA, actorA );
+ actorA.RaiseAbove( actorA );
application.SendNotification();
application.Render();
ResetTouchCallbacks();
- DevelActor::RaiseAbove( actorA, actorC );
+ actorA.RaiseAbove( actorC );
application.SendNotification();
application.Render();
END_TEST;
}
+
+
+static void LayoutDirectionChanged( Actor actor, LayoutDirection::Type type )
+{
+ gLayoutDirectionType = type;
+}
+
+int UtcDaliActorLayoutDirectionProperty(void)
+{
+ TestApplication application;
+ tet_infoline( "Check layout direction property" );
+
+ Actor actor0 = Actor::New();
+ DALI_TEST_EQUALS( actor0.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
+ Stage::GetCurrent().Add( actor0 );
+
+ application.SendNotification();
+ application.Render();
+
+ Actor actor1 = Actor::New();
+ DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
+ Actor actor2 = Actor::New();
+ DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
+ Actor actor3 = Actor::New();
+ DALI_TEST_EQUALS( actor3.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
+ Actor actor4 = Actor::New();
+ DALI_TEST_EQUALS( actor4.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
+ Actor actor5 = Actor::New();
+ DALI_TEST_EQUALS( actor5.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
+ Actor actor6 = Actor::New();
+ DALI_TEST_EQUALS( actor6.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
+ Actor actor7 = Actor::New();
+ DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
+ Actor actor8 = Actor::New();
+ DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
+ Actor actor9 = Actor::New();
+ DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
+
+ actor1.Add( actor2 );
+ gLayoutDirectionType = LayoutDirection::LEFT_TO_RIGHT;
+ actor2.LayoutDirectionChangedSignal().Connect( LayoutDirectionChanged );
+
+ DALI_TEST_EQUALS( actor1.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), true, TEST_LOCATION );
+ actor1.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
+ DALI_TEST_EQUALS( actor1.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), false, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
+ DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
+ DALI_TEST_EQUALS( gLayoutDirectionType, LayoutDirection::RIGHT_TO_LEFT, TEST_LOCATION );
+
+ actor1.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, true );
+ actor0.Add( actor1 );
+ DALI_TEST_EQUALS( actor1.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
+ DALI_TEST_EQUALS( actor2.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
+
+ Stage::GetCurrent().Add( actor3 );
+ actor3.Add( actor4 );
+ actor4.Add( actor5 );
+ actor5.Add( actor6 );
+ actor5.Add( actor7 );
+ actor7.Add( actor8 );
+ actor8.Add( actor9 );
+ actor3.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
+ actor5.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
+
+ DALI_TEST_EQUALS( actor8.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), true, TEST_LOCATION );
+ actor8.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, false );
+ DALI_TEST_EQUALS( actor8.GetProperty< bool >( Actor::Property::INHERIT_LAYOUT_DIRECTION ), false, TEST_LOCATION );
+
+ actor7.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
+
+ DALI_TEST_EQUALS( actor3.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
+ DALI_TEST_EQUALS( actor4.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
+ DALI_TEST_EQUALS( actor5.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
+ DALI_TEST_EQUALS( actor6.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
+ DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
+ DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
+ DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
+
+ actor8.SetProperty( Actor::Property::LAYOUT_DIRECTION, "RIGHT_TO_LEFT" );
+ DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
+ DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
+
+ actor7.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT );
+ DALI_TEST_EQUALS( actor7.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
+ DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
+ DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
+
+ actor8.SetProperty( Actor::Property::INHERIT_LAYOUT_DIRECTION, true );
+ DALI_TEST_EQUALS( actor8.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
+ DALI_TEST_EQUALS( actor9.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
+
+ END_TEST;
+}