1 #ifndef __DALI_TOOLKIT_INTERNAL_ImageView_H__
2 #define __DALI_TOOLKIT_INTERNAL_ImageView_H__
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
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>
28 #include <dali-toolkit/public-api/controls/control-impl.h>
29 #include <dali-toolkit/public-api/controls/image-view/image-view.h>
42 typedef IntrusivePtr<ImageView> ImageViewPtr;
45 * @copydoc Toolkit::ImageView
47 class ImageView : public Control
51 typedef Toolkit::ImageView::ImageType ImageType;
54 * ImageRequest element
55 * represents an image to be loaded and displayed
56 * with given attributes.
68 * @param[in] filename to load
69 * @param[in] width Width of image.
70 * @param[in] height Height of image.
72 ImageRequest( const std::string& filename, unsigned int width, unsigned int height )
73 : mFilename( filename )
75 mAttributes.SetSize( width, height );
78 std::string mFilename; ///< filename of image
79 ImageAttributes mAttributes; ///< attributes of image
85 * Create a new ImageView.
86 * @return A public handle to the newly allocated ImageView.
88 static Dali::Toolkit::ImageView New();
93 * @copydoc Toolkit::ImageView::SetImage(const std::string& filename, ImageType type, float min, float max)
95 void SetImage(const std::string& filename, ImageType type, float min, float max);
98 * @copydoc Toolkit::ImageView::SetImage(Image& image);
100 void SetImage(Image image);
103 * Adds an image to displayed at a detail range.
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
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
112 void AddImage(ImageRequest& req, PropertyCondition condition);
115 * @copydoc Toolkit::ImageView::SetCameraActor
117 void SetCameraActor(CameraActor camera, float detailFactor);
120 * @copydoc Toolkit::ImageView::SetDetail
122 void SetDetail(float detail);
127 * Construct a new ImageView.
132 * 2nd-phase initialization.
137 * A reference counted object may only be deleted by calling Unreference()
139 virtual ~ImageView();
143 * @copydoc Toolkit::Control::OnControlSizeSet( const Vector3& targetSize )
145 virtual void OnControlSizeSet( const Vector3& targetSize );
150 * Sets a Bitmap Image as the image to display for this ImageView
151 * min and max represent the minimum and maximum sizes to load.
152 * sizes will be created at 2^n scale factor. where n goes from
153 * ceil(log2(min)) to ceil(log2(max))
155 * @param[in] filename the image path to load
156 * @param[in] min the minimum size to load
157 * @param[in] max the maximum size to load
159 void SetImageBitmap(const std::string& filename, float min, float max);
162 * Sets a Distance Field Image as the image to display for this ImageView
164 * @param[in] filename the image path to load
166 void SetImageDistanceField(const std::string& filename);
169 * Invoked whenever the detail property passes a notification point.
170 * @param[in] notification The notification instance.
172 virtual void OnDetailChange(PropertyNotification& notification );
177 ImageView(const ImageView&);
180 ImageView& operator=(const ImageView& rhs);
184 Property::Index mPropertyDetail; ///< Detail property, changing this affects the level of detail of the content.
185 ImageActor mImageActor; ///< Holding image actor for the various images at differing levels of detail.
186 std::map<PropertyNotification, ImageRequest> mNotifications; ///< Property Notification -> Image map table.
188 PropertyNotification mPropertyNotification; ///< Property notification
191 } // namespace Internal
193 // Helpers for public-api forwarding methods
195 inline Toolkit::Internal::ImageView& GetImpl(Toolkit::ImageView& pub)
197 DALI_ASSERT_ALWAYS(pub);
199 Dali::RefObject& handle = pub.GetImplementation();
201 return static_cast<Toolkit::Internal::ImageView&>(handle);
204 inline const Toolkit::Internal::ImageView& GetImpl(const Toolkit::ImageView& pub)
206 DALI_ASSERT_ALWAYS(pub);
208 const Dali::RefObject& handle = pub.GetImplementation();
210 return static_cast<const Toolkit::Internal::ImageView&>(handle);
213 } // namespace Toolkit
217 #endif // __DALI_TOOLKIT_INTERNAL_ImageView_H__