{
Stage stage = Stage::GetCurrent();
- // Creates the background image.
+ // Hide the indicator bar
+ application.GetWindow().ShowIndicator( Dali::Window::INVISIBLE );
+
+ // Use a gradient visual to render the background gradient.
Toolkit::Control background = Dali::Toolkit::Control::New();
background.SetAnchorPoint( Dali::AnchorPoint::CENTER );
background.SetParentOrigin( Dali::ParentOrigin::CENTER );
background.SetResizePolicy( Dali::ResizePolicy::FILL_TO_PARENT, Dali::Dimension::ALL_DIMENSIONS );
- Dali::Property::Map map;
- map["rendererType"] = "IMAGE";
- map["url"] = BACKGROUND_IMAGE;
- background.SetProperty( Dali::Toolkit::Control::Property::BACKGROUND, map );
+
+ // Set up the background gradient.
+ Property::Array stopOffsets;
+ stopOffsets.PushBack( 0.0f );
+ stopOffsets.PushBack( 1.0f );
+ Property::Array stopColors;
+ stopColors.PushBack( Vector4( 0.17f, 0.24f, 0.35f, 1.0f ) ); // Dark, medium saturated blue ( top of screen)
+ stopColors.PushBack( Vector4( 0.45f, 0.70f, 0.80f, 1.0f ) ); // Medium bright, pastel blue (bottom of screen)
+ const float percentageStageHeight = stage.GetSize().height * 0.7f;
+
+ background.SetProperty( Toolkit::Control::Property::BACKGROUND, Dali::Property::Map()
+ .Add( Toolkit::Visual::Property::TYPE, Dali::Toolkit::Visual::GRADIENT )
+ .Add( Toolkit::GradientVisual::Property::STOP_OFFSET, stopOffsets )
+ .Add( Toolkit::GradientVisual::Property::STOP_COLOR, stopColors )
+ .Add( Toolkit::GradientVisual::Property::START_POSITION, Vector2( 0.0f, -percentageStageHeight ) )
+ .Add( Toolkit::GradientVisual::Property::END_POSITION, Vector2( 0.0f, percentageStageHeight ) )
+ .Add( Toolkit::GradientVisual::Property::UNITS, Toolkit::GradientVisual::Units::USER_SPACE ) );
+
stage.Add( background );
// Create a TextLabel for the application title.
renderer.SetTextures( textureSet );
// Setup the renderer properties:
- // We are writing to the color buffer & culling back faces.
- renderer.SetProperty( Renderer::Property::WRITE_TO_COLOR_BUFFER, true );
+ // We are writing to the color buffer & culling back faces (no stencil is used for the main cube).
+ renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR );
renderer.SetProperty( Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::BACK );
- // No stencil is used for the main cube.
- renderer.SetProperty( Renderer::Property::STENCIL_MODE, StencilMode::OFF );
-
// We do need to write to the depth buffer as other objects need to appear underneath this cube.
renderer.SetProperty( Renderer::Property::DEPTH_WRITE_MODE, DepthWriteMode::ON );
// We do not need to test the depth buffer as we are culling the back faces.
renderer.SetTextures( planeTextureSet );
// Setup the renderer properties:
- // We are writing to the color buffer & culling back faces (as we are NOT doing depth write).
- renderer.SetProperty( Renderer::Property::WRITE_TO_COLOR_BUFFER, true );
+ // We are writing to the color buffer & culling back faces as we are NOT doing depth write (no stencil is used for the floor).
+ renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR );
renderer.SetProperty( Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::BACK );
- // No stencil is used for the floor.
- renderer.SetProperty( Renderer::Property::STENCIL_MODE, StencilMode::OFF );
-
// We do not write to the depth buffer as its not needed.
renderer.SetProperty( Renderer::Property::DEPTH_WRITE_MODE, DepthWriteMode::OFF );
// We do need to test the depth buffer as we need the floor to be underneath the cube.
Renderer renderer = CreateRenderer( planeGeometry, size, false, Vector4::ONE );
// Setup the renderer properties:
- // The stencil plane is only for stencilling, so disable writing to color buffer.
- renderer.SetProperty( Renderer::Property::WRITE_TO_COLOR_BUFFER, false );
+ // The stencil plane is only for stencilling.
+ renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::STENCIL );
- // Enable stencil. Draw to the stencil buffer (only).
- renderer.SetProperty( Renderer::Property::STENCIL_MODE, StencilMode::ON );
renderer.SetProperty( Renderer::Property::STENCIL_FUNCTION, StencilFunction::ALWAYS );
renderer.SetProperty( Renderer::Property::STENCIL_FUNCTION_REFERENCE, 1 );
renderer.SetProperty( Renderer::Property::STENCIL_FUNCTION_MASK, 0xFF );
renderer.SetTextures( textureSet );
// Setup the renderer properties:
- // Write to color buffer so reflection is visible
- renderer.SetProperty( Renderer::Property::WRITE_TO_COLOR_BUFFER, true );
+ // Write to color buffer so reflection is visible.
+ // Also enable the stencil buffer, as we will be testing against it to only draw to areas within the stencil.
+ renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR_STENCIL );
// We cull to skip drawing the back faces.
renderer.SetProperty( Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::BACK );
renderer.SetProperty( Renderer::Property::BLEND_FACTOR_DEST_RGB, BlendFactor::ONE );
// Enable stencil. Here we only draw to areas within the stencil.
- renderer.SetProperty( Renderer::Property::STENCIL_MODE, StencilMode::ON );
renderer.SetProperty( Renderer::Property::STENCIL_FUNCTION, StencilFunction::EQUAL );
renderer.SetProperty( Renderer::Property::STENCIL_FUNCTION_REFERENCE, 1 );
renderer.SetProperty( Renderer::Property::STENCIL_FUNCTION_MASK, 0xff );