(ImageView) Restore erroneously removed APIs & Fix SetImage behaviour
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / public-api / controls / image-view / image-view.cpp
index ac42aeb..6408c19 100644 (file)
@@ -1,31 +1,29 @@
-//
-// 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.
-//
-
+/*
+ * Copyright (c) 2015 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.
+ *
+ */
+
+// CLASS HEADER
 #include <dali-toolkit/public-api/controls/image-view/image-view.h>
-#include <dali-toolkit/internal/controls/image-view/image-view-impl.h>
-#include <dali-toolkit/public-api/controls/buttons/button.h>
 
-using namespace Dali;
+// EXTERNAL INCLUDES
+#include <dali/public-api/images/resource-image.h>
+#include <dali/public-api/object/property-map.h>
 
-namespace
-{
-const float DEFAULT_MINIMUM_DETAIL = 0.125f;      ///< Default Minimum Detail level 12.5% of original size.
-const float DEFAULT_MAXIMUM_DETAIL = 1.0f;        ///< Default Maximum Detail level 100% (original size)
-const float CAMERA_100_PCT_DISTANCE(1695.0f);     ///< Based on Camera/Viewport/Projection settings at this distance object is 100% size.
-} // unnamed namespace
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/controls/image-view/image-view-impl.h>
 
 namespace Dali
 {
@@ -33,87 +31,88 @@ namespace Dali
 namespace Toolkit
 {
 
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// ImageView
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-const std::string ImageView::DETAIL_PROPERTY_NAME( "image-view-detail" );
-
 ImageView::ImageView()
 {
 }
 
-ImageView::ImageView( const ImageView& handle )
-: Control( handle )
+ImageView::ImageView( const ImageView& imageView )
+: Control( imageView )
 {
 }
 
-ImageView& ImageView::operator=( const ImageView& handle )
+ImageView& ImageView::operator=( const ImageView& imageView )
 {
-  if( &handle != this )
+  if( &imageView != this )
   {
-    Control::operator=( handle );
+    Control::operator=( imageView );
   }
   return *this;
 }
 
-ImageView::ImageView(Internal::ImageView& implementation)
-: Control(implementation)
+ImageView::~ImageView()
 {
 }
 
-ImageView::ImageView( Dali::Internal::CustomActor* internal )
-: Control( internal )
+ImageView ImageView::New()
 {
-  VerifyCustomActorPointer<Internal::ImageView>(internal);
+  return Internal::ImageView::New();
 }
 
-ImageView ImageView::New()
+ImageView ImageView::New( Image image )
 {
-  return Internal::ImageView::New();
+  ImageView imageView = Internal::ImageView::New();
+  imageView.SetImage( image );
+  return ImageView( imageView );
 }
 
-ImageView ImageView::DownCast( BaseHandle handle )
+ImageView ImageView::New( const std::string& url )
 {
-  return Control::DownCast<ImageView, Internal::ImageView>( handle );
+  ImageView imageView = Internal::ImageView::New();
+  imageView.SetImage( url, ImageDimensions() );
+  return imageView;
 }
 
-ImageView::~ImageView()
+ImageView ImageView::New( const std::string& url, ImageDimensions size )
+{
+  ImageView imageView = Internal::ImageView::New();
+  imageView.SetImage( url, size );
+  return imageView;
+}
+
+ImageView ImageView::DownCast( BaseHandle handle )
 {
+  return Control::DownCast<ImageView, Internal::ImageView>( handle );
 }
 
-void ImageView::SetImage(const std::string& filename, ImageType type)
+void ImageView::SetImage( Image image )
 {
-  GetImpl(*this).SetImage( filename, type, DEFAULT_MINIMUM_DETAIL, DEFAULT_MAXIMUM_DETAIL );
+  Dali::Toolkit::GetImpl( *this ).SetImage( image );
 }
 
-void ImageView::SetImage(const std::string& filename, ImageType type, float min, float max)
+void ImageView::SetImage( const std::string& url )
 {
-  GetImpl(*this).SetImage( filename, type, min, max );
+  Dali::Toolkit::GetImpl( *this ).SetImage( url, ImageDimensions() );
 }
 
-void ImageView::SetImage(Image image)
+void ImageView::SetImage( const std::string& url, ImageDimensions size )
 {
-  GetImpl(*this).SetImage( image );
+  Dali::Toolkit::GetImpl( *this ).SetImage( url, size );
 }
 
-void ImageView::SetCameraActor(CameraActor camera)
+Image ImageView::GetImage() const
 {
-  // TODO: Default detail factor should be calculated based on
-  // current Camera's field of view/viewport/projection.
-  // Ideal place would be inside the constraint, and have the Camera
-  // settings as properties.
-  GetImpl(*this).SetCameraActor( camera, CAMERA_100_PCT_DISTANCE );
+  return Image();
 }
 
-void ImageView::SetCameraActor(CameraActor camera, float detailFactor)
+ImageView::ImageView( Internal::ImageView& implementation )
+ : Control( implementation )
 {
-  GetImpl(*this).SetCameraActor( camera, detailFactor );
 }
 
-void ImageView::SetDetail(float detail)
+ImageView::ImageView( Dali::Internal::CustomActor* internal )
+ : Control( internal )
 {
-  GetImpl(*this).SetDetail( detail );
+  VerifyCustomActorPointer<Internal::ImageView>( internal );
 }
 
 } // namespace Toolkit