Merge "Added API to generate a MeshData object for a Dali::Path object" into tizen
[platform/core/uifw/dali-core.git] / dali / public-api / actors / image-actor.cpp
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali/public-api/actors/image-actor.h>
20
21 // INTERNAL INCLUDES
22 #include <dali/internal/event/actors/image-actor-impl.h>
23 #include <dali/internal/event/images/image-impl.h>
24 #include <dali/public-api/common/dali-common.h>
25
26 namespace Dali
27 {
28
29 ImageActor::ImageActor()
30 {
31 }
32
33 ImageActor ImageActor::New()
34 {
35   Internal::ImageActorPtr internal = Internal::ImageActor::New();
36   return ImageActor( internal.Get() );
37 }
38
39 ImageActor ImageActor::New(Image image)
40 {
41   ImageActor actor = ImageActor::New();
42   actor.SetImage( image );
43
44   return actor;
45 }
46
47 ImageActor ImageActor::New(Image image, PixelArea pixelArea)
48 {
49   ImageActor actor = ImageActor::New();
50   actor.SetImage( image );
51   actor.SetPixelArea( pixelArea );
52
53   return actor;
54 }
55
56 ImageActor ImageActor::DownCast( BaseHandle handle )
57 {
58   return ImageActor( dynamic_cast<Dali::Internal::ImageActor*>(handle.GetObjectPtr()) );
59 }
60
61 ImageActor::~ImageActor()
62 {
63 }
64
65 ImageActor::ImageActor(const ImageActor& copy)
66 : RenderableActor(copy)
67 {
68 }
69
70 ImageActor& ImageActor::operator=(const ImageActor& rhs)
71 {
72   BaseHandle::operator=(rhs);
73   return *this;
74 }
75
76 void ImageActor::SetImage(Image image)
77 {
78   Internal::ImagePtr imagePtr;
79   if( image )
80   {
81     imagePtr = &GetImplementation(image);
82   }
83   GetImplementation(*this).SetImage( imagePtr );
84 }
85
86 Image ImageActor::GetImage()
87 {
88   Internal::ImagePtr imagePtr( GetImplementation(*this).GetImage() );
89   return Dali::Image( imagePtr.Get() );
90 }
91
92 void ImageActor::SetToNaturalSize()
93 {
94   GetImplementation(*this).SetToNaturalSize();
95 }
96
97 void ImageActor::SetPixelArea(const PixelArea& pixelArea)
98 {
99   GetImplementation(*this).SetPixelArea(pixelArea);
100 }
101
102 ImageActor::PixelArea ImageActor::GetPixelArea() const
103 {
104   return GetImplementation(*this).GetPixelArea();
105 }
106
107 bool ImageActor::IsPixelAreaSet() const
108 {
109   return GetImplementation(*this).IsPixelAreaSet();
110 }
111
112 void ImageActor::ClearPixelArea()
113 {
114   GetImplementation(*this).ClearPixelArea();
115 }
116
117 void ImageActor::SetStyle(Style style)
118 {
119   GetImplementation(*this).SetStyle(style);
120 }
121
122 ImageActor::Style ImageActor::GetStyle() const
123 {
124   return GetImplementation(*this).GetStyle();
125 }
126
127 void ImageActor::SetNinePatchBorder(const Vector4& border)
128 {
129   GetImplementation(*this).SetNinePatchBorder(border, true/*in pixels*/);
130 }
131
132 Vector4 ImageActor::GetNinePatchBorder() const
133 {
134   return GetImplementation(*this).GetNinePatchBorder();
135 }
136
137 ImageActor::ImageActor(Internal::ImageActor* internal)
138 : RenderableActor(internal)
139 {
140 }
141
142 } // namespace Dali