1 #ifndef __DALI_TOOLKIT_INTERNAL_CHECK_BOX_BUTTON_DEFAULT_PAINTER_H__
2 #define __DALI_TOOLKIT_INTERNAL_CHECK_BOX_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 <dali-toolkit/public-api/shader-effects/image-region-effect.h>
29 #include "check-box-button-painter-impl.h"
40 // Forward declarations
43 class CheckBoxButtonDefaultPainter;
47 typedef IntrusivePtr<CheckBoxButtonDefaultPainter> CheckBoxButtonDefaultPainterPtr;
50 * CheckBoxButtonDefaultPainter controls the Dali::Toolkit::CheckBoxButton appearance.
52 * This class inherits from Dali::Toolkit::Internal::CheckBoxButtonPainter and is registered in a
53 * Dali::Toolkit::Internal::CheckBoxButton object in order to receive the state changes.
55 class CheckBoxButtonDefaultPainter : public CheckBoxButtonPainter
61 * Set actors and animations to NULL.
63 CheckBoxButtonDefaultPainter();
68 * It clears all fade in or fade out animations.
70 ~CheckBoxButtonDefaultPainter();
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::SetSelectedImage( Toolkit::Button& button, Actor image )
104 virtual void SetSelectedImage( Toolkit::Button& button, Actor image );
107 * @copydoc ButtonPainter::SetBackgroundImage( Toolkit::Button& button, Actor image )
109 virtual void SetBackgroundImage( Toolkit::Button& button, Actor image );
112 * @copydoc ButtonPainter::SetDisabledSelectedImage( Toolkit::Button& button, Actor image )
114 virtual void SetDisabledSelectedImage( Toolkit::Button& button, Actor image );
117 * @copydoc ButtonPainter::SetDisabledBackgroundImage( Toolkit::Button& button, Actor image )
119 virtual void SetDisabledBackgroundImage( Toolkit::Button& button, Actor image );
121 /////////////////////////////////////////////////////////////////////////////
122 // CheckBoxButtonPainter interface
123 /////////////////////////////////////////////////////////////////////////////
126 * This method is called when the Dali::Toolkit::Internal::CheckBoxButton in which this object is registered
129 * @param[inout] checkBox The Dali::Toolkit::CheckBoxButton in which this object is registered.
131 void Selected( Toolkit::Button& checkBox );
136 CheckBoxButtonDefaultPainter( const CheckBoxButtonDefaultPainter& );
139 CheckBoxButtonDefaultPainter& operator=( const CheckBoxButtonDefaultPainter& );
144 * Default check box button painter states.
148 UnselectedState, ///< The check box button is unselected.
149 SelectedState, ///< The check box button is selected.
150 DisabledUnselectedState, ///< The check box button is disabled and unselected.
151 DisabledSelectedState, ///< The check box button is disabled and selected.
152 UnselectedSelectedTransition, ///< The check box button is in transition from unselected to selected.
153 SelectedUnselectedTransition, ///< The check box button is in transition from selected to unselected.
154 UnselectedDisabledTransition, ///< The check box button is in transition from unselected to disabled.
155 DisabledUnselectedTransition, ///< The check box button is in transition from disabled to unselected.
156 SelectedDisabledTransition, ///< The check box button is in transition from selected to disabled.
157 DisabledSelectedTransition ///< The check box button is in transition from disabled to selected.
161 * Used in the FadeOut functions.
165 Background, ///< Fade out the background.
166 Foreground ///< Fade out the foreground.
171 * Apply size and position constraints to painter actors.
173 * @param[inout] actor The actor.
174 * @param[in] depth Depth position.
176 void ApplyConstraint( Actor& actor, float depth );
179 * Apply size constraint to check tick
181 * @param[inout] actor The actor.
182 * @param[in] depth Depth position.
184 void ApplySelectedConstraint( Actor& actor, float depth );
187 * Adds the actor to the fade in animation. It creates a fade in animation if needed.
189 * @param[in] actor The actor.
191 void AddToFadeInAnimation( const Actor& actor );
194 * Starts the check in animation.
196 * CheckBoxButtonDefaultPainter::CheckInAnimationFinished slot is called when the animation finishes.
198 void StartCheckInAnimation();
201 * Stops the check in animation.
203 void StopCheckInAnimation();
206 * Adds the actor to the fade out animation. It creates a fade out animation if needed.
208 * @param[in] actor The actor.
210 void AddToFadeOutAnimation( const Actor& actor );
213 * Starts the check out animation.
215 * CheckBoxButtonDefaultPainter::CheckOutAnimationFinished slot is called when the animation finishes.
217 * @param[inout] checkBox The button which holds images.
219 void StartCheckOutAnimation( Toolkit::CheckBoxButton& checkBox );
222 * Stops the fade out animation.
224 * It removes the actor stored in CheckBoxButtonDefaultPainter::mFadeOutBackgroundImage and
225 * CheckBoxButtonDefaultPainter::mFadeOutSelectedImage.
227 * @param[inout] checkBox The button which holds images.
228 * @param[in] remove If true, removes the fadeout actor from root.
230 void StopCheckOutAnimation( Toolkit::CheckBoxButton& checkBox, bool remove = true );
233 * It adds the actor to the root actor and to the fade in animation.
235 * @param[inout] checkBox The button which holds images.
236 * @param[inout] image The actor.
237 * @param[in] opacity The initial opacity.
239 void FadeInImage( Toolkit::CheckBoxButton& checkBox, Actor& image, float opacity = 0.f );
242 * It adds the actor fade out animation and stores it to be removed when the animation finishes.
244 * @param[inout] checkBox The button which holds images.
245 * @param[in] layer Defines if the actor is going to be stored in the mFadeOutBackgroundImage or mFadeOutSelectedImage member.
246 * @param[inout] image The actor.
247 * @param[in] opacity The initial opacity.
249 void FadeOutImage( Toolkit::CheckBoxButton& checkBox, ImageLayer layer, Actor& image, float opacity = 1.f );
252 * Adds the actor to the fade in animation. It creates a fade in animation if needed.
254 * @param[in] actor The actor.
256 void AddToCheckInAnimation( const Actor& actor );
259 * It adds the actor to the root actor and to the fade in animation.
261 * @param[inout] checkBox The button which holds images.
262 * @param[inout] image The actor.
264 void SetupSelectedAnimation( Toolkit::CheckBoxButton& checkBox, Actor& image );
267 * Signal end of check out animation
269 void EndCheckOutAnimation();
274 * Called when the fade out animation finishes.
276 * It changes the check button painter state and removes actors from the root.
278 void CheckOutAnimationFinished( Dali::Animation& source );
281 * Called when the fade in animation finishes.
283 * It changes the check button painter state.
285 void CheckInAnimationFinished( Dali::Animation& source );
288 bool mDisabled; ///< Stores the disabled property.
290 PaintState mPaintState; ///< The painter state.
292 Animation mCheckInAnimation; ///< Animation used in the state transitions.
293 Animation mCheckOutAnimation; ///< Animation used in the state transitions.
294 Internal::CheckBoxButton* mButton; ///< Temporary pointer used to remove fade out images from button.
295 float mAnimationTime; ///< The animation time.
297 ImageRegionEffect mTickUVEffect; ///< ImageRegionEffect to expand the tick across
299 Property::Index mPercentageParentSizeProperty; ///< Dynamic property on the image actor
302 } // namespace Internal
304 } // namespace Toolkit
308 #endif // __DALI_TOOLKIT_INTERNAL_CHECK_BOX_BUTTON_DEFAULT_PAINTER_H__