Split dali-toolkit into Base & Optional
[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 Flora License, Version 1.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://floralicense.org/license/
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 #include <dali-toolkit/public-api/controls/image-view/image-view.h>
18 #include <dali-toolkit/internal/controls/image-view/image-view-impl.h>
19 #include <dali-toolkit/public-api/controls/buttons/button.h>
20
21 using namespace Dali;
22
23 namespace
24 {
25 const float DEFAULT_MINIMUM_DETAIL = 0.125f;      ///< Default Minimum Detail level 12.5% of original size.
26 const float DEFAULT_MAXIMUM_DETAIL = 1.0f;        ///< Default Maximum Detail level 100% (original size)
27 const float CAMERA_100_PCT_DISTANCE(1695.0f);     ///< Based on Camera/Viewport/Projection settings at this distance object is 100% size.
28 } // unnamed namespace
29
30 namespace Dali
31 {
32
33 namespace Toolkit
34 {
35
36 ///////////////////////////////////////////////////////////////////////////////////////////////////
37 // ImageView
38 ///////////////////////////////////////////////////////////////////////////////////////////////////
39
40 const std::string ImageView::DETAIL_PROPERTY_NAME( "image-view-detail" );
41
42 ImageView::ImageView()
43 {
44 }
45
46 ImageView::ImageView( const ImageView& handle )
47 : Control( handle )
48 {
49 }
50
51 ImageView& ImageView::operator=( const ImageView& handle )
52 {
53   if( &handle != this )
54   {
55     Control::operator=( handle );
56   }
57   return *this;
58 }
59
60 ImageView::ImageView(Internal::ImageView& implementation)
61 : Control(implementation)
62 {
63 }
64
65 ImageView::ImageView( Dali::Internal::CustomActor* internal )
66 : Control( internal )
67 {
68   VerifyCustomActorPointer<Internal::ImageView>(internal);
69 }
70
71 ImageView ImageView::New()
72 {
73   return Internal::ImageView::New();
74 }
75
76 ImageView ImageView::DownCast( BaseHandle handle )
77 {
78   return Control::DownCast<ImageView, Internal::ImageView>( handle );
79 }
80
81 ImageView::~ImageView()
82 {
83 }
84
85 void ImageView::SetImage(const std::string& filename, ImageType type)
86 {
87   GetImpl(*this).SetImage( filename, type, DEFAULT_MINIMUM_DETAIL, DEFAULT_MAXIMUM_DETAIL );
88 }
89
90 void ImageView::SetImage(const std::string& filename, ImageType type, float min, float max)
91 {
92   GetImpl(*this).SetImage( filename, type, min, max );
93 }
94
95 void ImageView::SetImage(Image image)
96 {
97   GetImpl(*this).SetImage( image );
98 }
99
100 void ImageView::SetCameraActor(CameraActor camera)
101 {
102   // TODO: Default detail factor should be calculated based on
103   // current Camera's field of view/viewport/projection.
104   // Ideal place would be inside the constraint, and have the Camera
105   // settings as properties.
106   GetImpl(*this).SetCameraActor( camera, CAMERA_100_PCT_DISTANCE );
107 }
108
109 void ImageView::SetCameraActor(CameraActor camera, float detailFactor)
110 {
111   GetImpl(*this).SetCameraActor( camera, detailFactor );
112 }
113
114 void ImageView::SetDetail(float detail)
115 {
116   GetImpl(*this).SetDetail( detail );
117 }
118
119 } // namespace Toolkit
120
121 } // namespace Dali