1 #ifndef DALI_TOOLKIT_INTERNAL_IMAGE_VIEW_H
2 #define DALI_TOOLKIT_INTERNAL_IMAGE_VIEW_H
5 * Copyright (c) 2020 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 * @brief Sets this ImageView from an Dali::Property::Map
63 * If the handle is empty, ImageView will display nothing
64 * @param[in] map The Dali::Property::Map to use for to display.
66 void SetImage( const Dali::Property::Map& map );
69 * @copydoc Dali::Toolkit::SetImage
71 void SetImage( const std::string& imageUrl, ImageDimensions size );
74 * @brief Set whether the Pre-multiplied Alpha Blending is required
76 * @param[in] preMultipled whether alpha is pre-multiplied.
78 void EnablePreMultipliedAlpha( bool preMultipled );
81 * @brief Query whether alpha is pre-multiplied.
83 * @return True if alpha is pre-multiplied, false otherwise.
85 bool IsPreMultipliedAlphaEnabled() const;
89 * Called when a property of an object of this type is set.
90 * @param[in] object The object whose property is set.
91 * @param[in] index The property index.
92 * @param[in] value The new property value.
94 static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
97 * Called to retrieve a property of an object of this type.
98 * @param[in] object The object whose property is to be retrieved.
99 * @param[in] index The property index.
100 * @return The current value of the property.
102 static Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex );
105 * @brief Set the depth index of this image renderer
107 * Renderer with higher depth indices are rendered in front of other visuals with smaller values
109 * @param[in] depthIndex The depth index of this renderer
111 void SetDepthIndex( int depthIndex );
113 private: // From Control
116 * @copydoc Toolkit::Control::OnInitialize
121 * @copydoc Toolkit::Control::GetNaturalSize
123 Vector3 GetNaturalSize() override;
126 * @copydoc Toolkit::Control::GetHeightForWidth()
128 float GetHeightForWidth( float width ) override;
131 * @copydoc Toolkit::Control::GetWidthForHeight()
133 float GetWidthForHeight( float height ) override;
136 * @copydoc Toolkit::Control::OnRelayout()
138 void OnRelayout( const Vector2& size, RelayoutContainer& container ) override;
143 * @brief Callback for ResourceReadySignal
144 * param[in] control signal prototype
146 void OnResourceReady( Toolkit::Control control );
149 * @brief Set TransformMap for fittingMode
150 * param[in] finalSize The size for fittingMode
151 * param[in] textureSize The size of texture
152 * param[in] offset The offset for fittingMode
153 * param[in] fittingMode The mode for fitting image
154 * param[in] transformMap The map for fitting image
156 void SetTransformMapForFittingMode ( Vector2 finalSize, Vector2 textureSize, Vector2 offset, Visual::FittingMode fittingMode, Property::Map& transformMap );
159 * @brief Apply fittingMode
160 * param[in] finalSize The size for fittingMode
161 * param[in] textureSize The size of texture
162 * param[in] offset The offset for fittingMode
163 * param[in] zeroPadding whether padding is zero
164 * param[in] transformMap The map for fitting image
166 void ApplyFittingMode( Vector2 finalSize, Vector2 textureSize, Vector2 offset, bool zeroPadding , Property::Map& transformMap);
170 ImageView( const ImageView& );
171 ImageView& operator=( const ImageView& );
174 Toolkit::Visual::Base mVisual;
176 std::string mUrl; ///< the url for the image if the image came from a URL, empty otherwise
177 Property::Map mPropertyMap; ///< the Property::Map if the image came from a Property::Map, empty otherwise
178 Property::Map mShaderMap; ///< the Property::Map if the custom shader is set, empty otherwise
179 ImageDimensions mImageSize; ///< the image size
181 bool mImageVisualPaddingSetByTransform :1; //< Flag to indicate Padding was set using a transform.
182 bool mImageViewPixelAreaSetByFittingMode:1; //< Flag to indicate pixel area was set by fitting Mode
185 } // namespace Internal
187 // Helpers for public-api forwarding methods
188 inline Toolkit::Internal::ImageView& GetImpl( Toolkit::ImageView& obj )
190 DALI_ASSERT_ALWAYS(obj);
191 Dali::RefObject& handle = obj.GetImplementation();
192 return static_cast<Toolkit::Internal::ImageView&>(handle);
195 inline const Toolkit::Internal::ImageView& GetImpl( const Toolkit::ImageView& obj )
197 DALI_ASSERT_ALWAYS(obj);
198 const Dali::RefObject& handle = obj.GetImplementation();
199 return static_cast<const Toolkit::Internal::ImageView&>(handle);
202 } // namespace Toolkit
206 #endif // DALI_TOOLKIT_INTERNAL_IMAGE_VIEW_H