Updated demos to use DALi clang-format
[platform/core/uifw/dali-demo.git] / examples / gaussian-blur-view / gaussian-blur-view-example.cpp
index 7fce8a6..e9ff1cc 100644 (file)
-//
-// Copyright (c) 2014 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Flora License, Version 1.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://floralicense.org/license/
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an AS IS BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-
-#include <dali/dali.h>
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <algorithm>
+
 #include <dali-toolkit/dali-toolkit.h>
+#include <dali-toolkit/devel-api/controls/gaussian-blur-view/gaussian-blur-view.h>
 
 using namespace Dali;
-using namespace Dali::Toolkit;
+using Dali::Toolkit::GaussianBlurView;
+using Dali::Toolkit::TextLabel;
 
 namespace
 {
-
-//#define ADD_REMOVE_FROM_STAGE_TEST
-
-const char* BACKGROUND_IMAGE_PATH = DALI_IMAGE_DIR "desktop_background_1440x2560.png";
-const char* UI_DIFFUSE_IMAGE( DALI_IMAGE_DIR "UI-Leather-DIFF.png" );
-
-const Rect<int> UI_PIXEL_AREA( 0, 0, 720, 1280 );
-
-const Rect<int> PANEL1_PIXEL_AREA( 0, 0, 720,  39 );
-const Rect<int> PANEL2_PIXEL_AREA( 0, 39, 720, 100 );
-
-const unsigned int NUM_MOVEMENT_ANIMATIONS = 2;
-
-// for animating bloom intensity on tap gesture
-const float PULSE_BLOOM_INCREASE_ANIM_TIME = 1.175;
-const float PULSE_BLOOM_DECREASE_ANIM_TIME = 2.4;
-const float PULSE_BLOOM_TOTAL_ANIM_TIME = PULSE_BLOOM_INCREASE_ANIM_TIME + PULSE_BLOOM_DECREASE_ANIM_TIME;
-const float PULSE_BLOOM_INTENSITY_DEFAULT = 1.0f;
-const float PULSE_BLOOM_INTENSITY_INCREASE = 3.0f;
-
-
-// buttons
-const char* BUTTON_BACKGROUND_IMAGE_PATH = DALI_IMAGE_DIR "GreyThinLine30x30-76x78.png";
-
-// These values depend on the button background image
-const float BUTTON_IMAGE_BORDER_LEFT   = 16.0f;
-const float BUTTON_IMAGE_BORDER_RIGHT  = 16.0f;
-const float BUTTON_IMAGE_BORDER_TOP    = 13.0f;
-const float BUTTON_IMAGE_BORDER_BOTTOM = 20.0f;
-
-const Vector4 BUTTON_IMAGE_BORDER( BUTTON_IMAGE_BORDER_LEFT, BUTTON_IMAGE_BORDER_TOP, BUTTON_IMAGE_BORDER_RIGHT, BUTTON_IMAGE_BORDER_BOTTOM );
-
-const float UI_MARGIN = 4.0f;                              ///< Screen Margin for placement of UI buttons
-const Vector3 BUTTON_SIZE_CONSTRAINT( 0.24f, 0.09f, 1.0f );
-const char * BUTTON_QUIT = "Quit";
-const char * BUTTON_QUIT_LABEL ="Quit";
+const char* const BACKGROUND_IMAGE(DEMO_IMAGE_DIR "lake_front.jpg");
+const float       BACKGROUND_IMAGE_WIDTH = 2048.0f;
 
 } // namespace
 
-
-
 /**
- * This example demonstrates a blur effect.
+ * This example shows a scrolling background image which can be blurred (on/off) by tapping the screen
  */
-class TestApp : public ConnectionTracker
+class GaussianBlurViewExample : public ConnectionTracker
 {
 public:
-
-  TestApp( Application &application )
-  : mApplication(application)
-  , mCurrentAnimation(0)
+  GaussianBlurViewExample(Application& application)
+  : mApplication(application),
+    mExcessWidth(0.0f),
+    mStrength(1.0f),
+    mActivate(false)
   {
-    application.InitSignal().Connect(this, &TestApp::Create);
-    application.TerminateSignal().Connect(this, &TestApp::Terminate);
+    mApplication.InitSignal().Connect(this, &GaussianBlurViewExample::Create);
   }
 
-  ~TestApp()
-  {
-  }
-
-public:
+  ~GaussianBlurViewExample() = default;
 
+private:
   void Create(Application& application)
   {
-    // Preload images
-    mDiffuseImage = Image::New( UI_DIFFUSE_IMAGE );
+    auto    window     = application.GetWindow();
+    Vector2 windowSize = window.GetSize();
+    window.KeyEventSignal().Connect(this, &GaussianBlurViewExample::OnKeyEvent);
 
-    // Creation is deferred until images have loaded
-    mDiffuseImage.LoadingFinishedSignal().Connect( this, &TestApp::Create2 );
-  }
+    mImageView = Toolkit::ImageView::New(BACKGROUND_IMAGE);
+    mImageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
+    mImageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
 
-#ifdef ADD_REMOVE_FROM_STAGE_TEST
-  void Create2(Image loadedImage)
-  {
-    Stage stage = Stage::GetCurrent();
-    Vector2 stageSize = stage.GetSize();
-
-    mStageRootActor = Actor::New();
-    mStageRootActor.SetParentOrigin(ParentOrigin::CENTER);
-    mStageRootActor.SetSize(stageSize);
-    stage.Add(mStageRootActor);
-
-    // Create the object that will perform the blurring work
-    mGaussianBlurView = Dali::Toolkit::GaussianBlurView::New();
-    mGaussianBlurView.SetParentOrigin(ParentOrigin::CENTER);
-    mGaussianBlurView.SetSize(stageSize * 0.75f);
-    mStageRootActor.Add(mGaussianBlurView);
-    mGaussianBlurView.Activate();
-
-    // Create the background image
-    Image background = Image::New(BACKGROUND_IMAGE_PATH);
-    ImageActor backgroundImage = ImageActor::New(background);
-    backgroundImage.SetParentOrigin(ParentOrigin::CENTER);
-    backgroundImage.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
-
-    Layer backgroundLayer = Layer::New();
-    backgroundLayer.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
-    backgroundLayer.SetParentOrigin( ParentOrigin::CENTER );
-    mGaussianBlurView.Add( backgroundLayer );
-    backgroundLayer.Add( backgroundImage );
-
-    Layer foregroundLayer = Layer::New();
-    foregroundLayer.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
-    foregroundLayer.SetParentOrigin( ParentOrigin::CENTER );
-    mGaussianBlurView.Add( foregroundLayer );
-
-    // Create visible actors
-    mObjectRootActor = Actor::New();
-    mObjectRootActor.SetParentOrigin( ParentOrigin::CENTER );
-    mObjectRootActor.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
-    foregroundLayer.Add( mObjectRootActor );
-
-    ImageActor imageActor = ImageActor::New( mDiffuseImage );
-    imageActor.SetParentOrigin( ParentOrigin::CENTER );
-    imageActor.SetSize( stageSize * 0.75f);
-    mObjectRootActor.Add( imageActor );
-
-    imageActor = ImageActor::New( mDiffuseImage );
-    imageActor.SetParentOrigin( ParentOrigin::CENTER );
-    imageActor.SetSize( stageSize * 0.5f );
-    imageActor.SetPosition(0.0f, 0.0f, 100.0f);
-    mObjectRootActor.Add( imageActor );
-
-    AnimateGaussianBlurView();
-
-    // Gesture detection
-    mTapGestureDetector = TapGestureDetector::New();
-    mTapGestureDetector.Attach( mStageRootActor );
-    mTapGestureDetector.DetectedSignal().Connect( this, &TestApp::OnTap );
-  }
+    float excessWidth = std::max(0.0f, (BACKGROUND_IMAGE_WIDTH - windowSize.width) * 0.5f);
 
-  void AnimateGaussianBlurView()
-  {
-    if(mRotationAnimation)
+    if(excessWidth > 0.0f)
     {
-      mRotationAnimation.Stop();
-    }
-    if(mResizeAnimation)
-    {
-      mResizeAnimation.Stop();
-    }
-    if(mTranslationAnimation)
-    {
-      mTranslationAnimation.Stop();
-    }
-    if(mBlurAnimation)
-    {
-      mBlurAnimation.Stop();
-    }
-
-    // ROTATE
-    float animDuration = 10.0f;
-    mRotationAnimation = Animation::New(animDuration);
-    mRotationAnimation.RotateBy(mGaussianBlurView, Degree(720), Vector3::YAXIS, AlphaFunctions::EaseInOut);
-    mRotationAnimation.SetEndAction( Animation::Discard );
-    mRotationAnimation.SetLooping( true );
-    mRotationAnimation.Play();
-
-    // BLUR
-    mBlurAnimation = Animation::New( 4.0f );
-    mBlurAnimation.AnimateTo( Property( mGaussianBlurView, mGaussianBlurView.GetBlurStrengthPropertyIndex() ), 0.0f, AlphaFunctions::Linear, TimePeriod(0.0f, 0.5f) );
-    mBlurAnimation.AnimateTo( Property( mGaussianBlurView, mGaussianBlurView.GetBlurStrengthPropertyIndex() ), 1.0f, AlphaFunctions::Linear, TimePeriod(2.0f, 0.5f) );
-    mBlurAnimation.SetEndAction( Animation::Discard );
-    mBlurAnimation.SetLooping( true );
-    mBlurAnimation.Play();
-  }
-#else //#ifdef ADD_REMOVE_FROM_STAGE_TEST
-
-  void Create2(Image loadedImage)
-  {
-    Stage stage = Stage::GetCurrent();
-    Vector2 stageSize = stage.GetSize();
-
-    mStageRootActor = Actor::New();
-    mStageRootActor.SetParentOrigin(ParentOrigin::CENTER);
-    mStageRootActor.SetSize(stageSize);
-    stage.Add(mStageRootActor);
-
-    // Create the object that will perform the blurring work
-    mGaussianBlurView = Dali::Toolkit::GaussianBlurView::New();
-    mGaussianBlurView.SetParentOrigin(ParentOrigin::CENTER);
-    mGaussianBlurView.SetSize(stageSize * 0.75f);
-    mStageRootActor.Add(mGaussianBlurView);
-    mGaussianBlurView.Activate();
-
-    // Create the Quit button
-    PushButton button;
-    button = CreateButton(BUTTON_QUIT, BUTTON_QUIT_LABEL, BUTTON_SIZE_CONSTRAINT);
-    button.SetAnchorPoint(AnchorPoint::BOTTOM_RIGHT);
-    button.SetParentOrigin(ParentOrigin::BOTTOM_RIGHT);
-    button.SetPosition(-UI_MARGIN, -UI_MARGIN);
-
-    // Create the background image
-    Image background = Image::New(BACKGROUND_IMAGE_PATH);
-    ImageActor backgroundImage = ImageActor::New(background);
-    backgroundImage.SetParentOrigin(ParentOrigin::CENTER);
-    backgroundImage.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
-
-    Layer backgroundLayer = Layer::New();
-    backgroundLayer.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
-    backgroundLayer.SetParentOrigin( ParentOrigin::CENTER );
-    mGaussianBlurView.Add( backgroundLayer );
-    backgroundLayer.Add( backgroundImage );
-
-    Layer foregroundLayer = Layer::New();
-    foregroundLayer.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
-    foregroundLayer.SetParentOrigin( ParentOrigin::CENTER );
-    mGaussianBlurView.Add( foregroundLayer );
-
-    // Create visible actors
-    mObjectRootActor = Actor::New();
-    mObjectRootActor.SetParentOrigin( ParentOrigin::CENTER );
-    mObjectRootActor.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
-    foregroundLayer.Add( mObjectRootActor );
-
-    ImageActor imageActor = ImageActor::New( mDiffuseImage );
-    imageActor.SetParentOrigin( ParentOrigin::CENTER );
-    imageActor.SetSize( stageSize * 0.75f);
-    mObjectRootActor.Add( imageActor );
-
-    imageActor = ImageActor::New( mDiffuseImage );
-    imageActor.SetParentOrigin( ParentOrigin::CENTER );
-    imageActor.SetSize( stageSize * 0.5f );
-    imageActor.SetPosition(0.0f, 0.0f, 100.0f);
-    mObjectRootActor.Add( imageActor );
-
-    ToggleAnimation();
-
-    // Gesture detection
-    mTapGestureDetector = TapGestureDetector::New();
-    mTapGestureDetector.Attach( mStageRootActor );
-    mTapGestureDetector.DetectedSignal().Connect( this, &TestApp::OnTap );
-  }
-
-  PushButton CreateButton(const std::string& name, const std::string& label, const Vector3& sizeConstraint)
-  {
-    // Create the button
-    Image img = Image::New(BUTTON_BACKGROUND_IMAGE_PATH);
-    ImageActor background = ImageActor::New(img);
+      // Move background image to show GaussianBlurView activity
 
-    background.SetStyle(ImageActor::STYLE_NINE_PATCH);
-    background.SetNinePatchBorder(BUTTON_IMAGE_BORDER);
+      float pixelsPerSecond = 10.0f;
+      float duration        = excessWidth / pixelsPerSecond;
+      float qDuration       = duration * 0.25f;
 
-    PushButton button = PushButton::New();
-    button.SetName(name);
-    button.SetBackgroundImage(background);
+      mAnimation = Animation::New(duration);
+      mAnimation.AnimateTo(Property(mImageView, Actor::Property::POSITION_X), excessWidth, TimePeriod(0.0f, qDuration));
+      mAnimation.AnimateTo(Property(mImageView, Actor::Property::POSITION_X), 0.0f, TimePeriod(qDuration, qDuration));
+      mAnimation.AnimateTo(Property(mImageView, Actor::Property::POSITION_X), -excessWidth, TimePeriod(2.0f * qDuration, qDuration));
+      mAnimation.AnimateTo(Property(mImageView, Actor::Property::POSITION_X), 0.0f, TimePeriod(3.0f * qDuration, qDuration));
 
-    // Set the button's size
-    button.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), RelativeToConstraint( sizeConstraint ) ) );
-
-    mStageRootActor.Add(button);
-
-    button.ClickedSignal().Connect(this, &TestApp::OnButtonTouchEvent);
-
-    SetButtonLabel(button, label, TextView::Center);
+      mAnimation.SetLooping(true);
+      mAnimation.Play();
+    }
 
-    return button;
-  }
+    Layer onTop = Layer::New();
+    onTop.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
+    onTop.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
+    onTop.SetProperty(Actor::Property::SIZE, windowSize);
+    window.Add(onTop);
+    onTop.RaiseToTop();
 
-  void SetButtonLabel(PushButton button, const std::string& label, const TextView::LineJustification justification)
-  {
-    Font font = Font::New();
-    Vector3 textSize = font.MeasureText(label);
-
-    // Add a text label to the button
-    TextView textView = TextView::New( label );
-    textView.SetAnchorPoint( AnchorPoint::CENTER );
-    textView.SetParentOrigin( ParentOrigin::CENTER );
-    textView.SetMultilinePolicy(TextView::SplitByWord);
-    textView.SetWidthExceedPolicy(TextView::Original);
-    textView.SetTextAlignment(static_cast< Alignment::Type >( Alignment::HorizontalCenter | Alignment::VerticalCenter ));
-    textView.SetLineJustification(justification);
-    textView.SetSize(textSize);
-
-    Alignment align = Alignment::New();
-    align.Add(textView);
-    align.SetScaling( Alignment::ShrinkToFitKeepAspect );
-
-    button.SetLabelText(align);
-  }
+    mOnLabel = TextLabel::New("Blur ON");
+    mOnLabel.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+    mOnLabel.SetProperty(TextLabel::Property::TEXT_COLOR, Color::GREEN);
+    mOnLabel.SetProperty(Actor::Property::VISIBLE, false);
+    onTop.Add(mOnLabel);
 
-  /**
-   * Signal handler, called when the button is pressed
-   */
-  bool OnButtonTouchEvent(Button button)
-  {
-    if(button.GetName() == BUTTON_QUIT)
-    {
-      // quit the application
-      mApplication.Quit();
-    }
+    mOffLabel = TextLabel::New("Blur OFF");
+    mOffLabel.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+    mOffLabel.SetProperty(TextLabel::Property::TEXT_COLOR, Color::WHITE);
+    mOffLabel.SetProperty(Actor::Property::VISIBLE, true);
+    onTop.Add(mOffLabel);
 
-    return true;
-  }
+    mGaussianBlurView = GaussianBlurView::New(30, 8.0f, Pixel::RGBA8888, 0.5f, 0.5f, false);
+    mGaussianBlurView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
+    mGaussianBlurView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
+    mGaussianBlurView.SetProperty(Actor::Property::SIZE, windowSize);
+    window.Add(mGaussianBlurView);
 
-  void AnimateGaussianBlurView()
-  {
-    if(mRotationAnimation)
-    {
-      mRotationAnimation.Stop();
-    }
-    if(mResizeAnimation)
-    {
-      mResizeAnimation.Stop();
-    }
-    if(mTranslationAnimation)
-    {
-      mTranslationAnimation.Stop();
-    }
-    if(mBlurAnimation)
-    {
-      mBlurAnimation.Stop();
-    }
+    mGaussianBlurView.Add(mImageView);
+    mGaussianBlurView.SetProperty(mGaussianBlurView.GetBlurStrengthPropertyIndex(), mStrength);
 
-    // ROTATE
-    float animDuration = 10.0f;
-    mRotationAnimation = Animation::New(animDuration);
-    mRotationAnimation.RotateBy(mGaussianBlurView, Degree(720), Vector3::YAXIS, AlphaFunctions::EaseInOut);
-    mRotationAnimation.SetEndAction( Animation::Discard );
-    mRotationAnimation.SetLooping( true );
-    mRotationAnimation.Play();
-
-
-    // RESIZE
-    Stage stage = Stage::GetCurrent();
-    Vector3 stageSize(stage.GetSize().width, stage.GetSize().height, 1.0f);
-    mResizeAnimation = Animation::New( 7.5f );
-    mResizeAnimation.AnimateTo( Property(mGaussianBlurView, Actor::SIZE), stageSize * Vector3(0.5f, 0.5f, 1.0f), AlphaFunctions::Bounce, TimePeriod(2.5f) );
-    mResizeAnimation.SetEndAction( Animation::Discard );
-    mResizeAnimation.SetLooping( true );
-    mResizeAnimation.Play();
-
-
-    // TRANSLATE
-    mTranslationAnimation = Animation::New( 7.5f );
-    mTranslationAnimation.AnimateBy( Property(mObjectRootActor, Actor::POSITION), Vector3(100.0f, 0.0f, 0.0f), AlphaFunctions::Bounce, TimePeriod(2.5f) );
-    mTranslationAnimation.AnimateBy( Property(mObjectRootActor, Actor::POSITION), Vector3(300.0f, 0.0f, 0.0f), AlphaFunctions::Bounce, TimePeriod(2.5f, 2.5f) );
-    mTranslationAnimation.AnimateBy( Property(mObjectRootActor, Actor::POSITION), Vector3(0.0f, 0.0f, 0.0f), AlphaFunctions::Bounce, TimePeriod(5.0f, 2.5f) );
-    mTranslationAnimation.SetEndAction( Animation::Discard );
-    mTranslationAnimation.SetLooping( true );
-    mTranslationAnimation.Play();
-
-
-    // BLUR
-    mBlurAnimation = Animation::New( 4.0f );
-    mBlurAnimation.AnimateTo( Property( mGaussianBlurView, mGaussianBlurView.GetBlurStrengthPropertyIndex() ), 0.0f, AlphaFunctions::Linear, TimePeriod(0.0f, 0.5f) );
-    mBlurAnimation.AnimateTo( Property( mGaussianBlurView, mGaussianBlurView.GetBlurStrengthPropertyIndex() ), 1.0f, AlphaFunctions::Linear, TimePeriod(2.0f, 0.5f) );
-    mBlurAnimation.SetEndAction( Animation::Discard );
-    mBlurAnimation.SetLooping( true );
-    mBlurAnimation.Play();
+    window.GetRootLayer().TouchedSignal().Connect(this, &GaussianBlurViewExample::OnTouch);
   }
 
-  void AnimateActorRoot()
+  bool OnTouch(Actor actor, const TouchEvent& touch)
   {
-    if(mRotationAnimation)
-    {
-      mRotationAnimation.Stop();
-    }
-    if(mResizeAnimation)
-    {
-      mResizeAnimation.Stop();
-    }
-    if(mTranslationAnimation)
-    {
-      mTranslationAnimation.Stop();
-    }
-    if(mBlurAnimation)
-    {
-      mBlurAnimation.Stop();
-    }
-
-    // ROTATE
-    float animDuration = 10.0f;
-    mRotationAnimation = Animation::New(animDuration);
-    mRotationAnimation.RotateBy(mObjectRootActor, Degree(720), Vector3::YAXIS, AlphaFunctions::EaseInOut);
-    mRotationAnimation.SetEndAction( Animation::Discard );
-    mRotationAnimation.SetLooping( true );
-    mRotationAnimation.Play();
-
-
-    // RESIZE
-    Stage stage = Stage::GetCurrent();
-    Vector3 stageSize(stage.GetSize().width, stage.GetSize().height, 1.0f);
-    mResizeAnimation = Animation::New( 7.5f );
-    mResizeAnimation.AnimateTo( Property(mGaussianBlurView, Actor::SIZE), stageSize * Vector3(0.5f, 0.5f, 1.0f), AlphaFunctions::Bounce, TimePeriod(2.5f) );
-    mResizeAnimation.SetEndAction( Animation::Discard );
-    mResizeAnimation.SetLooping( true );
-    mResizeAnimation.Play();
-
-
-    // TRANSLATE
-    mTranslationAnimation = Animation::New( 7.5f );
-    mTranslationAnimation.AnimateBy( Property(mObjectRootActor, Actor::POSITION), Vector3(100.0f, 0.0f, 0.0f), AlphaFunctions::Bounce, TimePeriod(2.5f) );
-    mTranslationAnimation.AnimateBy( Property(mObjectRootActor, Actor::POSITION), Vector3(300.0f, 0.0f, 0.0f), AlphaFunctions::Bounce, TimePeriod(2.5f, 2.5f) );
-    mTranslationAnimation.AnimateBy( Property(mObjectRootActor, Actor::POSITION), Vector3(0.0f, 0.0f, 0.0f), AlphaFunctions::Bounce, TimePeriod(5.0f, 2.5f) );
-    mTranslationAnimation.SetEndAction( Animation::Discard );
-    mTranslationAnimation.SetLooping( true );
-    mTranslationAnimation.Play();
-
-
-    // BLUR
-    mBlurAnimation = Animation::New( 4.0f );
-    mBlurAnimation.AnimateTo( Property( mGaussianBlurView, mGaussianBlurView.GetBlurStrengthPropertyIndex() ), 0.0f, AlphaFunctions::Linear, TimePeriod(0.0f, 0.5f) );
-    mBlurAnimation.AnimateTo( Property( mGaussianBlurView, mGaussianBlurView.GetBlurStrengthPropertyIndex() ), 1.0f, AlphaFunctions::Linear, TimePeriod(2.0f, 0.5f) );
-    mBlurAnimation.SetEndAction( Animation::Discard );
-    mBlurAnimation.SetLooping( true );
-    mBlurAnimation.Play();
-  }
+    const PointState::Type state = touch.GetState(0);
 
-  void ToggleAnimation()
-  {
-    mCurrentAnimation++;
-    if(mCurrentAnimation == NUM_MOVEMENT_ANIMATIONS)
+    if(PointState::DOWN == state)
     {
-      mCurrentAnimation = 0;
-    }
+      if(!mActivate)
+      {
+        mActivate = true;
+        mGaussianBlurView.Activate();
 
-    switch(mCurrentAnimation)
-    {
-    case 0:
-      AnimateActorRoot();
-      break;
+        mOnLabel.SetProperty(Actor::Property::VISIBLE, true);
+        mOffLabel.SetProperty(Actor::Property::VISIBLE, false);
+      }
+      else
+      {
+        mActivate = false;
+        mGaussianBlurView.Deactivate();
 
-    case 1:
-      AnimateGaussianBlurView();
-      break;
+        mOnLabel.SetProperty(Actor::Property::VISIBLE, false);
+        mOffLabel.SetProperty(Actor::Property::VISIBLE, true);
+      }
     }
-  }
-#endif //#ifdef ADD_REMOVE_FROM_STAGE_TEST
 
-  void Terminate( Application& app )
-  {
+    return true;
   }
 
-  void OnTap( Actor actor, const TapGesture& tapGesture )
+  void OnKeyEvent(const KeyEvent& event)
   {
-    Stage stage = Stage::GetCurrent();
-
-#ifdef ADD_REMOVE_FROM_STAGE_TEST
-    if(mGaussianBlurView.OnStage())
-    {
-      mStageRootActor.Remove(mGaussianBlurView);
-      mGaussianBlurView.Deactivate();
-    }
-    else
+    if(event.GetState() == KeyEvent::DOWN)
     {
-      mStageRootActor.Add(mGaussianBlurView);
-      mGaussianBlurView.Activate();
+      if(IsKey(event, Dali::DALI_KEY_ESCAPE) || IsKey(event, Dali::DALI_KEY_BACK))
+      {
+        mApplication.Quit();
+      }
     }
-#else //#ifdef ADD_REMOVE_FROM_STAGE_TEST
-    ToggleAnimation();
-#endif //#ifdef ADD_REMOVE_FROM_STAGE_TEST
   }
 
 private:
-
   Application& mApplication;
 
-  TapGestureDetector mTapGestureDetector;
-
-  Actor mStageRootActor;
+  Toolkit::ImageView mImageView;
 
-  Actor mObjectRootActor;
-  Image mDiffuseImage;
+  Animation mAnimation;
 
-  unsigned int mCurrentAnimation;
-  Animation mRotationAnimation;
-  Animation mResizeAnimation;
-  Animation mTranslationAnimation;
-  Animation mBlurAnimation;
-  Animation mPulseBloomIntensityAnim;
+  TextLabel mOnLabel;
+  TextLabel mOffLabel;
 
-  // for rendering the blur / bloom
   GaussianBlurView mGaussianBlurView;
-  BloomView mBloomView;
-};
 
-/*****************************************************************************/
+  float mExcessWidth;
+  float mStrength;
 
-static void
-RunTest( Application& application )
-{
-  TestApp theApp(application);
-  application.MainLoop();
-}
-
-/*****************************************************************************/
+  bool mActivate;
+};
 
-int
-main(int argc, char **argv)
+int DALI_EXPORT_API main(int argc, char** argv)
 {
   Application application = Application::New(&argc, &argv);
 
-  RunTest(application);
+  GaussianBlurViewExample test(application);
+
+  application.MainLoop();
 
   return 0;
 }