-#ifndef __DALI_TOOLKIT_INTERNAL_ImageView_H__
-#define __DALI_TOOLKIT_INTERNAL_ImageView_H__
-
-//
-// Copyright (c) 2014 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Flora License, Version 1.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://floralicense.org/license/
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an AS IS BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+#ifndef DALI_TOOLKIT_INTERNAL_IMAGE_VIEW_H
+#define DALI_TOOLKIT_INTERNAL_IMAGE_VIEW_H
+
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
// EXTERNAL INCLUDES
-#include <boost/bind.hpp>
+#include <dali/public-api/object/property-map.h>
// INTERNAL INCLUDES
-#include <dali/dali.h>
+#include <dali-toolkit/internal/visuals/image/image-visual.h>
#include <dali-toolkit/public-api/controls/control-impl.h>
#include <dali-toolkit/public-api/controls/image-view/image-view.h>
namespace Dali
{
-
namespace Toolkit
{
+class ImageView;
namespace Internal
{
+class ImageView : public Control
+{
+protected:
+ /**
+ * Construct a new ImageView.
+ */
+ ImageView();
-class ImageView;
-
-typedef IntrusivePtr<ImageView> ImageViewPtr;
+ /**
+ * A reference counted object may only be deleted by calling Unreference()
+ */
+ virtual ~ImageView();
-/**
- * @copydoc Toolkit::ImageView
- */
-class ImageView : public ControlImpl
-{
public:
+ /**
+ * Create a new ImageView.
+ * @return A smart-pointer to the newly allocated ImageView.
+ */
+ static Toolkit::ImageView New();
- typedef Toolkit::ImageView::ImageType ImageType;
-
- /**
- * ImageRequest element
- * represents an image to be loaded and displayed
- * with given attributes.
- */
- struct ImageRequest
- {
- /**
- * Default constructor
- */
- ImageRequest()
- {
- }
-
- /**
- * @param[in] filename to load
- * @param[in] width Width of image.
- * @param[in] height Height of image.
- */
- ImageRequest( const std::string& filename, unsigned int width, unsigned int height )
- : mFilename( filename )
- {
- mAttributes.SetSize( width, height );
- }
-
- std::string mFilename; ///< filename of image
- ImageAttributes mAttributes; ///< attributes of image
- };
+ /**
+ * @brief Sets this ImageView from an Dali::Property::Map
+ *
+ * If the handle is empty, ImageView will display nothing
+ * @param[in] map The Dali::Property::Map to use for to display.
+ */
+ void SetImage(const Dali::Property::Map& map);
-public:
+ /**
+ * @copydoc Dali::Toolkit::SetImage
+ */
+ void SetImage(const std::string& imageUrl, ImageDimensions size);
/**
- * Create a new ImageView.
- * @return A public handle to the newly allocated ImageView.
+ * @brief Set whether the Pre-multiplied Alpha Blending is required
+ *
+ * @param[in] preMultipled whether alpha is pre-multiplied.
*/
- static Dali::Toolkit::ImageView New();
+ void EnablePreMultipliedAlpha(bool preMultipled);
-public:
+ /**
+ * @brief Query whether alpha is pre-multiplied.
+ *
+ * @return True if alpha is pre-multiplied, false otherwise.
+ */
+ bool IsPreMultipliedAlphaEnabled() const;
+ // Properties
/**
- * @copydoc Toolkit::ImageView::SetImage(const std::string& filename, ImageType type, float min, float max)
+ * Called when a property of an object of this type is set.
+ * @param[in] object The object whose property is set.
+ * @param[in] index The property index.
+ * @param[in] value The new property value.
*/
- void SetImage(const std::string& filename, ImageType type, float min, float max);
+ static void SetProperty(BaseObject* object, Property::Index index, const Property::Value& value);
/**
- * @copydoc Toolkit::ImageView::SetImage(Image& image);
+ * Called to retrieve a property of an object of this type.
+ * @param[in] object The object whose property is to be retrieved.
+ * @param[in] index The property index.
+ * @return The current value of the property.
*/
- void SetImage(Image image);
+ static Property::Value GetProperty(BaseObject* object, Property::Index propertyIndex);
/**
- * Adds an image to displayed at a detail range.
+ * @brief Set the depth index of this image renderer
*
- * @note If two or more images are specified to be displayed at
- * the same overlapping range. Then the last image that was added
- * will be displayed.
+ * Renderer with higher depth indices are rendered in front of other visuals with smaller values
*
- * @param[in] req The image to load and display
- * @param[in] condition The detail condition to be satisified for the image to display
+ * @param[in] depthIndex The depth index of this renderer
*/
- void AddImage(ImageRequest& req, PropertyCondition condition);
+ void SetDepthIndex(int depthIndex);
+private: // From Control
/**
- * @copydoc Toolkit::ImageView::SetCameraActor
+ * @copydoc Toolkit::Control::OnInitialize
*/
- void SetCameraActor(CameraActor camera, float detailFactor);
+ void OnInitialize();
/**
- * @copydoc Toolkit::ImageView::SetDetail
+ * @copydoc Toolkit::Control::GetNaturalSize
*/
- void SetDetail(float detail);
+ Vector3 GetNaturalSize() override;
-protected:
+ /**
+ * @copydoc Toolkit::Control::GetHeightForWidth()
+ */
+ float GetHeightForWidth(float width) override;
/**
- * Construct a new ImageView.
+ * @copydoc Toolkit::Control::GetWidthForHeight()
*/
- ImageView();
+ float GetWidthForHeight(float height) override;
/**
- * 2nd-phase initialization.
+ * @copydoc Toolkit::Control::OnRelayout()
*/
- void Initialize();
+ void OnRelayout(const Vector2& size, RelayoutContainer& container) override;
/**
- * A reference counted object may only be deleted by calling Unreference()
+ * @copydoc Toolkit::Control::OnCreateTransitions()
*/
- virtual ~ImageView();
+ virtual void OnCreateTransitions(Dali::Animation& animation, Dali::Toolkit::Control source, AlphaFunction alphaFunction, TimePeriod timePeriod) override;
private:
-
/**
- * Sets a Bitmap Image as the image to display for this ImageView
- * min and max represent the minimum and maximum sizes to load.
- * sizes will be created at 2^n scale factor. where n goes from
- * ceil(log2(min)) to ceil(log2(max))
- *
- * @param[in] filename the image path to load
- * @param[in] min the minimum size to load
- * @param[in] max the maximum size to load
+ * @brief Callback for ResourceReadySignal
+ * param[in] control signal prototype
*/
- void SetImageBitmap(const std::string& filename, float min, float max);
+ void OnResourceReady(Toolkit::Control control);
/**
- * Sets a Distance Field Image as the image to display for this ImageView
- *
- * @param[in] filename the image path to load
+ * @brief Set TransformMap for fittingMode
+ * param[in] finalSize The size for fittingMode
+ * param[in] textureSize The size of texture
+ * param[in] offset The offset for fittingMode
+ * param[in] fittingMode The mode for fitting image
+ * param[in] transformMap The map for fitting image
*/
- void SetImageDistanceField(const std::string& filename);
+ void SetTransformMapForFittingMode(Vector2 finalSize, Vector2 textureSize, Vector2 offset, Visual::FittingMode fittingMode, Property::Map& transformMap);
/**
- * Invoked whenever the detail property passes a notification point.
- * @param[in] notification The notification instance.
+ * @brief Apply fittingMode
+ * param[in] finalSize The size for fittingMode
+ * param[in] textureSize The size of texture
+ * param[in] offset The offset for fittingMode
+ * param[in] zeroPadding whether padding is zero
+ * param[in] transformMap The map for fitting image
*/
- virtual void OnDetailChange(PropertyNotification& notification );
+ void ApplyFittingMode(Vector2 finalSize, Vector2 textureSize, Vector2 offset, bool zeroPadding, Property::Map& transformMap);
private:
-
// Undefined
ImageView(const ImageView&);
-
- // Undefined
- ImageView& operator=(const ImageView& rhs);
+ ImageView& operator=(const ImageView&);
private:
+ Toolkit::Visual::Base mVisual;
- Property::Index mPropertyDetail; ///< Detail property, changing this affects the level of detail of the content.
- ImageActor mImageActor; ///< Holding image actor for the various images at differing levels of detail.
- std::map<PropertyNotification, ImageRequest> mNotifications; ///< Property Notification -> Image map table.
+ std::string mUrl; ///< the url for the image if the image came from a URL, empty otherwise
+ Property::Map mPropertyMap; ///< the Property::Map if the image came from a Property::Map, empty otherwise
+ Property::Map mShaderMap; ///< the Property::Map if the custom shader is set, empty otherwise
+ ImageDimensions mImageSize; ///< the image size
- PropertyNotification mPropertyNotification; ///< Property notification
+ bool mImageVisualPaddingSetByTransform : 1; //< Flag to indicate Padding was set using a transform.
+ bool mImageViewPixelAreaSetByFittingMode : 1; //< Flag to indicate pixel area was set by fitting Mode
};
} // namespace Internal
// Helpers for public-api forwarding methods
-
-inline Toolkit::Internal::ImageView& GetImpl(Toolkit::ImageView& pub)
+inline Toolkit::Internal::ImageView& GetImpl(Toolkit::ImageView& obj)
{
- DALI_ASSERT_ALWAYS(pub);
-
- Dali::RefObject& handle = pub.GetImplementation();
-
+ DALI_ASSERT_ALWAYS(obj);
+ Dali::RefObject& handle = obj.GetImplementation();
return static_cast<Toolkit::Internal::ImageView&>(handle);
}
-inline const Toolkit::Internal::ImageView& GetImpl(const Toolkit::ImageView& pub)
+inline const Toolkit::Internal::ImageView& GetImpl(const Toolkit::ImageView& obj)
{
- DALI_ASSERT_ALWAYS(pub);
-
- const Dali::RefObject& handle = pub.GetImplementation();
-
+ DALI_ASSERT_ALWAYS(obj);
+ const Dali::RefObject& handle = obj.GetImplementation();
return static_cast<const Toolkit::Internal::ImageView&>(handle);
}
} // namespace Dali
-#endif // __DALI_TOOLKIT_INTERNAL_ImageView_H__
+#endif // DALI_TOOLKIT_INTERNAL_IMAGE_VIEW_H