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 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/actors/image-actor.h>
23 #include <dali/internal/event/actor-attachments/actor-attachment-declarations.h>
24 #include <dali/internal/event/actor-attachments/renderable-attachment-impl.h>
25 #include <dali/internal/event/images/image-impl.h>
26 #include <dali/internal/event/images/image-connector.h>
36 class ImageAttachment;
41 * An attachment for rendering images in various ways.
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] stage The stage to use for messaging
53 * @param[in] parentNode The node to attach a scene-object to.
54 * @return A smart-pointer to the newly allocated ImageAttachment.
56 static ImageAttachmentPtr New( Stage& stage, const SceneGraph::Node& parentNode );
59 * Sets image rendered by the attachment.
60 * @param [in] image A pointer to the image to display or NULL to clear. Reference to avoid unnecessary increment/decrement reference count.
62 void SetImage( ImagePtr& image );
65 * Retrieve the image rendered by the attachment.
66 * @return The image or an uninitialized image in case the ImageActor was cleared.
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.
139 ImageAttachment(Stage& stage);
142 * Creates the corresponding scene-graph ImageAttachment.
143 * @return A newly allocated scene object.
145 static SceneGraph::ImageAttachment* CreateSceneObject();
148 * @copydoc Dali::Internal::RenderableAttachment::OnStageConnection2()
150 virtual void OnStageConnection2();
153 * @copydoc Dali::Internal::RenderableAttachment::OnStageDisconnection2()
155 virtual void OnStageDisconnection2();
158 * @copydoc Dali::Internal::RenderableAttachment::GetSceneObject()
160 virtual const SceneGraph::RenderableAttachment& GetSceneObject() const;
165 * A reference counted object may only be deleted by calling Unreference()
167 virtual ~ImageAttachment();
171 const SceneGraph::ImageAttachment* mSceneObject; ///< Not owned
173 ImageConnector mImageConnectable; ///< Manages the image displayed by the attachment
175 // Cached for public getters
177 PixelArea mPixelArea;
182 bool mIsPixelAreaSet : 1;
183 bool mBorderInPixels : 1;
186 } // namespace Internal
190 #endif // __DALI_INTERNAL_IMAGE_ATTACHMENT_H__