[dali_1.0.42] Merge branch 'tizen'
[platform/core/uifw/dali-demo.git] / examples / refraction-effect / refraction-effect-example.cpp
index 7a3a290..a220490 100644 (file)
 
 #include <dali/dali.h>
 #include <dali-toolkit/dali-toolkit.h>
+#include <dali/devel-api/actors/mesh-actor.h>
+#include <dali/devel-api/modeling/material.h>
+#include <dali/devel-api/geometry/mesh.h>
+
 #include "shared/view.h"
 
 #include <fstream>
 #include <sstream>
+#include <limits>
 
 using namespace Dali;
 
@@ -56,10 +61,13 @@ struct LightOffsetConstraint
   {
   }
 
-  Vector2 operator()( const Vector2& current, const PropertyInput& spinAngleProperty)
+  void operator()( Vector2& current, const PropertyInputContainer& inputs )
   {
-    float spinAngle = spinAngleProperty.GetFloat();
-    return Vector2( cos(spinAngle ), sin( spinAngle ) ) * mRadius;
+    float spinAngle = inputs[0]->GetFloat();
+    current.x = cos( spinAngle );
+    current.y = sin( spinAngle );
+
+    current *= mRadius;
   }
 
   float mRadius;
@@ -68,19 +76,14 @@ struct LightOffsetConstraint
 /**
  * @brief Load an image, scaled-down to no more than the stage dimensions.
  *
- * Uses image scaling mode ImageAttributes::ScaleToFill to resize the image at
+ * Uses image scaling mode SCALE_TO_FILL to resize the image at
  * load time to cover the entire stage with pixels with no borders,
- * and filter mode ImageAttributes::BoxThenLinear to sample the image with
- * maximum quality.
+ * and filter mode BOX_THEN_LINEAR to sample the image with maximum quality.
  */
 ResourceImage LoadStageFillingImage( const char * const imagePath )
 {
   Size stageSize = Stage::GetCurrent().GetSize();
-  ImageAttributes attributes;
-  attributes.SetSize( stageSize.x, stageSize.y );
-  attributes.SetFilterMode( ImageAttributes::BoxThenLinear );
-  attributes.SetScalingMode( ImageAttributes::ScaleToFill );
-  return ResourceImage::New( imagePath, attributes );
+  return ResourceImage::New( imagePath, ImageDimensions( stageSize.x, stageSize.y ), Dali::FittingMode::SCALE_TO_FILL, Dali::SamplingMode::BOX_THEN_LINEAR );
 }
 
 } // namespace
@@ -254,10 +257,9 @@ public:
     handle.SetUniform( "uLightIntensity",  2.5f );
 
     Dali::Property::Index index = handle.RegisterProperty( "uSpinAngle", 0.f );
-    Constraint constraint = Constraint::New<Vector2>( handle.GetPropertyIndex("uLightSpinOffset"),
-                                                      LocalSource(index),
-                                                      LightOffsetConstraint(stageSize.x*0.1f));
-    handle.ApplyConstraint( constraint );
+    Constraint constraint = Constraint::New<Vector2>( handle, handle.GetPropertyIndex("uLightSpinOffset"), LightOffsetConstraint(stageSize.x*0.1f) );
+    constraint.AddSource( LocalSource(index) );
+    constraint.Apply();
 
     return handle;
   }
@@ -326,7 +328,7 @@ private:
     // Creates a default view with a default tool bar.
     // The view is added to the stage.
     Toolkit::ToolBar toolBar;
-    Toolkit::View    view;
+    Toolkit::Control    view;
     mContent = DemoHelper::CreateView( application,
         view,
         toolBar,
@@ -654,7 +656,7 @@ 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);