1 #ifndef __DALI_TOOLKIT_INTERNAL_PUSH_BUTTON_H__
2 #define __DALI_TOOLKIT_INTERNAL_PUSH_BUTTON_H__
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/public-api/common/dali-vector.h>
23 #include <dali/public-api/animation/animation.h>
26 #include <dali-toolkit/public-api/controls/buttons/push-button.h>
27 #include "button-impl.h"
39 * PushButton implementation class.
41 * \sa Dali::Toolkit::PushButton
43 class PushButton : public Button
48 * Create a new PushButton.
49 * @return A smart-pointer to the newly allocated PushButton.
51 static Dali::Toolkit::PushButton New();
56 * Construct a new PushButton.
61 * A reference counted object may only be deleted by calling Unreference()
63 virtual ~PushButton();
65 private: // From Button
68 * @copydoc Toolkit::Internal::Button::OnButtonInitialize()
70 virtual void OnButtonInitialize();
73 * @copydoc Toolkit::Internal::Button::OnLabelSet()
75 virtual void OnLabelSet();
78 * @copydoc Toolkit::Internal::Button::OnButtonImageSet()
80 virtual void OnButtonImageSet();
83 * @copydoc Toolkit::Internal::Button::OnSelectedImageSet()
85 virtual void OnSelectedImageSet();
88 * @copydoc Toolkit::Internal::Button::OnBackgroundImage()
90 virtual void OnBackgroundImageSet();
93 * @copydoc Toolkit::Internal::Button::OnSelectedBackgroundImageSet()
95 virtual void OnSelectedBackgroundImageSet();
98 * @copydoc Toolkit::Internal::Button::OnDisabledImageSet()
100 virtual void OnDisabledImageSet();
103 * @copydoc Toolkit::Internal::Button::OnDisabledBackgroundImageSet()
105 virtual void OnDisabledBackgroundImageSet();
108 * @copydoc Toolkit::Internal::Button::OnSelected()
110 virtual bool OnSelected();
113 * @copydoc Toolkit::Internal::Button::OnDisabled()
115 virtual bool OnDisabled();
118 * @copydoc Toolkit::Internal::Button::OnPressed()
120 virtual bool OnPressed();
123 * @copydoc Toolkit::Internal::Button::OnReleased()
125 virtual bool OnReleased();
128 * @copydoc Toolkit::Internal::Button::StopAllAnimations()
130 virtual void StopAllAnimations();
132 private: // From Control
135 * @copydoc Toolkit::Control::OnControlSizeSet( const Vector3& targetSize )
137 virtual void OnControlSizeSet( const Vector3& targetSize );
140 * @copydoc Toolkit::Control::GetNaturalSize()
142 virtual Vector3 GetNaturalSize();
147 * Starts the transition animation.
148 * PushButton::TransitionAnimationFinished slot is called when the animation finishes.
150 void StartTransitionAnimation();
153 * Stops the transition animation.
154 * @param[in] remove If true, removes the fadeout actor from root.
156 void StopTransitionAnimation( bool remove = true );
159 * It adds the actor to the root actor and to the fade in animation.
160 * @param[inout] image The actor.
161 * @param[in] opacity The initial opacity.
162 * @param[in] scale The initial scale.
164 void FadeInImage( Actor& image, float opacity = 0.f, Vector3 scale = Vector3( 1.f, 1.f, 1.f ) );
167 * It adds the actor fade out animation and stores it to be removed when the animation finishes.
168 * @param[in] layer Defines if the actor is going to be stored in the mFadeOutBackgroundImage or mFadeOutCheckedImage member.
169 * @param[inout] image The actor.
170 * @param[in] opacity The initial opacity.
171 * @param[in] scale The initial scale.
173 void FadeOutImage( Actor& image, float opacity = 1.f, Vector3 scale = Vector3( 1.f, 1.f, 1.f ) );
178 * Called when the transition animation finishes.
180 void TransitionAnimationFinished( Dali::Animation& source );
185 PushButton( const PushButton& );
188 PushButton& operator=( const PushButton& );
192 Animation mTransitionAnimation; ///< Animation used in the state transitions.
193 Vector3 mSize; ///< The button's size.
196 } // namespace Internal
198 // Helpers for public-api forwarding methods
200 inline Toolkit::Internal::PushButton& GetImplementation( Toolkit::PushButton& button )
202 DALI_ASSERT_ALWAYS( button );
204 Dali::RefObject& handle = button.GetImplementation();
206 return static_cast<Toolkit::Internal::PushButton&>( handle );
209 inline const Toolkit::Internal::PushButton& GetImplementation( const Toolkit::PushButton& button )
211 DALI_ASSERT_ALWAYS( button );
213 const Dali::RefObject& handle = button.GetImplementation();
215 return static_cast<const Toolkit::Internal::PushButton&>( handle );
218 } // namespace Toolkit
222 #endif // __DALI_TOOLKIT_INTERNAL_PUSH_BUTTON_H__