Add ResourceReady for Control
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / public-api / controls / control.cpp
1 /*
2  * Copyright (c) 2022 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-toolkit/public-api/controls/control.h>
20
21 // EXTERNAL INCLUDES
22 #include <dali/integration-api/debug.h>
23
24 // INTERNAL INCLUDES
25 #include <dali-toolkit/internal/controls/control/control-data-impl.h>
26 #include <dali-toolkit/public-api/controls/control-impl.h>
27
28 namespace Dali
29 {
30 namespace Toolkit
31 {
32 Control Control::New()
33 {
34   return Toolkit::Internal::Control::New();
35 }
36
37 Control Control::New(ControlBehaviour additionalBehaviour)
38 {
39   return Toolkit::Internal::Control::New(static_cast<Toolkit::Internal::Control::ControlBehaviour>(additionalBehaviour));
40 }
41
42 Control::Control()
43 {
44 }
45
46 Control::Control(const Control& uiControl) = default;
47
48 Control::Control(Control&& rhs) = default;
49
50 Control::~Control()
51 {
52 }
53
54 Control& Control::operator=(const Control& handle) = default;
55
56 Control& Control::operator=(Control&& rhs) = default;
57
58 Control Control::DownCast(BaseHandle handle)
59 {
60   return DownCast<Control, Internal::Control>(handle);
61 }
62
63 void Control::SetKeyInputFocus()
64 {
65   Internal::GetImplementation(*this).SetKeyInputFocus();
66 }
67
68 bool Control::HasKeyInputFocus()
69 {
70   return Internal::GetImplementation(*this).HasKeyInputFocus();
71 }
72
73 void Control::ClearKeyInputFocus()
74 {
75   Internal::GetImplementation(*this).ClearKeyInputFocus();
76 }
77
78 PinchGestureDetector Control::GetPinchGestureDetector() const
79 {
80   return Internal::GetImplementation(*this).GetPinchGestureDetector();
81 }
82
83 PanGestureDetector Control::GetPanGestureDetector() const
84 {
85   return Internal::GetImplementation(*this).GetPanGestureDetector();
86 }
87
88 TapGestureDetector Control::GetTapGestureDetector() const
89 {
90   return Internal::GetImplementation(*this).GetTapGestureDetector();
91 }
92
93 LongPressGestureDetector Control::GetLongPressGestureDetector() const
94 {
95   return Internal::GetImplementation(*this).GetLongPressGestureDetector();
96 }
97
98 void Control::SetStyleName(const std::string& styleName)
99 {
100   Internal::GetImplementation(*this).SetStyleName(styleName);
101 }
102
103 const std::string& Control::GetStyleName() const
104 {
105   return Internal::GetImplementation(*this).GetStyleName();
106 }
107
108 void Control::SetBackgroundColor(const Vector4& color)
109 {
110   Internal::GetImplementation(*this).SetBackgroundColor(color);
111 }
112
113 void Control::ClearBackground()
114 {
115   Internal::GetImplementation(*this).ClearBackground();
116 }
117
118 bool Control::IsResourceReady() const
119 {
120   return Internal::GetImplementation(*this).IsResourceReady();
121 }
122
123 Toolkit::Visual::ResourceStatus Control::GetVisualResourceStatus(Dali::Property::Index index)
124 {
125   const Internal::Control&       internalControl = Toolkit::Internal::GetImplementation(*this);
126   const Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get(internalControl);
127   return controlDataImpl.GetVisualResourceStatus(index);
128 }
129
130 Control::KeyEventSignalType& Control::KeyEventSignal()
131 {
132   return Internal::GetImplementation(*this).KeyEventSignal();
133 }
134
135 Control::KeyInputFocusSignalType& Control::KeyInputFocusGainedSignal()
136 {
137   return Internal::GetImplementation(*this).KeyInputFocusGainedSignal();
138 }
139
140 Control::KeyInputFocusSignalType& Control::KeyInputFocusLostSignal()
141 {
142   return Internal::GetImplementation(*this).KeyInputFocusLostSignal();
143 }
144
145 Control::ResourceReadySignalType& Control::ResourceReadySignal()
146 {
147   Internal::Control&       internalControl = Toolkit::Internal::GetImplementation(*this);
148   Internal::Control::Impl& controlImpl     = Internal::Control::Impl::Get(internalControl);
149
150   return controlImpl.mResourceReadySignal;
151 }
152
153 Control::Control(Internal::Control& implementation)
154 : CustomActor(implementation)
155 {
156 }
157
158 Control::Control(Dali::Internal::CustomActor* internal)
159 : CustomActor(internal)
160 {
161   VerifyCustomActorPointer<Internal::Control>(internal);
162 }
163
164 } // namespace Toolkit
165
166 } // namespace Dali