(ScrollView) Updates to scroll view internals to improve responsiveness and smoothnes...
[platform/core/uifw/dali-toolkit.git] / base / dali-toolkit / public-api / controls / control.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 #include <dali-toolkit/public-api/controls/control.h>
19 #include <dali-toolkit/public-api/controls/control-impl.h>
20
21 namespace Dali
22 {
23
24 namespace Toolkit
25 {
26
27 const char* const Control::ACTION_CONTROL_ACTIVATED = "control-activated";
28 const char* const Control::SIGNAL_KEY_EVENT = "key-event";
29
30 Control Control::New()
31 {
32   return Internal::Control::New();
33 }
34
35 Control::Control()
36 {
37 }
38
39 Control::Control(const Control& uiControl)
40 : CustomActor( uiControl ? static_cast< const Internal::Control& >( uiControl.GetImplementation() ).GetOwner() : NULL)
41 {
42 }
43
44 Control::~Control()
45 {
46 }
47
48 Control& Control::operator=( const Control& handle )
49 {
50   if( &handle != this )
51   {
52     CustomActor::operator=( handle );
53   }
54   return *this;
55 }
56
57 Control Control::DownCast( BaseHandle handle )
58 {
59   return DownCast< Control, Internal::Control >(handle);
60 }
61
62 Internal::Control& Control::GetImplementation()
63 {
64   return static_cast<Internal::Control&>(CustomActor::GetImplementation());
65 }
66
67 const Internal::Control& Control::GetImplementation() const
68 {
69   return static_cast<const Internal::Control&>(CustomActor::GetImplementation());
70 }
71
72 void Control::SetSizePolicy( SizePolicy widthPolicy, SizePolicy heightPolicy )
73 {
74   GetImplementation().SetSizePolicy( widthPolicy, heightPolicy );
75 }
76
77 void Control::GetSizePolicy( SizePolicy& widthPolicy, SizePolicy& heightPolicy ) const
78 {
79   GetImplementation().GetSizePolicy( widthPolicy, heightPolicy );
80 }
81
82 void Control::SetMinimumSize( const Vector3& size )
83 {
84   GetImplementation().SetMinimumSize( size );
85 }
86
87 const Vector3& Control::GetMinimumSize() const
88 {
89   return GetImplementation().GetMinimumSize();
90 }
91
92 void Control::SetMaximumSize( const Vector3& size )
93 {
94   GetImplementation().SetMaximumSize( size );
95 }
96
97 const Vector3& Control::GetMaximumSize() const
98 {
99   return GetImplementation().GetMaximumSize();
100 }
101
102 Vector3 Control::GetNaturalSize()
103 {
104   return GetImplementation().GetNaturalSize();
105 }
106
107 float Control::GetHeightForWidth( float width )
108 {
109   return GetImplementation().GetHeightForWidth( width );
110 }
111
112 float Control::GetWidthForHeight( float height )
113 {
114   return GetImplementation().GetWidthForHeight( height );
115 }
116
117 void Control::SetKeyInputFocus()
118 {
119   GetImplementation().SetKeyInputFocus();
120 }
121
122 bool Control::HasKeyInputFocus()
123 {
124   return GetImplementation().HasKeyInputFocus();
125 }
126
127 void Control::ClearKeyInputFocus()
128 {
129   GetImplementation().ClearKeyInputFocus();
130 }
131
132 PinchGestureDetector Control::GetPinchGestureDetector() const
133 {
134   return GetImplementation().GetPinchGestureDetector();
135 }
136
137 PanGestureDetector Control::GetPanGestureDetector() const
138 {
139   return GetImplementation().GetPanGestureDetector();
140 }
141
142 TapGestureDetector Control::GetTapGestureDetector() const
143 {
144   return GetImplementation().GetTapGestureDetector();
145 }
146
147 LongPressGestureDetector Control::GetLongPressGestureDetector() const
148 {
149   return GetImplementation().GetLongPressGestureDetector();
150 }
151
152 void Control::SetBackgroundColor( const Vector4& color )
153 {
154   GetImplementation().SetBackgroundColor( color );
155 }
156
157 Vector4 Control::GetBackgroundColor() const
158 {
159   return GetImplementation().GetBackgroundColor();
160 }
161
162 void Control::SetBackground( Image image )
163 {
164   GetImplementation().SetBackground( image );
165 }
166
167 void Control::ClearBackground()
168 {
169   GetImplementation().ClearBackground();
170 }
171
172 Actor Control::GetBackgroundActor() const
173 {
174   return GetImplementation().GetBackgroundActor();
175 }
176
177 Control::KeyEventSignalV2& Control::KeyEventSignal()
178 {
179   return GetImplementation().KeyEventSignal();
180 }
181
182 /**
183  * @copydoc ConnectionTrackerInterface::SignalConnected
184  */
185 void Control::SignalConnected( SlotObserver* slotObserver, CallbackBase* callback )
186 {
187   GetImplementation().SignalConnected(slotObserver, callback );
188 }
189
190 /**
191  * @copydoc ConnectionTrackerInterface::SignalDisconnected
192  */
193 void Control::SignalDisconnected( SlotObserver* slotObserver, CallbackBase* callback )
194 {
195   GetImplementation().SignalDisconnected(slotObserver, callback );
196 }
197
198 /**
199  * @copydoc ConnectionTrackerInterface::GetConnectionCount
200  */
201 std::size_t Control::GetConnectionCount() const
202 {
203   return GetImplementation().GetConnectionCount( );
204 }
205
206
207 Control::Control(Internal::Control& implementation)
208 : CustomActor(implementation)
209 {
210 }
211
212 Control::Control(Dali::Internal::CustomActor* internal)
213 : CustomActor(internal)
214 {
215   VerifyCustomActorPointer<Internal::Control>(internal);
216 }
217
218 } // namespace Toolkit
219
220 } // namespace Dali