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()
57 * Create a new ImageView.
58 * @return A smart-pointer to the newly allocated ImageView.
60 static Toolkit::ImageView New();
63 * @copydoc Dali::Toolkit::SetImage
65 void SetImage( Image image );
68 * @brief Sets this ImageView from an Dali::Property::Map
70 * If the handle is empty, ImageView will display nothing
71 * @param[in] map The Dali::Property::Map to use for to display.
73 void SetImage( Dali::Property::Map map );
76 * @copydoc Dali::Toolkit::SetImage
78 void SetImage( const std::string& imageUrl );
82 * Called when a property of an object of this type is set.
83 * @param[in] object The object whose property is set.
84 * @param[in] index The property index.
85 * @param[in] value The new property value.
87 static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
90 * Called to retrieve a property of an object of this type.
91 * @param[in] object The object whose property is to be retrieved.
92 * @param[in] index The property index.
93 * @return The current value of the property.
95 static Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex );
97 private: // From Control
100 * @copydoc Toolkit::Control::OnStageConnect()
102 virtual void OnStageConnection( int depth );
105 * @copydoc Toolkit::Control::GetNaturalSize
107 virtual Vector3 GetNaturalSize();
110 * @copydoc Toolkit::Control::GetHeightForWidth()
112 virtual float GetHeightForWidth( float width );
115 * @copydoc Toolkit::Control::GetWidthForHeight()
117 virtual float GetWidthForHeight( float height );
121 * Attaches mImage member to the renderer, creating the renderers, samplers, meshes and materials if needed
123 * @pre mImage has been initialised
129 ImageView( const ImageView& );
130 ImageView& operator=( const ImageView& );
133 Toolkit::ControlRenderer mRenderer;
134 ImageDimensions mImageSize;
136 std::string mUrl; ///< the url for the image if the image came from a URL, empty otherwise
137 Image mImage; ///< the Image if the image came from a Image, null otherwise
138 Property::Map mPropertyMap; ///< the Property::Map if the image came from a Property::Map, empty otherwise
141 } // namespace Internal
143 // Helpers for public-api forwarding methods
144 inline Toolkit::Internal::ImageView& GetImpl( Toolkit::ImageView& obj )
146 DALI_ASSERT_ALWAYS(obj);
147 Dali::RefObject& handle = obj.GetImplementation();
148 return static_cast<Toolkit::Internal::ImageView&>(handle);
151 inline const Toolkit::Internal::ImageView& GetImpl( const Toolkit::ImageView& obj )
153 DALI_ASSERT_ALWAYS(obj);
154 const Dali::RefObject& handle = obj.GetImplementation();
155 return static_cast<const Toolkit::Internal::ImageView&>(handle);
158 } // namespace Toolkit
162 #endif // __DALI_TOOLKIT_INTERNAL_IMAGE_VIEW_H__