Include required header files directly rather than through dali.h
[platform/core/uifw/dali-toolkit.git] / optional / dali-toolkit / internal / controls / image-view / image-view-impl.h
1 #ifndef __DALI_TOOLKIT_INTERNAL_ImageView_H__
2 #define __DALI_TOOLKIT_INTERNAL_ImageView_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/image-actor.h>
23 #include <dali/public-api/common/map-wrapper.h>
24 #include <dali/public-api/images/image-attributes.h>
25 #include <dali/public-api/object/property-notification.h>
26
27 // INTERNAL INCLUDES
28 #include <dali-toolkit/public-api/controls/control-impl.h>
29 #include <dali-toolkit/public-api/controls/image-view/image-view.h>
30
31 namespace Dali
32 {
33
34 namespace Toolkit
35 {
36
37 namespace Internal
38 {
39
40 class ImageView;
41
42 typedef IntrusivePtr<ImageView>    ImageViewPtr;
43
44 /**
45  * @copydoc Toolkit::ImageView
46  */
47 class ImageView : public Control
48 {
49 public:
50
51   typedef Toolkit::ImageView::ImageType ImageType;
52
53   /**
54    * ImageRequest element
55    * represents an image to be loaded and displayed
56    * with given attributes.
57    */
58   struct ImageRequest
59   {
60     /**
61      * Default constructor
62      */
63     ImageRequest()
64     {
65     }
66
67     /**
68      * @param[in] filename to load
69      * @param[in] width Width of image.
70      * @param[in] height Height of image.
71      */
72     ImageRequest( const std::string& filename, unsigned int width, unsigned int height )
73     : mFilename( filename )
74     {
75       mAttributes.SetSize( width, height );
76     }
77
78     std::string mFilename;                  ///< filename of image
79     ImageAttributes mAttributes;            ///< attributes of image
80   };
81
82 public:
83
84   /**
85    * Create a new ImageView.
86    * @return A public handle to the newly allocated ImageView.
87    */
88   static Dali::Toolkit::ImageView New();
89
90 public:
91
92   /**
93    * @copydoc Toolkit::ImageView::SetImage(const std::string& filename, ImageType type, float min, float max)
94    */
95   void SetImage(const std::string& filename, ImageType type, float min, float max);
96
97   /**
98    * @copydoc Toolkit::ImageView::SetImage(Image& image);
99    */
100   void SetImage(Image image);
101
102   /**
103    * Adds an image to displayed at a detail range.
104    *
105    * @note If two or more images are specified to be displayed at
106    * the same overlapping range. Then the last image that was added
107    * will be displayed.
108    *
109    * @param[in] req The image to load and display
110    * @param[in] condition The detail condition to be satisified for the image to display
111    */
112   void AddImage(ImageRequest& req, PropertyCondition condition);
113
114   /**
115    * @copydoc Toolkit::ImageView::SetCameraActor
116    */
117   void SetCameraActor(CameraActor camera, float detailFactor);
118
119   /**
120    * @copydoc Toolkit::ImageView::SetDetail
121    */
122   void SetDetail(float detail);
123
124 protected:
125
126   /**
127    * Construct a new ImageView.
128    */
129   ImageView();
130
131   /**
132    * 2nd-phase initialization.
133    */
134   void Initialize();
135
136   /**
137    * A reference counted object may only be deleted by calling Unreference()
138    */
139   virtual ~ImageView();
140
141 private:
142
143   /**
144    * Sets a Bitmap Image as the image to display for this ImageView
145    * min and max represent the minimum and maximum sizes to load.
146    * sizes will be created at 2^n scale factor. where n goes from
147    * ceil(log2(min)) to ceil(log2(max))
148    *
149    * @param[in] filename the image path to load
150    * @param[in] min the minimum size to load
151    * @param[in] max the maximum size to load
152    */
153   void SetImageBitmap(const std::string& filename, float min, float max);
154
155   /**
156    * Sets a Distance Field Image as the image to display for this ImageView
157    *
158    * @param[in] filename the image path to load
159    */
160   void SetImageDistanceField(const std::string& filename);
161
162   /**
163    * Invoked whenever the detail property passes a notification point.
164    * @param[in] notification The notification instance.
165    */
166   virtual void OnDetailChange(PropertyNotification& notification );
167
168 private:
169
170   // Undefined
171   ImageView(const ImageView&);
172
173   // Undefined
174   ImageView& operator=(const ImageView& rhs);
175
176 private:
177
178   Property::Index mPropertyDetail;                              ///< Detail property, changing this affects the level of detail of the content.
179   ImageActor mImageActor;                                       ///< Holding image actor for the various images at differing levels of detail.
180   std::map<PropertyNotification, ImageRequest> mNotifications;  ///< Property Notification -> Image map table.
181
182   PropertyNotification mPropertyNotification;   ///< Property notification
183 };
184
185 } // namespace Internal
186
187 // Helpers for public-api forwarding methods
188
189 inline Toolkit::Internal::ImageView& GetImpl(Toolkit::ImageView& pub)
190 {
191   DALI_ASSERT_ALWAYS(pub);
192
193   Dali::RefObject& handle = pub.GetImplementation();
194
195   return static_cast<Toolkit::Internal::ImageView&>(handle);
196 }
197
198 inline const Toolkit::Internal::ImageView& GetImpl(const Toolkit::ImageView& pub)
199 {
200   DALI_ASSERT_ALWAYS(pub);
201
202   const Dali::RefObject& handle = pub.GetImplementation();
203
204   return static_cast<const Toolkit::Internal::ImageView&>(handle);
205 }
206
207 } // namespace Toolkit
208
209 } // namespace Dali
210
211 #endif // __DALI_TOOLKIT_INTERNAL_ImageView_H__