X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fimage-view%2Fimage-view-impl.h;h=4f05648a7fa75d4461393e9d07800644cc9bfa6f;hp=9c0f89ab7a51bcdb6ab979bbb35b741b69992282;hb=108a91b70f76ed395aaff1694010c56f3d1a653c;hpb=e2eda444afbe82e9591fe198eef339227f90a616 diff --git a/dali-toolkit/internal/controls/image-view/image-view-impl.h b/dali-toolkit/internal/controls/image-view/image-view-impl.h index 9c0f89a..4f05648 100644 --- a/dali-toolkit/internal/controls/image-view/image-view-impl.h +++ b/dali-toolkit/internal/controls/image-view/image-view-impl.h @@ -1,27 +1,28 @@ -#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) 2017 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 +#include // INTERNAL INCLUDES -#include +#include #include #include @@ -31,173 +32,158 @@ namespace Dali namespace Toolkit { -namespace Internal -{ - class ImageView; -typedef IntrusivePtr ImageViewPtr; - -/** - * @copydoc Toolkit::ImageView - */ -class ImageView : public ControlImpl +namespace Internal { -public: +class ImageView : public Control +{ +protected: - 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 - }; + /** + * Construct a new ImageView. + */ + ImageView(); -public: + /** + * A reference counted object may only be deleted by calling Unreference() + */ + virtual ~ImageView(); +public: /** * Create a new ImageView. - * @return A public handle to the newly allocated ImageView. + * @return A smart-pointer to the newly allocated ImageView. */ - static Dali::Toolkit::ImageView New(); + static Toolkit::ImageView New(); -public: + /** + * @copydoc Dali::Toolkit::SetImage + */ + void SetImage( Image image ); /** - * @copydoc Toolkit::ImageView::SetImage(const std::string& filename, ImageType type, float min, float max) + * @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 std::string& filename, ImageType type, float min, float max); + void SetImage( const Dali::Property::Map& map ); /** - * @copydoc Toolkit::ImageView::SetImage(Image& image); + * @copydoc Dali::Toolkit::SetImage */ - void SetImage(Image image); + void SetImage( const std::string& imageUrl, ImageDimensions size ); /** - * Adds an image to displayed at a detail range. - * - * @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. - * - * @param[in] req The image to load and display - * @param[in] condition The detail condition to be satisified for the image to display + * @copydoc Dali::Toolkit::GetImage */ - void AddImage(ImageRequest& req, PropertyCondition condition); + Image GetImage() const; /** - * @copydoc Toolkit::ImageView::SetCameraActor + * @brief Set whether the Pre-multiplied Alpha Blending is required + * + * @param[in] preMultipled whether alpha is pre-multiplied. */ - void SetCameraActor(CameraActor camera, float detailFactor); + void EnablePreMultipliedAlpha( bool preMultipled ); /** - * @copydoc Toolkit::ImageView::SetDetail + * @brief Query whether alpha is pre-multiplied. + * + * @return True is alpha is pre-multiplied, false otherwise. */ - void SetDetail(float detail); + bool IsPreMultipliedAlphaEnabled() const; -protected: + // Properties + /** + * 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. + */ + static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value ); /** - * Construct a new ImageView. + * 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. */ - ImageView(); + static Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex ); /** - * 2nd-phase initialization. + * @brief Set the depth index of this image renderer + * + * Renderer with higher depth indices are rendered in front of other visuals with smaller values + * + * @param[in] depthIndex The depth index of this renderer */ - void Initialize(); + void SetDepthIndex( int depthIndex ); + +private: // From Control /** - * A reference counted object may only be deleted by calling Unreference() + * @copydoc Toolkit::Control::OnInitialize */ - virtual ~ImageView(); + void OnInitialize(); -private: + /** + * @copydoc Toolkit::Control::GetNaturalSize + */ + virtual Vector3 GetNaturalSize(); /** - * 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 + * @copydoc Toolkit::Control::GetHeightForWidth() */ - void SetImageBitmap(const std::string& filename, float min, float max); + virtual float GetHeightForWidth( float width ); /** - * Sets a Distance Field Image as the image to display for this ImageView - * - * @param[in] filename the image path to load + * @copydoc Toolkit::Control::GetWidthForHeight() */ - void SetImageDistanceField(const std::string& filename); + virtual float GetWidthForHeight( float height ); /** - * Invoked whenever the detail property passes a notification point. - * @param[in] notification The notification instance. + * @copydoc Toolkit::Control::OnRelayout() */ - virtual void OnDetailChange(PropertyNotification& notification ); + virtual void OnRelayout( const Vector2& size, RelayoutContainer& container ); private: - // Undefined - ImageView(const ImageView&); + /** + * @brief Callback for ResourceReadySignal + * param[in] control signal prototype + */ + void OnResourceReady( Toolkit::Control control ); +private: // Undefined - ImageView& operator=(const ImageView& rhs); + ImageView( const ImageView& ); + 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 mNotifications; ///< Property Notification -> Image map table. - - PropertyNotification mPropertyNotification; ///< Property notification + std::string mUrl; ///< the url for the image if the image came from a URL, empty otherwise + Image mImage; ///< the Image if the image came from a Image, null 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 }; } // 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(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(handle); } @@ -205,4 +191,4 @@ inline const Toolkit::Internal::ImageView& GetImpl(const Toolkit::ImageView& pub } // namespace Dali -#endif // __DALI_TOOLKIT_INTERNAL_ImageView_H__ +#endif // __DALI_TOOLKIT_INTERNAL_IMAGE_VIEW_H__