993faefe00934b598bedf4a490dd9490c2ae7fae
[platform/core/uifw/dali-adaptor.git] / dali / internal / canvas-renderer / common / drawable-impl.cpp
1 /*
2  * Copyright (c) 2021 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/internal/canvas-renderer/common/drawable-factory.h>
20 #include <dali/internal/canvas-renderer/common/drawable-impl.h>
21
22 namespace Dali
23 {
24 namespace Internal
25 {
26 namespace Adaptor
27 {
28 Drawable::Drawable() = default;
29
30 Drawable::~Drawable()
31 {
32   if(pImpl)
33   {
34     delete pImpl;
35   }
36 }
37
38 void Drawable::Create()
39 {
40   if(!pImpl)
41   {
42     pImpl = Internal::Adaptor::DrawableFactory::New();
43   }
44 }
45
46 bool Drawable::SetOpacity(float opacity)
47 {
48   if(!pImpl)
49   {
50     return false;
51   }
52   return pImpl->SetOpacity(opacity);
53 }
54
55 float Drawable::GetOpacity() const
56 {
57   if(!pImpl)
58   {
59     return 0.0f;
60   }
61   return pImpl->GetOpacity();
62 }
63
64 bool Drawable::Rotate(Degree degree)
65 {
66   if(!pImpl)
67   {
68     return false;
69   }
70   return pImpl->Rotate(degree);
71 }
72
73 bool Drawable::Scale(float factor)
74 {
75   if(!pImpl)
76   {
77     return false;
78   }
79   return pImpl->Scale(factor);
80 }
81
82 bool Drawable::Translate(Vector2 translate)
83 {
84   if(!pImpl)
85   {
86     return false;
87   }
88   return pImpl->Translate(translate);
89 }
90
91 bool Drawable::Transform(const Dali::Matrix3& matrix)
92 {
93   if(!pImpl)
94   {
95     return false;
96   }
97   return pImpl->Transform(matrix);
98 }
99
100 Rect<float> Drawable::GetBoundingBox() const
101 {
102   if(!pImpl)
103   {
104     return Rect<float>(0, 0, 0, 0);
105   }
106   return pImpl->GetBoundingBox();
107 }
108
109 void Drawable::SetAdded(bool added)
110 {
111   if(!pImpl)
112   {
113     return;
114   }
115   pImpl->SetAdded(added);
116 }
117
118 bool Drawable::IsAdded() const
119 {
120   if(!pImpl)
121   {
122     return false;
123   }
124   return pImpl->IsAdded();
125 }
126
127 void* Drawable::GetObject() const
128 {
129   if(!pImpl)
130   {
131     return nullptr;
132   }
133   return pImpl->GetObject();
134 }
135
136 void Drawable::SetObject(const void* object)
137 {
138   if(!pImpl)
139   {
140     return;
141   }
142   pImpl->SetObject(object);
143 }
144
145 void Drawable::SetChanged(bool changed)
146 {
147   if(!pImpl)
148   {
149     return;
150   }
151   pImpl->SetChanged(changed);
152 }
153
154 bool Drawable::GetChanged() const
155 {
156   if(!pImpl)
157   {
158     return false;
159   }
160   return pImpl->GetChanged();
161 }
162
163 Dali::Internal::Adaptor::Drawable* Drawable::GetImplementation()
164 {
165   return pImpl;
166 }
167
168 } // namespace Adaptor
169
170 } // namespace Internal
171
172 } // namespace Dali