1 #ifndef __DALI_TOOLKIT_INTERNAL_IMAGE_VIEW_H__
2 #define __DALI_TOOLKIT_INTERNAL_IMAGE_VIEW_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/object/property-map.h>
25 #include <dali-toolkit/internal/visuals/image/image-visual.h>
26 #include <dali-toolkit/public-api/controls/control-impl.h>
27 #include <dali-toolkit/public-api/controls/image-view/image-view.h>
39 class ImageView : public Control
44 * Construct a new ImageView.
49 * A reference counted object may only be deleted by calling Unreference()
55 * Create a new ImageView.
56 * @return A smart-pointer to the newly allocated ImageView.
58 static Toolkit::ImageView New();
61 * @copydoc Dali::Toolkit::SetImage
63 void SetImage( Image image );
66 * @brief Sets this ImageView from an Dali::Property::Map
68 * If the handle is empty, ImageView will display nothing
69 * @param[in] map The Dali::Property::Map to use for to display.
71 void SetImage( Dali::Property::Map map );
74 * @copydoc Dali::Toolkit::SetImage
76 void SetImage( const std::string& imageUrl, ImageDimensions size );
79 * @copydoc Dali::Toolkit::GetImage
81 Image GetImage() const;
84 * @brief Set whether the Pre-multiplied Alpha Blending is required
86 * @param[in] preMultipled whether alpha is pre-multiplied.
88 void EnablePreMultipliedAlpha( bool preMultipled );
91 * @brief Query whether alpha is pre-multiplied.
93 * @return True is alpha is pre-multiplied, false otherwise.
95 bool IsPreMultipliedAlphaEnabled() const;
99 * Called when a property of an object of this type is set.
100 * @param[in] object The object whose property is set.
101 * @param[in] index The property index.
102 * @param[in] value The new property value.
104 static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
107 * Called to retrieve a property of an object of this type.
108 * @param[in] object The object whose property is to be retrieved.
109 * @param[in] index The property index.
110 * @return The current value of the property.
112 static Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex );
115 * @brief Set the depth index of this image renderer
117 * Renderer with higher depth indices are rendered in front of other visuals with smaller values
119 * @param[in] depthIndex The depth index of this renderer
121 void SetDepthIndex( int depthIndex );
123 private: // From Control
126 * @copydoc Toolkit::Control::OnSizeSet()
128 virtual void OnSizeSet( const Vector3& targetSize );
131 * @copydoc Toolkit::Control::GetNaturalSize
133 virtual Vector3 GetNaturalSize();
136 * @copydoc Toolkit::Control::GetHeightForWidth()
138 virtual float GetHeightForWidth( float width );
141 * @copydoc Toolkit::Control::GetWidthForHeight()
143 virtual float GetWidthForHeight( float height );
147 ImageView( const ImageView& );
148 ImageView& operator=( const ImageView& );
151 Toolkit::Visual::Base mVisual;
152 ImageDimensions mImageSize;
155 std::string mUrl; ///< the url for the image if the image came from a URL, empty otherwise
156 Image mImage; ///< the Image if the image came from a Image, null otherwise
157 Property::Map mPropertyMap; ///< the Property::Map if the image came from a Property::Map, empty otherwise
160 } // namespace Internal
162 // Helpers for public-api forwarding methods
163 inline Toolkit::Internal::ImageView& GetImpl( Toolkit::ImageView& obj )
165 DALI_ASSERT_ALWAYS(obj);
166 Dali::RefObject& handle = obj.GetImplementation();
167 return static_cast<Toolkit::Internal::ImageView&>(handle);
170 inline const Toolkit::Internal::ImageView& GetImpl( const Toolkit::ImageView& obj )
172 DALI_ASSERT_ALWAYS(obj);
173 const Dali::RefObject& handle = obj.GetImplementation();
174 return static_cast<const Toolkit::Internal::ImageView&>(handle);
177 } // namespace Toolkit
181 #endif // __DALI_TOOLKIT_INTERNAL_IMAGE_VIEW_H__