- //Create the index buffer
- Property::Map indexFormat;
- indexFormat["indices"] = Property::UNSIGNED_INTEGER;
- PropertyBuffer indexBuffer = PropertyBuffer::New( indexFormat, 6u );
- indexBuffer.SetData(gQuadIndex);
-
- //Create the geometry
- Geometry mesh = Geometry::New();
- mesh.AddVertexBuffer( vertexBuffer );
- mesh.SetIndexBuffer( indexBuffer );
-
- //Add uniforms to the shader
- shader.RegisterProperty( "uBackgroundColor", color );
-
- //Create the renderer
- Renderer renderer = Renderer::New( mesh, material );
- renderer.SetDepthIndex( BACKGROUND_DEPTH_INDEX );
-
- //Create the actor
- Actor meshActor = Actor::New();
- meshActor.SetSize( Vector3::ONE );
- meshActor.AddRenderer( renderer );
- meshActor.SetPositionInheritanceMode( USE_PARENT_POSITION_PLUS_LOCAL_POSITION );
- meshActor.SetColorMode( USE_PARENT_COLOR );
-
- //Constraint scale of the mesh actor to the size of the control
- Constraint constraint = Constraint::New<Vector3>( meshActor,
- Actor::Property::SCALE,
- EqualToConstraint() );
- constraint.AddSource( ParentSource( Actor::Property::SIZE ) );
- constraint.Apply();
+ //Create the index buffer
+ Property::Map indexFormat;
+ indexFormat["indices"] = Property::INTEGER;
+ PropertyBuffer indexBuffer = PropertyBuffer::New( indexFormat, 6u );
+ indexBuffer.SetData(gQuadIndex);
+
+ //Create the geometry
+ Geometry mesh = Geometry::New();
+ mesh.AddVertexBuffer( vertexBuffer );
+ mesh.SetIndexBuffer( indexBuffer );
+
+ //Add uniforms to the shader
+ shader.RegisterProperty( "uBackgroundColor", color );
+
+ //Create the renderer
+ Renderer renderer = Renderer::New( mesh, material );
+ renderer.SetDepthIndex( parent.GetHierarchyDepth() + BACKGROUND_DEPTH_INDEX );
+
+ //Create the actor
+ Actor meshActor = Actor::New();
+ meshActor.SetSize( Vector3::ONE );
+ meshActor.AddRenderer( renderer );
+ meshActor.SetPositionInheritanceMode( USE_PARENT_POSITION_PLUS_LOCAL_POSITION );
+ meshActor.SetColorMode( USE_PARENT_COLOR );
+
+ //Constraint scale of the mesh actor to the size of the control
+ Constraint constraint = Constraint::New<Vector3>( meshActor,
+ Actor::Property::SCALE,
+ EqualToConstraint() );
+ constraint.AddSource( ParentSource( Actor::Property::SIZE ) );
+ constraint.Apply();
+
+ return meshActor;
+ }
+ else
+ {
+ ImageActor imageActor = ImageActor::New( image );
+ imageActor.SetColor( color );
+ imageActor.SetPositionInheritanceMode( USE_PARENT_POSITION_PLUS_LOCAL_POSITION );
+ imageActor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
+ imageActor.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
+ imageActor.SetSortModifier( parent.GetHierarchyDepth() + BACKGROUND_DEPTH_INDEX );
+
+ return imageActor;
+ }