2 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
20 #include <dali-toolkit/public-api/controls/buttons/button.h>
24 #include <dali-toolkit/internal/controls/buttons/button-impl.h>
27 #include <dali/public-api/actors/image-actor.h>
38 Button::Button( const Button& button )
43 Button& Button::operator=( const Button& button )
47 Control::operator=( button );
56 Button Button::DownCast( BaseHandle handle )
58 return Control::DownCast<Button, Internal::Button>(handle);
61 void Button::SetDisabled( bool disabled )
63 Dali::Toolkit::GetImplementation( *this ).SetDisabled( disabled );
66 bool Button::IsDisabled() const
68 return Dali::Toolkit::GetImplementation( *this ).IsDisabled();
71 void Button::SetAutoRepeating( bool autoRepeating )
73 Dali::Toolkit::GetImplementation( *this ).SetAutoRepeating( autoRepeating );
76 bool Button::IsAutoRepeating() const
78 return Dali::Toolkit::GetImplementation( *this ).IsAutoRepeating();
81 void Button::SetInitialAutoRepeatingDelay( float initialAutoRepeatingDelay )
83 Dali::Toolkit::GetImplementation( *this ).SetInitialAutoRepeatingDelay( initialAutoRepeatingDelay );
86 float Button::GetInitialAutoRepeatingDelay() const
88 return Dali::Toolkit::GetImplementation( *this ).GetInitialAutoRepeatingDelay();
91 void Button::SetNextAutoRepeatingDelay( float nextAutoRepeatingDelay )
93 Dali::Toolkit::GetImplementation( *this ).SetNextAutoRepeatingDelay( nextAutoRepeatingDelay );
96 float Button::GetNextAutoRepeatingDelay() const
98 return Dali::Toolkit::GetImplementation( *this ).GetNextAutoRepeatingDelay();
101 void Button::SetTogglableButton( bool togglable )
103 Dali::Toolkit::GetImplementation( *this ).SetTogglableButton( togglable );
106 bool Button::IsTogglableButton() const
108 return Dali::Toolkit::GetImplementation( *this ).IsTogglableButton();
111 void Button::SetSelected( bool selected )
113 Dali::Toolkit::GetImplementation( *this ).SetSelected( selected );
116 bool Button::IsSelected() const
118 return Dali::Toolkit::GetImplementation( *this ).IsSelected();
121 void Button::SetAnimationTime( float animationTime )
123 Dali::Toolkit::GetImplementation( *this ).SetAnimationTime( animationTime );
126 float Button::GetAnimationTime() const
128 return Dali::Toolkit::GetImplementation( *this ).GetAnimationTime();
131 void Button::SetLabel( const std::string& label )
133 Dali::Toolkit::GetImplementation( *this ).SetLabel( label );
136 void Button::SetLabel( Actor label )
138 Dali::Toolkit::GetImplementation( *this ).SetLabel( label );
141 Actor Button::GetLabel() const
143 return Dali::Toolkit::GetImplementation( *this ).GetLabel();
146 void Button::SetButtonImage( Image image )
148 Actor imageActor = ImageActor::New( image );
149 Dali::Toolkit::GetImplementation( *this ).SetButtonImage( imageActor );
152 void Button::SetBackgroundImage( Image image )
154 Actor imageActor = ImageActor::New( image );
155 Dali::Toolkit::GetImplementation( *this ).SetBackgroundImage( imageActor );
158 void Button::SetSelectedImage( Image image )
160 Actor imageActor = ImageActor::New( image );
161 imageActor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
162 Dali::Toolkit::GetImplementation( *this ).SetSelectedImage( imageActor );
165 void Button::SetSelectedBackgroundImage( Image image )
167 Dali::Toolkit::GetImplementation( *this ).SetSelectedBackgroundImage( ImageActor::New( image ) );
170 void Button::SetDisabledBackgroundImage( Image image )
172 Actor imageActor = ImageActor::New( image );
173 imageActor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
174 Dali::Toolkit::GetImplementation( *this ).SetDisabledBackgroundImage( imageActor );
177 void Button::SetDisabledImage( Image image )
179 Actor imageActor = ImageActor::New( image );
180 imageActor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
181 Dali::Toolkit::GetImplementation( *this ).SetDisabledImage( imageActor );
184 void Button::SetDisabledSelectedImage( Image image )
186 Actor imageActor = ImageActor::New( image );
187 imageActor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
188 Dali::Toolkit::GetImplementation( *this ).SetDisabledSelectedImage( imageActor );
191 Button::ButtonSignalType& Button::PressedSignal()
193 return Dali::Toolkit::GetImplementation( *this ).PressedSignal();
196 Button::ButtonSignalType& Button::ReleasedSignal()
198 return Dali::Toolkit::GetImplementation( *this ).ReleasedSignal();
201 Button::ButtonSignalType& Button::ClickedSignal()
203 return Dali::Toolkit::GetImplementation( *this ).ClickedSignal();
206 Button::ButtonSignalType& Button::StateChangedSignal()
208 return Dali::Toolkit::GetImplementation( *this ).StateChangedSignal();
211 Button::Button( Internal::Button& implementation )
212 : Control( implementation )
216 Button::Button( Dali::Internal::CustomActor* internal )
217 : Control( internal )
219 VerifyCustomActorPointer<Internal::Button>(internal);
222 } // namespace Toolkit