Moved PushButton::SetButtonImage etc to Button base class.
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / public-api / controls / buttons / button.cpp
1 /*
2  * Copyright (c) 2015 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
20 #include <dali-toolkit/public-api/controls/buttons/button.h>
21
22 // INTERNAL INCLUDES
23
24 #include <dali-toolkit/internal/controls/buttons/button-impl.h>
25
26 // EXTERNAL INCLUDES
27 #include <dali/public-api/actors/image-actor.h>
28
29 namespace Dali
30 {
31
32 namespace Toolkit
33 {
34
35 Button::Button()
36 {}
37
38 Button::Button( const Button& button )
39 : Control( button )
40 {
41 }
42
43 Button& Button::operator=( const Button& button )
44 {
45   if( &button != this )
46   {
47     Control::operator=( button );
48   }
49   return *this;
50 }
51
52 Button::~Button()
53 {
54 }
55
56 Button Button::DownCast( BaseHandle handle )
57 {
58   return Control::DownCast<Button, Internal::Button>(handle);
59 }
60
61 void Button::SetDisabled( bool disabled )
62 {
63   Dali::Toolkit::GetImplementation( *this ).SetDisabled( disabled );
64 }
65
66 bool Button::IsDisabled() const
67 {
68   return Dali::Toolkit::GetImplementation( *this ).IsDisabled();
69 }
70
71 void Button::SetAutoRepeating( bool autoRepeating )
72 {
73   Dali::Toolkit::GetImplementation( *this ).SetAutoRepeating( autoRepeating );
74 }
75
76 bool Button::IsAutoRepeating() const
77 {
78   return Dali::Toolkit::GetImplementation( *this ).IsAutoRepeating();
79 }
80
81 void Button::SetInitialAutoRepeatingDelay( float initialAutoRepeatingDelay )
82 {
83   Dali::Toolkit::GetImplementation( *this ).SetInitialAutoRepeatingDelay( initialAutoRepeatingDelay );
84 }
85
86 float Button::GetInitialAutoRepeatingDelay() const
87 {
88   return Dali::Toolkit::GetImplementation( *this ).GetInitialAutoRepeatingDelay();
89 }
90
91 void Button::SetNextAutoRepeatingDelay( float nextAutoRepeatingDelay )
92 {
93   Dali::Toolkit::GetImplementation( *this ).SetNextAutoRepeatingDelay( nextAutoRepeatingDelay );
94 }
95
96 float Button::GetNextAutoRepeatingDelay() const
97 {
98   return Dali::Toolkit::GetImplementation( *this ).GetNextAutoRepeatingDelay();
99 }
100
101 void Button::SetTogglableButton( bool togglable )
102 {
103   Dali::Toolkit::GetImplementation( *this ).SetTogglableButton( togglable );
104 }
105
106 bool Button::IsTogglableButton() const
107 {
108   return Dali::Toolkit::GetImplementation( *this ).IsTogglableButton();
109 }
110
111 void Button::SetSelected( bool selected )
112 {
113   Dali::Toolkit::GetImplementation( *this ).SetSelected( selected );
114 }
115
116 bool Button::IsSelected() const
117 {
118   return Dali::Toolkit::GetImplementation( *this ).IsSelected();
119 }
120
121 void Button::SetAnimationTime( float animationTime )
122 {
123   Dali::Toolkit::GetImplementation( *this ).SetAnimationTime( animationTime );
124 }
125
126 float Button::GetAnimationTime() const
127 {
128   return Dali::Toolkit::GetImplementation( *this ).GetAnimationTime();
129 }
130
131 void Button::SetLabel( const std::string& label )
132 {
133   Dali::Toolkit::GetImplementation( *this ).SetLabel( label );
134 }
135
136 void Button::SetLabel( Actor label )
137 {
138   Dali::Toolkit::GetImplementation( *this ).SetLabel( label );
139 }
140
141 Actor Button::GetLabel() const
142 {
143   return Dali::Toolkit::GetImplementation( *this ).GetLabel();
144 }
145
146 void Button::SetButtonImage( Image image )
147 {
148   Actor imageActor = ImageActor::New( image );
149   Dali::Toolkit::GetImplementation( *this ).SetButtonImage( imageActor );
150 }
151
152 void Button::SetBackgroundImage( Image image )
153 {
154   Actor imageActor = ImageActor::New( image );
155   Dali::Toolkit::GetImplementation( *this ).SetBackgroundImage( imageActor );
156 }
157
158 void Button::SetSelectedImage( Image image )
159 {
160   Actor imageActor = ImageActor::New( image );
161   imageActor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
162   Dali::Toolkit::GetImplementation( *this ).SetSelectedImage( imageActor );
163 }
164
165 void Button::SetSelectedBackgroundImage( Image image )
166 {
167   Dali::Toolkit::GetImplementation( *this ).SetSelectedBackgroundImage( ImageActor::New( image ) );
168 }
169
170 void Button::SetDisabledBackgroundImage( Image image )
171 {
172   Actor imageActor = ImageActor::New( image );
173   imageActor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
174   Dali::Toolkit::GetImplementation( *this ).SetDisabledBackgroundImage( imageActor );
175 }
176
177 void Button::SetDisabledImage( Image image )
178 {
179   Actor imageActor = ImageActor::New( image );
180   imageActor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
181   Dali::Toolkit::GetImplementation( *this ).SetDisabledImage( imageActor );
182 }
183
184 void Button::SetDisabledSelectedImage( Image image )
185 {
186   Actor imageActor = ImageActor::New( image );
187   imageActor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
188   Dali::Toolkit::GetImplementation( *this ).SetDisabledSelectedImage( imageActor );
189 }
190
191 Button::ButtonSignalType& Button::PressedSignal()
192 {
193   return Dali::Toolkit::GetImplementation( *this ).PressedSignal();
194 }
195
196 Button::ButtonSignalType& Button::ReleasedSignal()
197 {
198   return Dali::Toolkit::GetImplementation( *this ).ReleasedSignal();
199 }
200
201 Button::ButtonSignalType& Button::ClickedSignal()
202 {
203   return Dali::Toolkit::GetImplementation( *this ).ClickedSignal();
204 }
205
206 Button::ButtonSignalType& Button::StateChangedSignal()
207 {
208   return Dali::Toolkit::GetImplementation( *this ).StateChangedSignal();
209 }
210
211 Button::Button( Internal::Button& implementation )
212 : Control( implementation )
213 {
214 }
215
216 Button::Button( Dali::Internal::CustomActor* internal )
217 : Control( internal )
218 {
219   VerifyCustomActorPointer<Internal::Button>(internal);
220 }
221
222 } // namespace Toolkit
223
224 } // namespace Dali