Merge remote-tracking branch 'origin/tizen' into devel/new_mesh
[platform/core/uifw/dali-demo.git] / examples / motion-stretch / motion-stretch-example.cpp
index b9c4a75..0084cdd 100644 (file)
@@ -21,6 +21,7 @@
 #include "shared/view.h"
 #include <dali/dali.h>
 #include <dali-toolkit/dali-toolkit.h>
+#include <dali-toolkit/devel-api/shader-effects/motion-stretch-effect.h>
 
 using namespace Dali;
 using namespace Dali::Toolkit;
@@ -124,8 +125,6 @@ public:
   {
     // The Init signal is received once (only) during the Application lifetime
 
-    DemoHelper::RequestThemeChange();
-
     Stage::GetCurrent().KeyEventSignal().Connect(this, &MotionStretchExampleApp::OnKeyEvent);
 
     // Creates a default view with a default tool bar.
@@ -166,8 +165,8 @@ public:
     winHandle.AddAvailableOrientation( Dali::Window::PORTRAIT_INVERSE  );
     winHandle.AddAvailableOrientation( Dali::Window::LANDSCAPE_INVERSE );
 
-    winHandle.GetOrientation().ChangedSignal().Connect( this, &MotionStretchExampleApp::OnOrientationChanged );
-    unsigned int degrees = winHandle.GetOrientation().GetDegrees();
+   // winHandle.GetOrientation().ChangedSignal().Connect( this, &MotionStretchExampleApp::OnOrientationChanged );
+    unsigned int degrees = 0;
     Rotate( static_cast< DeviceOrientation >( degrees ) );
 
 
@@ -185,7 +184,12 @@ public:
     mContentLayer.Add( mMotionStretchImageActor );
 
     // Create shader used for doing motion stretch
-    mMotionStretchEffect = MotionStretchEffect::Apply(mMotionStretchImageActor);
+    mMotionStretchEffect = Toolkit::CreateMotionStretchEffect();
+    Dali::Property::Index uModelProperty = mMotionStretchEffect.GetPropertyIndex( "uModelLastFrame" );
+    Constraint constraint = Constraint::New<Matrix>( mMotionStretchEffect, uModelProperty, EqualToConstraint() );
+    constraint.AddSource( Source( mMotionStretchImageActor , Actor::Property::WORLD_MATRIX ) );
+    constraint.Apply();
+    mMotionStretchImageActor.SetShaderEffect( mMotionStretchEffect );
   }
 
   //////////////////////////////////////////////////////////////
@@ -409,7 +413,7 @@ private:
   PushButton                 mActorEffectsButton;     ///< The actor effects toggling Button.
 
   // Motion stretch
-  MotionStretchEffect mMotionStretchEffect;
+  ShaderEffect mMotionStretchEffect;
   ImageActor mMotionStretchImageActor;
 
   // animate actor to position where user taps screen
@@ -441,7 +445,7 @@ void RunTest(Application& app)
 //
 int main(int argc, char **argv)
 {
-  Application app = Application::New(&argc, &argv);
+  Application app = Application::New(&argc, &argv, DALI_DEMO_THEME_PATH);
 
   RunTest(app);