PixelArea support for ImageView
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / image-view / image-view-impl.cpp
index 714701a..aaab3b6 100644 (file)
@@ -33,7 +33,10 @@ BaseHandle Create()
 
 // Setup properties, signals and actions using the type-registry.
 DALI_TYPE_REGISTRATION_BEGIN( Toolkit::ImageView, Toolkit::Control, Create );
+DALI_PROPERTY_REGISTRATION( Toolkit, ImageView, "resourceUrl", STRING, RESOURCE_URL )
 DALI_PROPERTY_REGISTRATION( Toolkit, ImageView, "image", MAP, IMAGE )
+
+DALI_ANIMATABLE_PROPERTY_REGISTRATION_WITH_DEFAULT( Toolkit, ImageView, "pixelArea", Vector4(0.f, 0.f, 1.f, 1.f), PIXEL_AREA )
 DALI_TYPE_REGISTRATION_END()
 
 } // anonymous namespace
@@ -144,7 +147,10 @@ void ImageView::SetImage( const std::string& url, ImageDimensions size )
 
 void ImageView::SetDepthIndex( int depthIndex )
 {
-  mRenderer.SetDepthIndex( depthIndex );
+  if( mRenderer )
+  {
+    mRenderer.SetDepthIndex( depthIndex );
+  }
 }
 
 Vector3 ImageView::GetNaturalSize()
@@ -153,10 +159,10 @@ Vector3 ImageView::GetNaturalSize()
 
   size.x = mImageSize.GetWidth();
   size.y = mImageSize.GetHeight();
-  size.z = std::min(size.x, size.y);
 
   if( size.x > 0 && size.y > 0 )
   {
+    size.z = std::min(size.x, size.y);
     return size;
   }
   else
@@ -190,6 +196,7 @@ float ImageView::GetWidthForHeight( float height )
   }
 }
 
+
 ///////////////////////////////////////////////////////////
 //
 // Private methods
@@ -217,7 +224,6 @@ void ImageView::OnStageDisconnection()
   Control::OnStageDisconnection();
 }
 
-
 ///////////////////////////////////////////////////////////
 //
 // Properties
@@ -231,6 +237,16 @@ void ImageView::SetProperty( BaseObject* object, Property::Index index, const Pr
   {
     switch ( index )
     {
+      case Toolkit::ImageView::Property::RESOURCE_URL:
+      {
+        std::string imageUrl;
+        if( value.Get( imageUrl ) )
+        {
+          GetImpl( imageView ).SetImage( imageUrl, ImageDimensions() );
+        }
+        break;
+      }
+
       case Toolkit::ImageView::Property::IMAGE:
       {
         std::string imageUrl;
@@ -262,11 +278,20 @@ Property::Value ImageView::GetProperty( BaseObject* object, Property::Index prop
 
   if ( imageview )
   {
+    ImageView& impl = GetImpl( imageview );
     switch ( propertyIndex )
     {
+      case Toolkit::ImageView::Property::RESOURCE_URL:
+      {
+        if ( !impl.mUrl.empty() )
+        {
+          value = impl.mUrl;
+        }
+        break;
+      }
+
       case Toolkit::ImageView::Property::IMAGE:
       {
-        ImageView& impl = GetImpl( imageview );
         if ( !impl.mUrl.empty() )
         {
           value = impl.mUrl;