- content.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
- tile.Add(content);
-
- // create background image
- if( addBackground )
- {
- Image bg = Image::New( TILE_BACKGROUND );
- ImageActor image = ImageActor::New( bg );
- image.SetAnchorPoint( AnchorPoint::CENTER );
- image.SetParentOrigin( ParentOrigin::CENTER );
- // make the image 100% of tile
- image.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
- // move image back to get text appear in front
- image.SetZ( -1 );
- image.SetStyle( ImageActor::STYLE_NINE_PATCH );
- image.SetNinePatchBorder( Vector4( IMAGE_BORDER_LEFT, IMAGE_BORDER_TOP, IMAGE_BORDER_RIGHT, IMAGE_BORDER_BOTTOM ) );
-
- content.Add( image );
-
- // Add stencil
- ImageActor stencil = NewStencilImage();
- stencil.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
- image.Add( stencil );
- }
-
- TextView text = TextView::New( title );
- text.SetAnchorPoint( AnchorPoint::CENTER );
- text.SetParentOrigin( ParentOrigin::CENTER );
- text.SetWidthExceedPolicy( Toolkit::TextView::ShrinkToFit );
- text.SetMultilinePolicy( Toolkit::TextView::SplitByWord );
- text.SetLineJustification( Toolkit::TextView::Center );
- text.SetTextAlignment( Toolkit::Alignment::Type( Alignment::HorizontalCenter | Alignment::VerticalCenter ) );
- text.SetColor( Color::WHITE );
- text.SetZ( 1 );
- // make the text 90% of tile
- text.SetSize( 0.9f * parentSize.width, 0.9f * parentSize.height );
- text.SetStyleToCurrentText( GetTableTextStyle() );
- text.SetSnapshotModeEnabled( false );
- content.Add( text );
+ content.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS );
+ content.SetSizeModeFactor( sizeMultiplier );
+
+ Toolkit::ImageView tileContent = ImageView::New();
+ tileContent.SetParentOrigin( ParentOrigin::CENTER );
+ tileContent.SetAnchorPoint( AnchorPoint::CENTER );
+ tileContent.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
+
+ // Add the image via the property first.
+ tileContent.SetProperty( Toolkit::ImageView::Property::IMAGE, TILE_BACKGROUND_ALPHA );
+ // Register a property with the ImageView. This allows us to inject the scroll-view position into the shader.
+ Property::Value value = Vector3( 0.0f, 0.0f, 0.0f );
+ Property::Index propertyIndex = tileContent.RegisterProperty( "uCustomPosition", value );
+
+ // Add a shader to the image (details in shader source).
+ Property::Map map;
+ Property::Map customShader;
+ customShader[ Visual::Shader::Property::FRAGMENT_SHADER ] = FRAGMENT_SHADER_TEXTURED;
+ map[ Visual::Property::SHADER ] = customShader;
+ tileContent.SetProperty( Toolkit::ImageView::Property::IMAGE, map );
+ tileContent.SetColor( TILE_COLOR );
+
+ // We create a constraint to perform a precalculation on the scroll-view X offset
+ // and pass it to the shader uniform, along with the tile's position.
+ Constraint shaderPosition = Constraint::New < Vector3 > ( tileContent, propertyIndex, TileShaderPositionConstraint( mPageWidth, position.x ) );
+ shaderPosition.AddSource( Source( mScrollView, ScrollView::Property::SCROLL_POSITION ) );
+ shaderPosition.SetRemoveAction( Constraint::Discard );
+ shaderPosition.Apply();
+ content.Add( tileContent );
+
+ // Create an ImageView for the 9-patch border around the tile.
+ ImageView image = ImageView::New( TILE_BACKGROUND );
+ image.SetAnchorPoint( AnchorPoint::CENTER );
+ image.SetParentOrigin( ParentOrigin::CENTER );
+ image.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
+ image.SetOpacity( 0.8f );
+ tileContent.Add( image );
+
+ TextLabel label = TextLabel::New();
+ label.SetAnchorPoint( AnchorPoint::CENTER );
+ label.SetParentOrigin( ParentOrigin::CENTER );
+ label.SetStyleName( "LauncherLabel" );
+ label.SetProperty( TextLabel::Property::MULTI_LINE, true );
+ label.SetProperty( TextLabel::Property::TEXT, title );
+ label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
+ label.SetProperty( TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
+ label.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT );
+
+ // Pad around the label as its size is the same as the 9-patch border. It will overlap it without padding.
+ label.SetPadding( Padding( TILE_LABEL_PADDING, TILE_LABEL_PADDING, TILE_LABEL_PADDING, TILE_LABEL_PADDING ) );
+ content.Add( label );