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>
28 #include "push-button-painter-impl.h"
39 // Forward declarations
42 class PushButtonDefaultPainter;
46 typedef IntrusivePtr<PushButtonDefaultPainter> PushButtonDefaultPainterPtr;
49 * PushButtonDefaultPainter controls the Dali::Toolkit::PushButton appearance.
51 * This class inherits from Dali::Toolkit::Internal::PushButtonPainter and is registered in a
52 * Dali::Toolkit::Internal::PushButton object in order to receive the state changes.
54 class PushButtonDefaultPainter : public PushButtonPainter
61 * Set actors and animations to NULL.
63 PushButtonDefaultPainter();
68 * It clears all fade in or fade out animations.
70 ~PushButtonDefaultPainter();
72 /////////////////////////////////////////////////////////////////////////////
73 // ButtonPainter interface
74 /////////////////////////////////////////////////////////////////////////////
77 * @copydoc ButtonPainter::Initialize( Toolkit::Button& button )
79 virtual void Initialize( Toolkit::Button& button );
82 * @copydoc ButtonPainter::SetSize( Toolkit::Button& button, const Vector3& size )
84 virtual void SetSize( Toolkit::Button& button, const Vector3& size );
87 * @copydoc ButtonPainter::SetDisabled( Toolkit::Button& button, bool disabled )
89 virtual void SetDisabled( Toolkit::Button& button, bool disabled );
92 * @copydoc ButtonPainter::SetAnimationTime( float animationTime )
94 virtual void SetAnimationTime( float animationTime );
97 * @copydoc ButtonPainter::GetAnimationTime()
99 virtual float GetAnimationTime() const;
102 * @copydoc ButtonPainter::SetLabel( Toolkit::Button& button, Actor label )
104 virtual void SetLabel( Toolkit::Button& button, Actor label );
107 * @copydoc ButtonPainter::SetAutoRepeating( bool autorepeating )
109 virtual void SetAutoRepeating( bool autorepeating );
112 * @copydoc ButtonPainter::SetButtonImage( Toolkit::Button& button, Actor image )
114 virtual void SetButtonImage( Toolkit::Button& button, Actor image );
117 * @copydoc ButtonPainter::SetSelectedImage( Toolkit::Button& button, Actor image )
119 virtual void SetSelectedImage( Toolkit::Button& button, Actor image );
122 * @copydoc ButtonPainter::SetBackgroundImage( Toolkit::Button& button, Actor image )
124 virtual void SetBackgroundImage( Toolkit::Button& button, Actor image );
127 * @copydoc ButtonPainter::SetDisabledImage( Toolkit::Button& button, Actor image )
129 virtual void SetDisabledImage( Toolkit::Button& button, Actor image );
132 * @copydoc ButtonPainter::SetDisabledBackgroundImage( Toolkit::Button& button, Actor image )
134 virtual void SetDisabledBackgroundImage( Toolkit::Button& button, Actor image );
137 * @copydoc ButtonPainter::Pressed( Toolkit::Button& button )
139 void Pressed( Toolkit::Button& button );
142 * @copydoc ButtonPainter::Released( Toolkit::Button& button )
144 void Released( Toolkit::Button& button );
147 * @copydoc ButtonPainter::Clicked( Toolkit::Button& button )
149 void Clicked( Toolkit::Button& button );
152 * @copydoc ButtonPainter::Selected( Toolkit::Button& button )
154 void Selected( Toolkit::Button& button );
159 PushButtonDefaultPainter( const PushButtonDefaultPainter& );
162 PushButtonDefaultPainter& operator=( const PushButtonDefaultPainter& );
167 * Default push button painter states.
171 ReleasedState, ///< The push button is released.
172 PressedState, ///< The push button is pressed.
173 DisabledReleasedState, ///< The push button is disabled and released.
174 DisabledPressedState, ///< The push button is Disabled and pressed.
175 ReleasedPressedTransition, ///< The push button is in transition from released to pressed.
176 PressedReleasedTransition, ///< The push button is in transition from pressed to released.
177 ReleasedDisabledTransition, ///< The push button is in transition from released to disabled.
178 DisabledReleasedTransition, ///< The push button is in transition from disabled to released.
179 PressedDisabledTransition, ///< The push button is in transition from pressed to disabled.
180 DisabledPressedTransition ///< The push button is in transition from disabled to pressed.
184 * Used in the FadeOut functions.
188 Background, ///< Fade out the background.
189 Foreground ///< Fade out the foreground.
194 * Apply size and position constraints to painter actors.
196 * @param[inout] actor The actor.
197 * @param[in] depth Depth position.
199 void ApplyConstraint( Actor& actor, float depth );
202 * Adds the actor to the fade in animation. It creates a fade in animation if needed.
204 * @param[in] actor The actor.
206 void AddToFadeInAnimation( const Actor& actor );
209 * Starts the fade in animation.
211 * PushButtonDefaultPainter::PressedReleasedFadeInAnimationFinished slot is called when the animation finishes.
213 void StartFadeInAnimation();
216 * Stops the fade in animation.
218 void StopFadeInAnimation();
221 * Adds the actor to the fade out animation. It creates a fade out animation if needed.
223 void AddToFadeOutAnimation( const Actor& actor );
226 * Starts the fade out animation.
228 * PushButtonDefaultPainter::PressedReleasedFadeOutAnimationFinished slot is called when the animation finishes.
229 * @param[inout] pushButton The button which holds images.
231 void StartFadeOutAnimation( Toolkit::PushButton& pushButton );
234 * Stops the fade out animation.
236 * It removes the actor stored in PushButtonDefaultPainter::mFadeOutBackgroundImage and
237 * PushButtonDefaultPainter::mFadeOutCheckedImage.
239 * @param[inout] pushButton The button which holds images.
240 * @param[in] remove If true, removes the fadeout actor from root.
242 void StopFadeOutAnimation( Toolkit::PushButton& pushButton, bool remove = true );
245 * It adds the actor to the root actor and to the fade in animation.
247 * @param[inout] pushButton The button which holds images.
248 * @param[inout] image The actor.
249 * @param[in] opacity The initial opacity.
251 void FadeInImage( Toolkit::PushButton& pushButton, Actor& image, float opacity = 0.f );
254 * It adds the actor fade out animation and stores it to be removed when the animation finishes.
255 * @param[inout] pushButton The button which holds images.
256 * @param[in] layer Defines if the actor is going to be stored in the mFadeOutBackgroundImage or mFadeOutCheckedImage member.
257 * @param[inout] image The actor.
258 * @param[in] opacity The initial opacity.
260 void FadeOutImage( Toolkit::PushButton& pushButton, ImageLayer layer, Actor& image, float opacity = 1.f );
265 * Called when the fade out animation finishes.
267 * It changes the check button painter state and removes actors from the root.
269 void PressedReleasedFadeOutAnimationFinished( Dali::Animation& source );
272 * Called when the fade in animation finishes.
274 * It changes the check button painter state.
276 void PressedReleasedFadeInAnimationFinished( Dali::Animation& source );
279 bool mAutoRepeating; ///< Stores the autorepeating property.
280 bool mDisabled; ///< Stores the disabled property.
282 PaintState mPaintState; ///< The painter state.
283 Animation mFadeInAnimation; ///< Animation used in the state transitions.
284 Animation mFadeOutAnimation; ///< Animation used in the state transitions.
285 Internal::PushButton* mButton; ///< Temporary pointer used to remove fade out images from button.
286 float mAnimationTime; ///< The animation time.
287 Vector3 mSize; ///< The button's size.
290 } // namespace Internal
292 } // namespace Toolkit
296 #endif // __DALI_TOOLKIT_INTERNAL_PUSH_BUTTON_DEFAULT_PAINTER_H__