1 #ifndef __DALI_TOOLKIT_INTERNAL_PUSH_BUTTON_DEFAULT_PAINTER_H__
2 #define __DALI_TOOLKIT_INTERNAL_PUSH_BUTTON_DEFAULT_PAINTER_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/images/image.h>
23 #include <dali/public-api/actors/actor.h>
24 #include <dali/public-api/math/vector2.h>
25 #include <dali/public-api/animation/animation.h>
27 #include "push-button-painter-impl.h"
38 // Forward declarations
41 class PushButtonDefaultPainter;
45 typedef IntrusivePtr<PushButtonDefaultPainter> PushButtonDefaultPainterPtr;
48 * PushButtonDefaultPainter controls the Dali::Toolkit::PushButton appearance.
50 * This class inherits from Dali::Toolkit::Internal::PushButtonPainter and is registered in a
51 * Dali::Toolkit::Internal::PushButton object in order to receive the state changes.
53 class PushButtonDefaultPainter : public PushButtonPainter
60 * Set actors and animations to NULL.
62 PushButtonDefaultPainter();
67 * It clears all fade in or fade out animations.
69 ~PushButtonDefaultPainter();
71 /////////////////////////////////////////////////////////////////////////////
72 // ButtonPainter interface
73 /////////////////////////////////////////////////////////////////////////////
76 * @copydoc ButtonPainter::Initialize( Toolkit::Button& button )
78 virtual void Initialize( Toolkit::Button& button );
81 * @copydoc ButtonPainter::SetSize( Toolkit::Button& button, const Vector3& size )
83 virtual void SetSize( Toolkit::Button& button, const Vector3& size );
86 * @copydoc ButtonPainter::SetDisabled( Toolkit::Button& button, bool disabled )
88 virtual void SetDisabled( Toolkit::Button& button, bool disabled );
91 * @copydoc ButtonPainter::SetAnimationTime( float animationTime )
93 virtual void SetAnimationTime( float animationTime );
96 * @copydoc ButtonPainter::GetAnimationTime()
98 virtual float GetAnimationTime() const;
101 * @copydoc ButtonPainter::SetLabel( Toolkit::Button& button, Actor label )
103 virtual void SetLabel( Toolkit::Button& button, Actor label );
106 * @copydoc ButtonPainter::SetAutoRepeating( bool autorepeating )
108 virtual void SetAutoRepeating( bool autorepeating );
111 * @copydoc ButtonPainter::SetButtonImage( Toolkit::Button& button, Actor image )
113 virtual void SetButtonImage( Toolkit::Button& button, Actor image );
116 * @copydoc ButtonPainter::SetSelectedImage( Toolkit::Button& button, Actor image )
118 virtual void SetSelectedImage( Toolkit::Button& button, Actor image );
121 * @copydoc ButtonPainter::SetBackgroundImage( Toolkit::Button& button, Actor image )
123 virtual void SetBackgroundImage( Toolkit::Button& button, Actor image );
126 * @copydoc ButtonPainter::SetDisabledImage( Toolkit::Button& button, Actor image )
128 virtual void SetDisabledImage( Toolkit::Button& button, Actor image );
131 * @copydoc ButtonPainter::SetDisabledBackgroundImage( Toolkit::Button& button, Actor image )
133 virtual void SetDisabledBackgroundImage( Toolkit::Button& button, Actor image );
136 * @copydoc ButtonPainter::Pressed( Toolkit::Button& button )
138 void Pressed( Toolkit::Button& button );
141 * @copydoc ButtonPainter::Released( Toolkit::Button& button )
143 void Released( Toolkit::Button& button );
146 * @copydoc ButtonPainter::Clicked( Toolkit::Button& button )
148 void Clicked( Toolkit::Button& button );
151 * @copydoc ButtonPainter::Selected( Toolkit::Button& button )
153 void Selected( Toolkit::Button& button );
158 PushButtonDefaultPainter( const PushButtonDefaultPainter& );
161 PushButtonDefaultPainter& operator=( const PushButtonDefaultPainter& );
166 * Default push button painter states.
170 ReleasedState, ///< The push button is released.
171 PressedState, ///< The push button is pressed.
172 DisabledReleasedState, ///< The push button is disabled and released.
173 DisabledPressedState, ///< The push button is Disabled and pressed.
174 ReleasedPressedTransition, ///< The push button is in transition from released to pressed.
175 PressedReleasedTransition, ///< The push button is in transition from pressed to released.
176 ReleasedDisabledTransition, ///< The push button is in transition from released to disabled.
177 DisabledReleasedTransition, ///< The push button is in transition from disabled to released.
178 PressedDisabledTransition, ///< The push button is in transition from pressed to disabled.
179 DisabledPressedTransition ///< The push button is in transition from disabled to pressed.
183 * Used in the FadeOut functions.
187 Background, ///< Fade out the background.
188 Foreground ///< Fade out the foreground.
193 * Apply size and position constraints to painter actors.
195 * @param[inout] actor The actor.
196 * @param[in] depth Depth position.
198 void ApplyConstraint( Actor& actor, float depth );
201 * Adds the actor to the fade in animation. It creates a fade in animation if needed.
203 * @param[in] actor The actor.
205 void AddToFadeInAnimation( const Actor& actor );
208 * Starts the fade in animation.
210 * PushButtonDefaultPainter::PressedReleasedFadeInAnimationFinished slot is called when the animation finishes.
212 void StartFadeInAnimation();
215 * Stops the fade in animation.
217 void StopFadeInAnimation();
220 * Adds the actor to the fade out animation. It creates a fade out animation if needed.
222 void AddToFadeOutAnimation( const Actor& actor );
225 * Starts the fade out animation.
227 * PushButtonDefaultPainter::PressedReleasedFadeOutAnimationFinished slot is called when the animation finishes.
228 * @param[inout] pushButton The button which holds images.
230 void StartFadeOutAnimation( Toolkit::PushButton& pushButton );
233 * Stops the fade out animation.
235 * It removes the actor stored in PushButtonDefaultPainter::mFadeOutBackgroundImage and
236 * PushButtonDefaultPainter::mFadeOutCheckedImage.
238 * @param[inout] pushButton The button which holds images.
239 * @param[in] remove If true, removes the fadeout actor from root.
241 void StopFadeOutAnimation( Toolkit::PushButton& pushButton, bool remove = true );
244 * It adds the actor to the root actor and to the fade in animation.
246 * @param[inout] pushButton The button which holds images.
247 * @param[inout] image The actor.
248 * @param[in] opacity The initial opacity.
250 void FadeInImage( Toolkit::PushButton& pushButton, Actor& image, float opacity = 0.f );
253 * It adds the actor fade out animation and stores it to be removed when the animation finishes.
254 * @param[inout] pushButton The button which holds images.
255 * @param[in] layer Defines if the actor is going to be stored in the mFadeOutBackgroundImage or mFadeOutCheckedImage member.
256 * @param[inout] image The actor.
257 * @param[in] opacity The initial opacity.
259 void FadeOutImage( Toolkit::PushButton& pushButton, ImageLayer layer, Actor& image, float opacity = 1.f );
264 * Called when the fade out animation finishes.
266 * It changes the check button painter state and removes actors from the root.
268 void PressedReleasedFadeOutAnimationFinished( Dali::Animation& source );
271 * Called when the fade in animation finishes.
273 * It changes the check button painter state.
275 void PressedReleasedFadeInAnimationFinished( Dali::Animation& source );
278 bool mAutoRepeating; ///< Stores the autorepeating property.
279 bool mDisabled; ///< Stores the disabled property.
281 PaintState mPaintState; ///< The painter state.
282 Animation mFadeInAnimation; ///< Animation used in the state transitions.
283 Animation mFadeOutAnimation; ///< Animation used in the state transitions.
284 Internal::PushButton* mButton; ///< Temporary pointer used to remove fade out images from button.
285 float mAnimationTime; ///< The animation time.
286 Vector3 mSize; ///< The button's size.
289 } // namespace Internal
291 } // namespace Toolkit
295 #endif // __DALI_TOOLKIT_INTERNAL_PUSH_BUTTON_DEFAULT_PAINTER_H__