License conversion from Flora to Apache 2.0
[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   // empty image
36   Internal::ImageActorPtr internal = Internal::ImageActor::New(NULL);
37   return ImageActor(internal.Get());
38 }
39
40 ImageActor ImageActor::New(Image image)
41 {
42   Internal::ImageActorPtr internal;
43   if (image)
44   {
45     internal = Internal::ImageActor::New(&GetImplementation(image));
46   }
47   else
48   {
49     // empty image
50     internal = Internal::ImageActor::New(NULL);
51   }
52
53   return ImageActor(internal.Get());
54 }
55
56 ImageActor ImageActor::New(Image image, PixelArea pixelArea)
57 {
58   Internal::ImageActorPtr internal;
59   if (image)
60   {
61     internal = Internal::ImageActor::New(&GetImplementation(image), pixelArea);
62   }
63   else
64   {
65     // empty image
66     internal = Internal::ImageActor::New(NULL, pixelArea);
67   }
68
69   return ImageActor(internal.Get());
70 }
71
72 ImageActor ImageActor::DownCast( BaseHandle handle )
73 {
74   return ImageActor( dynamic_cast<Dali::Internal::ImageActor*>(handle.GetObjectPtr()) );
75 }
76
77 ImageActor::~ImageActor()
78 {
79 }
80
81 void ImageActor::SetImage(Image image)
82 {
83   if (image)
84   {
85     GetImplementation(*this).SetImage(&GetImplementation(image));
86   }
87   else
88   {
89     GetImplementation(*this).SetImage(NULL);
90   }
91 }
92
93 Image ImageActor::GetImage()
94 {
95   return GetImplementation(*this).GetImage();
96 }
97
98 void ImageActor::SetToNaturalSize()
99 {
100   GetImplementation(*this).SetToNaturalSize();
101 }
102
103 void ImageActor::SetPixelArea(const PixelArea& pixelArea)
104 {
105   GetImplementation(*this).SetPixelArea(pixelArea);
106 }
107
108 ImageActor::PixelArea ImageActor::GetPixelArea() const
109 {
110   return GetImplementation(*this).GetPixelArea();
111 }
112
113 bool ImageActor::IsPixelAreaSet() const
114 {
115   return GetImplementation(*this).IsPixelAreaSet();
116 }
117
118 void ImageActor::ClearPixelArea()
119 {
120   GetImplementation(*this).ClearPixelArea();
121 }
122
123 void ImageActor::SetStyle(Style style)
124 {
125   GetImplementation(*this).SetStyle(style);
126 }
127
128 ImageActor::Style ImageActor::GetStyle() const
129 {
130   return GetImplementation(*this).GetStyle();
131 }
132
133 void ImageActor::SetNinePatchBorder(const Vector4& border)
134 {
135   GetImplementation(*this).SetNinePatchBorder(border, true/*in pixels*/);
136 }
137
138 Vector4 ImageActor::GetNinePatchBorder() const
139 {
140   return GetImplementation(*this).GetNinePatchBorder();
141 }
142
143 void ImageActor::SetFadeIn(bool enableFade)
144 {
145   GetImplementation(*this).SetFadeIn(enableFade);
146 }
147
148 bool ImageActor::GetFadeIn() const
149 {
150   return GetImplementation(*this).GetFadeIn();
151 }
152
153 void ImageActor::SetFadeInDuration(float durationSeconds)
154 {
155   GetImplementation(*this).SetFadeInDuration(durationSeconds);
156 }
157
158 float ImageActor::GetFadeInDuration() const
159 {
160   return GetImplementation(*this).GetFadeInDuration();
161 }
162
163 Vector2 ImageActor::GetCurrentImageSize() const
164 {
165   return GetImplementation(*this).GetCurrentImageSize();
166 }
167
168 ImageActor::ImageActor(Internal::ImageActor* internal)
169 : RenderableActor(internal)
170 {
171 }
172
173 } // namespace Dali