1 #ifndef __DALI_INTERNAL_IMAGE_ATTACHMENT_H__
2 #define __DALI_INTERNAL_IMAGE_ATTACHMENT_H__
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
7 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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.
21 #include <dali/public-api/actors/image-actor.h>
22 #include <dali/internal/event/actor-attachments/actor-attachment-declarations.h>
23 #include <dali/internal/event/actor-attachments/renderable-attachment-impl.h>
24 #include <dali/internal/event/images/image-impl.h>
25 #include <dali/internal/event/images/image-connector.h>
35 class ImageAttachment;
40 * An attachment for rendering images in various ways.
41 * The default geometry scaling mode is ScaleToFill.
43 class ImageAttachment : public RenderableAttachment
47 typedef Dali::ImageActor::Style Style;
48 typedef Dali::ImageActor::PixelArea PixelArea;
51 * Create a new ImageAttachment.
52 * @param[in] parentNode The node to attach a scene-object to.
53 * @param[in] image A pointer to the image to display or NULL to not render anything.
54 * @return A smart-pointer to the newly allocated ImageAttachment.
56 static ImageAttachmentPtr New( const SceneGraph::Node& parentNode, Image* image );
59 * Sets image rendered by the attachment.
60 * @param [in] image A pointer to the image to display or NULL to clear.
62 void SetImage(Image* image);
65 * Retrieve the image rendered by the attachment.
66 * @return The image or an uninitialized image in case the ImageActor was cleared.
68 Dali::Image GetImage();
71 * Set a region of the image to display, in pixels.
72 * @param [in] pixelArea The area of the image to display.
73 * This in pixels, relative to the top-left (0,0) of the image.
75 void SetPixelArea(const PixelArea& pixelArea);
78 * Retrieve the region of the image to display, in pixels.
79 * @return The pixel area, or a default-constructed area if none was set.
81 const PixelArea& GetPixelArea() const
83 // This is not animatable; the cached value is up-to-date.
88 * Query whether a pixel area has been set.
89 * @return True if a pixel area has been set.
91 bool IsPixelAreaSet() const
93 // This is not animatable; the cached value is up-to-date.
94 return mIsPixelAreaSet;
98 * Remove any pixel areas specified with SetPixelArea; the entire image will be displayed.
99 * @pre image must be initialized.
101 void ClearPixelArea();
104 * Set how the ImageAttachment is rendered; the default is STYLE_QUAD.
105 * @param [in] style The new style.
107 void SetStyle(Style style);
110 * Query how the image is rendered.
111 * @return The rendering style.
115 // This is not animatable; the cached value is up-to-date.
120 * @copydoc Dali::ImageActor::SetNinePatchBorder
122 void SetNinePatchBorder(const Vector4& border, bool inPixels);
125 * @copydoc Dali::ImageActor::GetNinePatchBorder
127 Vector4 GetNinePatchBorder()
129 // This is not animatable; the cached value is up-to-date.
136 * First stage construction of a ImageAttachment.
137 * @param[in] stage Used to send messages to scene-graph.
138 * @param[in] image A pointer to the image to display or NULL to not render anything.
140 ImageAttachment(Stage& stage, Image* image);
143 * Creates the corresponding scene-graph ImageAttachment.
144 * @return A newly allocated scene object.
146 static SceneGraph::ImageAttachment* CreateSceneObject( const Image* current );
149 * @copydoc Dali::Internal::RenderableAttachment::OnStageConnection2()
151 virtual void OnStageConnection2();
154 * @copydoc Dali::Internal::RenderableAttachment::OnStageDisconnection2()
156 virtual void OnStageDisconnection2();
159 * @copydoc Dali::Internal::RenderableAttachment::GetSceneObject()
161 virtual const SceneGraph::RenderableAttachment& GetSceneObject() const;
166 * A reference counted object may only be deleted by calling Unreference()
168 virtual ~ImageAttachment();
172 const SceneGraph::ImageAttachment* mSceneObject; ///< Not owned
174 ImageConnector mImageConnectable; ///< Manages the image displayed by the attachment
176 // Cached for public getters
178 PixelArea mPixelArea;
183 bool mIsPixelAreaSet : 1;
184 bool mBorderInPixels : 1;
187 } // namespace Internal
191 #endif // __DALI_INTERNAL_IMAGE_ATTACHMENT_H__