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/vector-wrapper.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 CustomActorImpl::OnSizeSet( const Vector3& targetSize )
137 virtual void OnSizeSet( const Vector3& targetSize );
140 * @copydoc Toolkit::Control::GetNaturalSize
142 virtual Vector3 GetNaturalSize();
145 * @copydoc Toolkit::Control::OnSetResizePolicy
147 virtual void OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension );
152 * Starts the transition animation.
153 * PushButton::TransitionAnimationFinished slot is called when the animation finishes.
155 void StartTransitionAnimation();
158 * Stops the transition animation.
159 * @param[in] remove If true, removes the fadeout actor from root.
161 void StopTransitionAnimation( bool remove = true );
164 * It adds the actor to the root actor and to the fade in animation.
165 * @param[inout] image The actor.
166 * @param[in] opacity The initial opacity.
167 * @param[in] scale The initial scale.
169 void FadeInImage( Actor& image, float opacity = 0.f, Vector3 scale = Vector3( 1.f, 1.f, 1.f ) );
172 * It adds the actor fade out animation and stores it to be removed when the animation finishes.
173 * @param[in] layer Defines if the actor is going to be stored in the mFadeOutBackgroundImage or mFadeOutCheckedImage member.
174 * @param[inout] image The actor.
175 * @param[in] opacity The initial opacity.
176 * @param[in] scale The initial scale.
178 void FadeOutImage( Actor& image, float opacity = 1.f, Vector3 scale = Vector3( 1.f, 1.f, 1.f ) );
181 * @brief Custom configuration for size negotiation
183 void ConfigureSizeNegotiation();
186 * @brief Configure size negotiation for a given dimension
188 * @param[in] dimension The dimension to configure
189 * @param[in] images The list of images to configure
190 * @param[in] label The text label to configure
192 void ConfigureSizeNegotiationDimension( Dimension::Type dimension, const std::vector< Actor >& images, Actor& label );
197 * Called when the transition animation finishes.
199 void TransitionAnimationFinished( Dali::Animation& source );
204 PushButton( const PushButton& );
207 PushButton& operator=( const PushButton& );
211 Animation mTransitionAnimation; ///< Animation used in the state transitions.
212 Vector3 mSize; ///< The button's size.
215 } // namespace Internal
217 // Helpers for public-api forwarding methods
219 inline Toolkit::Internal::PushButton& GetImplementation( Toolkit::PushButton& button )
221 DALI_ASSERT_ALWAYS( button );
223 Dali::RefObject& handle = button.GetImplementation();
225 return static_cast<Toolkit::Internal::PushButton&>( handle );
228 inline const Toolkit::Internal::PushButton& GetImplementation( const Toolkit::PushButton& button )
230 DALI_ASSERT_ALWAYS( button );
232 const Dali::RefObject& handle = button.GetImplementation();
234 return static_cast<const Toolkit::Internal::PushButton&>( handle );
237 } // namespace Toolkit
241 #endif // __DALI_TOOLKIT_INTERNAL_PUSH_BUTTON_H__