Split dali-toolkit into Base & Optional
[platform/core/uifw/dali-toolkit.git] / optional / dali-toolkit / public-api / controls / image-view / image-view.h
1 #ifndef __DALI_TOOLKIT_IMAGE_VIEW_H__
2 #define __DALI_TOOLKIT_IMAGE_VIEW_H__
3
4 //
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
6 //
7 // Licensed under the Flora License, Version 1.0 (the License);
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
10 //
11 //     http://floralicense.org/license/
12 //
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an AS IS BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
18 //
19
20 // INTERNAL INCLUDES
21 #include <dali-toolkit/public-api/controls/control.h>
22
23 namespace Dali DALI_IMPORT_API
24 {
25
26 namespace Toolkit
27 {
28
29 namespace Internal DALI_INTERNAL
30 {
31 class ImageView;
32 }
33
34 class Button;
35
36 /**
37  * ImageView control loads and displays the correct
38  * image for the current level of detail (LOD) required.
39  * LOD is typically calculated from the Camera distance.
40  *
41  * Example:
42  *
43  * ImageView imageView = ImageView::New();
44  * imageView.SetCameraActor( mCamera );
45  * imageView.SetSize( Vector2(64.0f, 64.0f) );
46  * imageView.SetImage( "my-image.png", ImageView::BitmapType, 0.125f, 4.0f );
47  * layer.Add(imageView);
48  *
49  * The above creates an ImageView at 64x64 in size. Images of 12.5% the size up
50  * to 400% the size of imageView are created
51  * i.e. 8x8, 16x16, 32x32, 64x64, 128x128, and 256x256
52  *
53  * based on the distance imageView is from mCamera an appropriate, different
54  * image will be loaded and dispayed.
55  */
56 class ImageView : public Control
57 {
58 public:
59
60   /**
61    * Image Types, determines how image should be rendered.
62    */
63   enum ImageType
64   {
65     BitmapType,                            ///< Standard Bitmap image
66     DistanceFieldType                      ///< Distance Field encoded image
67   };
68
69   static const std::string DETAIL_PROPERTY_NAME;                          ///< The level of detail property
70
71 public:
72
73   /**
74    * Creates an empty ImageView handle
75    */
76   ImageView();
77
78   /**
79    * Copy constructor. Creates another handle that points to the same real object
80    * @param handle to copy from
81    */
82   ImageView( const ImageView& handle );
83
84   /**
85    * Assignment operator. Changes this handle to point to another real object
86    */
87   ImageView& operator=( const ImageView& handle );
88
89   /**
90    * Virtual destructor.
91    * Dali::Object derived classes typically do not contain member data.
92    */
93   virtual ~ImageView();
94
95   /**
96    * Create the Poup control
97    * @return A handle to the ImageView control.
98    */
99   static ImageView New();
100
101   /**
102    * Downcast an Object handle to ImageView. If handle points to an ImageView the
103    * downcast produces valid handle. If not the returned handle is left uninitialized.
104    * @param[in] handle Handle to an object
105    * @return handle to a ImageView or an uninitialized handle
106    */
107   static ImageView DownCast( BaseHandle handle );
108
109 public:
110
111   /**
112    * Load image into ImageView for level of detail scaling.
113    * Will automatically create different sized versions
114    * of the source image.
115    *
116    * @param[in] filename The image path to load
117    * @param[in] type The type of image e.g. BitmapType or DistanceFieldType
118    */
119   void SetImage(const std::string& filename, ImageType type);
120
121   /**
122    * Load image into ImageView for level of detail scaling.
123    * The minimum scale is a percentage of the size of the
124    * image view, and represents the smallest version of the
125    * source image to display e.g. 0.125 for 12.5%
126    * While the maximum scale represents the largest version of
127    * the source image to display e.g. 1.00 for 100% (original
128    * image view size)
129    *
130    * @note ImageView SetSize must be set specified prior to
131    * calling this.
132    *
133    * @param[in] filename The image path to load
134    * @param[in] type The type of image e.g. BitmapImage or DistanceFieldImage
135    * @param[in] min The minimum scale detail to load.
136    * @param[in] max The maximum scale detail to load.
137    */
138   void SetImage(const std::string& filename, ImageType type, float min, float max);
139
140   /**
141    * Sets an image to displayed for the entire detail range.
142    * Regardless of the detail level this image will be displayed.
143    *
144    * @param[in] image The image to display
145    */
146   void SetImage(Image image);
147
148   /**
149    * Sets the camera to use for determining level of detail.
150    * Which is based on distance from camera to this ImageView.
151    * The detailFactor is the distance at which the ImageView
152    * should appear at 100% scale. Which may differ based on
153    * Projection, and ShaderEffect settings.
154    * @param[in] camera The camera
155    */
156   void SetCameraActor(CameraActor camera);
157
158   /**
159    * Sets the camera to use for determining level of detail.
160    * Which is based on distance from camera to this ImageView.
161    * The detailFactor is the distance at which the ImageView
162    * should appear at 100% scale. Which may differ based on
163    * Projection, and ShaderEffect settings.
164    * @param[in] camera The camera
165    * @param[in] detailFactor The Camera distance where detail should be 1.0
166    * (ImageView should appear at 100% scale)
167    */
168   void SetCameraActor(CameraActor camera, float detailFactor);
169
170   /**
171    * Sets the current detail level.
172    * @note This sets the detail property value.
173    * @param[in] detail The level of detail to be viewed at.
174    */
175   void SetDetail(float detail);
176
177 public: // Not intended for application developers
178
179   /**
180    * Creates a handle using the Toolkit::Internal implementation.
181    * @param[in]  implementation  The Control implementation.
182    */
183   ImageView(Internal::ImageView& implementation);
184
185   /**
186    * Allows the creation of this Control from an Internal::CustomActor pointer.
187    * @param[in]  internal  A pointer to the internal CustomActor.
188    */
189   ImageView(Dali::Internal::CustomActor* internal);
190 };
191
192 } // namespace Toolkit
193
194 } // namespace Dali
195
196 #endif // __DALI_TOOLKIT_IMAGE_VIEW_H__