Include required header files directly rather than through dali.h
[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 Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
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
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/actors/camera-actor.h>
23
24 // INTERNAL INCLUDES
25 #include <dali-toolkit/public-api/controls/control.h>
26
27 namespace Dali DALI_IMPORT_API
28 {
29
30 namespace Toolkit
31 {
32
33 namespace Internal DALI_INTERNAL
34 {
35 class ImageView;
36 }
37
38 class Button;
39
40 /**
41  * ImageView control loads and displays the correct
42  * image for the current level of detail (LOD) required.
43  * LOD is typically calculated from the Camera distance.
44  *
45  * Example:
46  *
47  * ImageView imageView = ImageView::New();
48  * imageView.SetCameraActor( mCamera );
49  * imageView.SetSize( Vector2(64.0f, 64.0f) );
50  * imageView.SetImage( "my-image.png", ImageView::BitmapType, 0.125f, 4.0f );
51  * layer.Add(imageView);
52  *
53  * The above creates an ImageView at 64x64 in size. Images of 12.5% the size up
54  * to 400% the size of imageView are created
55  * i.e. 8x8, 16x16, 32x32, 64x64, 128x128, and 256x256
56  *
57  * based on the distance imageView is from mCamera an appropriate, different
58  * image will be loaded and dispayed.
59  */
60 class ImageView : public Control
61 {
62 public:
63
64   /**
65    * Image Types, determines how image should be rendered.
66    */
67   enum ImageType
68   {
69     BitmapType,                            ///< Standard Bitmap image
70     DistanceFieldType                      ///< Distance Field encoded image
71   };
72
73   static const std::string DETAIL_PROPERTY_NAME;                          ///< The level of detail property
74
75 public:
76
77   /**
78    * Creates an empty ImageView handle
79    */
80   ImageView();
81
82   /**
83    * Copy constructor. Creates another handle that points to the same real object
84    * @param handle to copy from
85    */
86   ImageView( const ImageView& handle );
87
88   /**
89    * Assignment operator. Changes this handle to point to another real object
90    */
91   ImageView& operator=( const ImageView& handle );
92
93   /**
94    * @brief Destructor
95    *
96    * This is non-virtual since derived Handle types must not contain data or virtual methods.
97    */
98   ~ImageView();
99
100   /**
101    * Create the Poup control
102    * @return A handle to the ImageView control.
103    */
104   static ImageView New();
105
106   /**
107    * Downcast an Object handle to ImageView. If handle points to an ImageView the
108    * downcast produces valid handle. If not the returned handle is left uninitialized.
109    * @param[in] handle Handle to an object
110    * @return handle to a ImageView or an uninitialized handle
111    */
112   static ImageView DownCast( BaseHandle handle );
113
114 public:
115
116   /**
117    * Load image into ImageView for level of detail scaling.
118    * Will automatically create different sized versions
119    * of the source image.
120    *
121    * @param[in] filename The image path to load
122    * @param[in] type The type of image e.g. BitmapType or DistanceFieldType
123    */
124   void SetImage(const std::string& filename, ImageType type);
125
126   /**
127    * Load image into ImageView for level of detail scaling.
128    * The minimum scale is a percentage of the size of the
129    * image view, and represents the smallest version of the
130    * source image to display e.g. 0.125 for 12.5%
131    * While the maximum scale represents the largest version of
132    * the source image to display e.g. 1.00 for 100% (original
133    * image view size)
134    *
135    * @note ImageView SetSize must be set specified prior to
136    * calling this.
137    *
138    * @param[in] filename The image path to load
139    * @param[in] type The type of image e.g. BitmapImage or DistanceFieldImage
140    * @param[in] min The minimum scale detail to load.
141    * @param[in] max The maximum scale detail to load.
142    */
143   void SetImage(const std::string& filename, ImageType type, float min, float max);
144
145   /**
146    * Sets an image to displayed for the entire detail range.
147    * Regardless of the detail level this image will be displayed.
148    *
149    * @param[in] image The image to display
150    */
151   void SetImage(Image image);
152
153   /**
154    * Sets the camera to use for determining level of detail.
155    * Which is based on distance from camera to this ImageView.
156    * The detailFactor is the distance at which the ImageView
157    * should appear at 100% scale. Which may differ based on
158    * Projection, and ShaderEffect settings.
159    * @param[in] camera The camera
160    */
161   void SetCameraActor(CameraActor camera);
162
163   /**
164    * Sets the camera to use for determining level of detail.
165    * Which is based on distance from camera to this ImageView.
166    * The detailFactor is the distance at which the ImageView
167    * should appear at 100% scale. Which may differ based on
168    * Projection, and ShaderEffect settings.
169    * @param[in] camera The camera
170    * @param[in] detailFactor The Camera distance where detail should be 1.0
171    * (ImageView should appear at 100% scale)
172    */
173   void SetCameraActor(CameraActor camera, float detailFactor);
174
175   /**
176    * Sets the current detail level.
177    * @note This sets the detail property value.
178    * @param[in] detail The level of detail to be viewed at.
179    */
180   void SetDetail(float detail);
181
182 public: // Not intended for application developers
183
184   /**
185    * Creates a handle using the Toolkit::Internal implementation.
186    * @param[in]  implementation  The Control implementation.
187    */
188   ImageView(Internal::ImageView& implementation);
189
190   /**
191    * Allows the creation of this Control from an Internal::CustomActor pointer.
192    * @param[in]  internal  A pointer to the internal CustomActor.
193    */
194   ImageView(Dali::Internal::CustomActor* internal);
195 };
196
197 } // namespace Toolkit
198
199 } // namespace Dali
200
201 #endif // __DALI_TOOLKIT_IMAGE_VIEW_H__