Include <cstdio> to compensate for core inclusion cleanup
[platform/core/uifw/dali-demo.git] / examples / image / image-scaling-irregular-grid / image-scaling-irregular-grid-example.cpp
index 7cf2cb3..cdc3e6b 100644 (file)
@@ -45,6 +45,7 @@
 #include <algorithm>
 #include <map>
 #include <dali-toolkit/dali-toolkit.h>
+#include <iostream>
 
 // INTERNAL INCLUDES
 #include "grid-flags.h"
@@ -58,9 +59,9 @@ namespace
 {
 
 /** Controls the output of application logging. */
-const bool DEBUG_PRINT_DIAGNOSTICS = false;
+//#define DEBUG_PRINT_DIAGNOSTICS;
 
-const char* BACKGROUND_IMAGE( DALI_IMAGE_DIR "background-4.jpg" );
+const char* BACKGROUND_IMAGE( DALI_IMAGE_DIR "background-gradient.jpg" );
 const char* TOOLBAR_IMAGE( DALI_IMAGE_DIR "top-bar.png" );
 const char* APPLICATION_TITLE( "Image Scaling Modes" );
 const char* TOGGLE_SCALING_IMAGE( DALI_IMAGE_DIR "icon-change.png" );
@@ -175,15 +176,14 @@ const unsigned NUM_IMAGE_PATHS = sizeof(IMAGE_PATHS) / sizeof(IMAGE_PATHS[0]) -
  */
 Image CreateImage(const std::string& filename, unsigned int width, unsigned int height, ImageAttributes::ScalingMode scalingMode )
 {
-  if( DEBUG_PRINT_DIAGNOSTICS )
-  {
+#ifdef DEBUG_PRINT_DIAGNOSTICS
     fprintf( stderr, "CreateImage(%s, %u, %u, scalingMode=%u)\n", filename.c_str(), width, height, unsigned( scalingMode ) );
-  }
+#endif
   ImageAttributes attributes;
 
   attributes.SetSize( width, height );
   attributes.SetScalingMode( scalingMode );
-  Image image = Image::New( filename, attributes );
+  Image image = ResourceImage::New( filename, attributes );
   return image;
 }
 
@@ -308,7 +308,7 @@ public:
                                             "" );
 
     // Create an image scaling toggle button. (right of toolbar)
-    Image toggleScalingImage = Image::New( TOGGLE_SCALING_IMAGE );
+    Image toggleScalingImage = ResourceImage::New( TOGGLE_SCALING_IMAGE );
     Toolkit::PushButton toggleScalingButton = Toolkit::PushButton::New();
     toggleScalingButton.SetBackgroundImage( toggleScalingImage );
     toggleScalingButton.ClickedSignal().Connect( this, &ImageScalingIrregularGridController::OnToggleScalingTouched );
@@ -402,10 +402,9 @@ public:
       bool allocated = grid.AllocateRegion( config->dimensions, cellX, cellY, imageGridDims );
       if( !allocated )
       {
-        if( DEBUG_PRINT_DIAGNOSTICS )
-        {
+#ifdef DEBUG_PRINT_DIAGNOSTICS
           fprintf( stderr, "Failed to allocate image in grid with dims (%f, %f) and path: %s.\n", config->dimensions.x, config->dimensions.y, config->path );
-        }
+#endif
         continue;
       }
 
@@ -418,7 +417,7 @@ public:
     // coordinates in a frame defined by a parent actor:
 
     Actor gridActor = Actor::New();
-    gridActor.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
+    gridActor.SetSizeMode( SIZE_EQUAL_TO_PARENT );
     gridActor.SetParentOrigin( ParentOrigin::CENTER );
     gridActor.SetAnchorPoint( AnchorPoint::CENTER );
 
@@ -474,7 +473,7 @@ public:
 
         ImageActor imageActor = ImageActor::DownCast( actor );
         Image oldImage = imageActor.GetImage();
-        Image newImage = CreateImage( oldImage.GetFilename(), imageSize.width + 0.5f, imageSize.height + 0.5f, newMode );
+        Image newImage = CreateImage( ResourceImage::DownCast(oldImage).GetUrl(), imageSize.width + 0.5f, imageSize.height + 0.5f, newMode );
         imageActor.SetImage( newImage );
         mScalingModes[id] = newMode;
       }
@@ -516,7 +515,7 @@ public:
         const Vector2 imageSize = mSizes[gridImageActor.GetId()];
         ImageAttributes::ScalingMode newMode = NextMode( mScalingModes[gridImageActor.GetId()] );
         Image oldImage = gridImageActor.GetImage();
-        Image newImage = CreateImage( oldImage.GetFilename(), imageSize.width, imageSize.height, newMode );
+        Image newImage = CreateImage(ResourceImage::DownCast(oldImage).GetUrl(), imageSize.width, imageSize.height, newMode );
         gridImageActor.SetImage( newImage );
 
         mScalingModes[gridImageActor.GetId()] = newMode;