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/controls/renderers/image/image-renderer.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 * @brief Set whether the Pre-multiplied Alpha Blending is required
81 * @param[in] preMultipled whether alpha is pre-multiplied.
83 void EnablePreMultipliedAlpha( bool preMultipled );
86 * @brief Query whether alpha is pre-multiplied.
88 * @return True is alpha is pre-multiplied, false otherwise.
90 bool IsPreMultipliedAlphaEnabled() const;
94 * Called when a property of an object of this type is set.
95 * @param[in] object The object whose property is set.
96 * @param[in] index The property index.
97 * @param[in] value The new property value.
99 static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
102 * Called to retrieve a property of an object of this type.
103 * @param[in] object The object whose property is to be retrieved.
104 * @param[in] index The property index.
105 * @return The current value of the property.
107 static Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex );
110 * @brief Set the depth index of this image renderer
112 * Renderer with higher depth indices are rendered in front of other renderers with smaller values
114 * @param[in] depthIndex The depth index of this renderer
116 void SetDepthIndex( int depthIndex );
118 private: // From Control
121 * @copydoc Toolkit::Control::OnStageConnect()
123 virtual void OnStageConnection( int depth );
126 * @copydoc Toolkit::Control::OnStageDisconnection()
128 virtual void OnStageDisconnection();
131 * @copydoc Toolkit::Control::OnSizeSet()
133 virtual void OnSizeSet( const Vector3& targetSize );
136 * @copydoc Toolkit::Control::GetNaturalSize
138 virtual Vector3 GetNaturalSize();
141 * @copydoc Toolkit::Control::GetHeightForWidth()
143 virtual float GetHeightForWidth( float width );
146 * @copydoc Toolkit::Control::GetWidthForHeight()
148 virtual float GetWidthForHeight( float height );
152 ImageView( const ImageView& );
153 ImageView& operator=( const ImageView& );
156 Toolkit::ControlRenderer mRenderer;
157 ImageDimensions mImageSize;
159 std::string mUrl; ///< the url for the image if the image came from a URL, empty otherwise
160 Image mImage; ///< the Image if the image came from a Image, null otherwise
161 Property::Map mPropertyMap; ///< the Property::Map if the image came from a Property::Map, empty otherwise
163 bool mPremultipledAlphaEnabled; ///< Flag indicating whether the Pre-multiplied Alpha Blending is required
166 } // namespace Internal
168 // Helpers for public-api forwarding methods
169 inline Toolkit::Internal::ImageView& GetImpl( Toolkit::ImageView& obj )
171 DALI_ASSERT_ALWAYS(obj);
172 Dali::RefObject& handle = obj.GetImplementation();
173 return static_cast<Toolkit::Internal::ImageView&>(handle);
176 inline const Toolkit::Internal::ImageView& GetImpl( const Toolkit::ImageView& obj )
178 DALI_ASSERT_ALWAYS(obj);
179 const Dali::RefObject& handle = obj.GetImplementation();
180 return static_cast<const Toolkit::Internal::ImageView&>(handle);
183 } // namespace Toolkit
187 #endif // __DALI_TOOLKIT_INTERNAL_IMAGE_VIEW_H__