afdda84542092260702a61fe77fa93b9b6aed90b
[platform/core/uifw/dali-toolkit.git] / optional / dali-toolkit / public-api / controls / image-view / image-view.cpp
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #include <dali-toolkit/public-api/controls/image-view/image-view.h>
19 #include <dali-toolkit/internal/controls/image-view/image-view-impl.h>
20 #include <dali-toolkit/public-api/controls/buttons/button.h>
21
22 using namespace Dali;
23
24 namespace
25 {
26 const float DEFAULT_MINIMUM_DETAIL = 0.125f;      ///< Default Minimum Detail level 12.5% of original size.
27 const float DEFAULT_MAXIMUM_DETAIL = 1.0f;        ///< Default Maximum Detail level 100% (original size)
28 const float CAMERA_100_PCT_DISTANCE(1695.0f);     ///< Based on Camera/Viewport/Projection settings at this distance object is 100% size.
29 } // unnamed namespace
30
31 namespace Dali
32 {
33
34 namespace Toolkit
35 {
36
37 ///////////////////////////////////////////////////////////////////////////////////////////////////
38 // ImageView
39 ///////////////////////////////////////////////////////////////////////////////////////////////////
40
41 const std::string ImageView::DETAIL_PROPERTY_NAME( "image-view-detail" );
42
43 ImageView::ImageView()
44 {
45 }
46
47 ImageView::ImageView( const ImageView& handle )
48 : Control( handle )
49 {
50 }
51
52 ImageView& ImageView::operator=( const ImageView& handle )
53 {
54   if( &handle != this )
55   {
56     Control::operator=( handle );
57   }
58   return *this;
59 }
60
61 ImageView::ImageView(Internal::ImageView& implementation)
62 : Control(implementation)
63 {
64 }
65
66 ImageView::ImageView( Dali::Internal::CustomActor* internal )
67 : Control( internal )
68 {
69   VerifyCustomActorPointer<Internal::ImageView>(internal);
70 }
71
72 ImageView ImageView::New()
73 {
74   return Internal::ImageView::New();
75 }
76
77 ImageView ImageView::DownCast( BaseHandle handle )
78 {
79   return Control::DownCast<ImageView, Internal::ImageView>( handle );
80 }
81
82 ImageView::~ImageView()
83 {
84 }
85
86 void ImageView::SetImage(const std::string& filename, ImageType type)
87 {
88   GetImpl(*this).SetImage( filename, type, DEFAULT_MINIMUM_DETAIL, DEFAULT_MAXIMUM_DETAIL );
89 }
90
91 void ImageView::SetImage(const std::string& filename, ImageType type, float min, float max)
92 {
93   GetImpl(*this).SetImage( filename, type, min, max );
94 }
95
96 void ImageView::SetImage(Image image)
97 {
98   GetImpl(*this).SetImage( image );
99 }
100
101 void ImageView::SetCameraActor(CameraActor camera)
102 {
103   // TODO: Default detail factor should be calculated based on
104   // current Camera's field of view/viewport/projection.
105   // Ideal place would be inside the constraint, and have the Camera
106   // settings as properties.
107   GetImpl(*this).SetCameraActor( camera, CAMERA_100_PCT_DISTANCE );
108 }
109
110 void ImageView::SetCameraActor(CameraActor camera, float detailFactor)
111 {
112   GetImpl(*this).SetCameraActor( camera, detailFactor );
113 }
114
115 void ImageView::SetDetail(float detail)
116 {
117   GetImpl(*this).SetDetail( detail );
118 }
119
120 } // namespace Toolkit
121
122 } // namespace Dali