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