Commit 993edc0f831a00dc73d2a53d9abd9f98721c8d02
Committed by
Gerrit Code Review
Merge "Replaced gradient image with gradient visual in renderer-stencil.example" into devel/master
Showing
1 changed file
with
19 additions
and
5 deletions
examples/renderer-stencil/renderer-stencil-example.cpp
| @@ -119,15 +119,29 @@ private: | @@ -119,15 +119,29 @@ private: | ||
| 119 | // Hide the indicator bar | 119 | // Hide the indicator bar |
| 120 | application.GetWindow().ShowIndicator( Dali::Window::INVISIBLE ); | 120 | application.GetWindow().ShowIndicator( Dali::Window::INVISIBLE ); |
| 121 | 121 | ||
| 122 | - // Creates the background image. | 122 | + // Use a gradient visual to render the background gradient. |
| 123 | Toolkit::Control background = Dali::Toolkit::Control::New(); | 123 | Toolkit::Control background = Dali::Toolkit::Control::New(); |
| 124 | background.SetAnchorPoint( Dali::AnchorPoint::CENTER ); | 124 | background.SetAnchorPoint( Dali::AnchorPoint::CENTER ); |
| 125 | background.SetParentOrigin( Dali::ParentOrigin::CENTER ); | 125 | background.SetParentOrigin( Dali::ParentOrigin::CENTER ); |
| 126 | background.SetResizePolicy( Dali::ResizePolicy::FILL_TO_PARENT, Dali::Dimension::ALL_DIMENSIONS ); | 126 | background.SetResizePolicy( Dali::ResizePolicy::FILL_TO_PARENT, Dali::Dimension::ALL_DIMENSIONS ); |
| 127 | - Dali::Property::Map map; | ||
| 128 | - map["rendererType"] = "IMAGE"; | ||
| 129 | - map["url"] = BACKGROUND_IMAGE; | ||
| 130 | - background.SetProperty( Dali::Toolkit::Control::Property::BACKGROUND, map ); | 127 | + |
| 128 | + // Set up the background gradient. | ||
| 129 | + Property::Array stopOffsets; | ||
| 130 | + stopOffsets.PushBack( 0.0f ); | ||
| 131 | + stopOffsets.PushBack( 1.0f ); | ||
| 132 | + Property::Array stopColors; | ||
| 133 | + stopColors.PushBack( Vector4( 0.17f, 0.24f, 0.35f, 1.0f ) ); // Dark, medium saturated blue ( top of screen) | ||
| 134 | + stopColors.PushBack( Vector4( 0.45f, 0.70f, 0.80f, 1.0f ) ); // Medium bright, pastel blue (bottom of screen) | ||
| 135 | + const float percentageStageHeight = stage.GetSize().height * 0.7f; | ||
| 136 | + | ||
| 137 | + background.SetProperty( Toolkit::Control::Property::BACKGROUND, Dali::Property::Map() | ||
| 138 | + .Add( Toolkit::Visual::Property::TYPE, Dali::Toolkit::Visual::GRADIENT ) | ||
| 139 | + .Add( Toolkit::GradientVisual::Property::STOP_OFFSET, stopOffsets ) | ||
| 140 | + .Add( Toolkit::GradientVisual::Property::STOP_COLOR, stopColors ) | ||
| 141 | + .Add( Toolkit::GradientVisual::Property::START_POSITION, Vector2( 0.0f, -percentageStageHeight ) ) | ||
| 142 | + .Add( Toolkit::GradientVisual::Property::END_POSITION, Vector2( 0.0f, percentageStageHeight ) ) | ||
| 143 | + .Add( Toolkit::GradientVisual::Property::UNITS, Toolkit::GradientVisual::Units::USER_SPACE ) ); | ||
| 144 | + | ||
| 131 | stage.Add( background ); | 145 | stage.Add( background ); |
| 132 | 146 | ||
| 133 | // Create a TextLabel for the application title. | 147 | // Create a TextLabel for the application title. |