2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include "check-box-button-default-painter-impl.h"
22 #include <dali/public-api/actors/image-actor.h>
23 #include <dali/public-api/animation/active-constraint.h>
24 #include <dali/public-api/animation/constraint.h>
25 #include <dali/public-api/animation/constraints.h>
26 #include <dali/public-api/object/ref-object.h>
29 #include "check-box-button-impl.h"
42 const float FOREGROUND_DEPTH( 0.5f );
43 const float BACKGROUND_DEPTH( 0.25f );
45 const float ANIMATION_TIME( 0.26f ); // EFL checkbox tick time
47 inline Toolkit::Internal::CheckBoxButton& GetCheckBoxButtonImpl( Toolkit::Button& button )
49 DALI_ASSERT_ALWAYS( button );
51 Dali::RefObject& handle = button.GetImplementation();
53 return static_cast<Toolkit::Internal::CheckBoxButton&>( handle );
56 inline const Toolkit::Internal::CheckBoxButton& GetCheckBoxButtonImpl( const Toolkit::Button& button )
58 DALI_ASSERT_ALWAYS( button );
60 const Dali::RefObject& handle = button.GetImplementation();
62 return static_cast<const Toolkit::Internal::CheckBoxButton&>( handle );
67 CheckBoxButtonDefaultPainter::CheckBoxButtonDefaultPainter()
68 : CheckBoxButtonPainter(),
70 mPaintState( UnselectedState ),
72 mAnimationTime( ANIMATION_TIME )
76 CheckBoxButtonDefaultPainter::~CheckBoxButtonDefaultPainter()
78 if( mCheckInAnimation )
80 mCheckInAnimation.Clear();
82 if( mCheckOutAnimation )
84 mCheckOutAnimation.Clear();
88 void CheckBoxButtonDefaultPainter::Initialize( Toolkit::Button& button )
90 Toolkit::Internal::CheckBoxButton& buttonImpl = GetCheckBoxButtonImpl( button );
91 Actor& backgroundImage = buttonImpl.GetBackgroundImage();
92 Actor& selectedImage = buttonImpl.GetSelectedImage();
93 Actor& disabledBackgroundImage = buttonImpl.GetDisabledBackgroundImage();
94 Actor& disabledSelectedImage = buttonImpl.GetDisabledSelectedImage();
96 Toolkit::CheckBoxButton& checkBox = static_cast<Toolkit::CheckBoxButton&>( button );
100 SetBackgroundImage( checkBox, backgroundImage );
105 SetSelectedImage( checkBox, selectedImage );
108 if( disabledBackgroundImage )
110 SetDisabledBackgroundImage( checkBox, disabledBackgroundImage );
113 if( disabledSelectedImage )
115 SetDisabledSelectedImage( checkBox, disabledSelectedImage );
118 SetDisabled( button, mDisabled );
121 void CheckBoxButtonDefaultPainter::SetSize( Toolkit::Button& button, const Vector3& size )
123 Toolkit::Internal::CheckBoxButton& buttonImpl = GetCheckBoxButtonImpl( button );
124 Actor& backgroundImage = buttonImpl.GetBackgroundImage();
125 Actor& selectedImage = buttonImpl.GetSelectedImage();
126 Actor& disabledBackgroundImage = buttonImpl.GetDisabledBackgroundImage();
127 Actor& disabledSelectedImage = buttonImpl.GetDisabledSelectedImage();
129 ApplySelectedConstraint( selectedImage, FOREGROUND_DEPTH );
130 ApplyConstraint( backgroundImage, BACKGROUND_DEPTH );
131 ApplyConstraint( disabledSelectedImage, FOREGROUND_DEPTH );
132 ApplyConstraint( disabledBackgroundImage, BACKGROUND_DEPTH );
135 void CheckBoxButtonDefaultPainter::SetDisabled( Toolkit::Button& button, bool disabled )
137 mDisabled = disabled;
139 Toolkit::Internal::CheckBoxButton& buttonImpl = GetCheckBoxButtonImpl( button );
140 Actor& backgroundImage = buttonImpl.GetBackgroundImage();
141 Actor& selectedImage = buttonImpl.GetSelectedImage();
142 Actor& disabledBackgroundImage = buttonImpl.GetDisabledBackgroundImage();
143 Actor& disabledSelectedImage = buttonImpl.GetDisabledSelectedImage();
144 Actor& fadeOutSelectedImage = buttonImpl.GetFadeOutSelectedImage();
145 Actor& fadeOutBackgroundImage = buttonImpl.GetFadeOutBackgroundImage();
147 Toolkit::CheckBoxButton& checkBox = static_cast<Toolkit::CheckBoxButton&>( button );
149 switch( mPaintState )
151 case UnselectedState:
155 StopCheckOutAnimation( checkBox );
156 FadeOutImage( checkBox, Background, backgroundImage );
157 FadeInImage( checkBox, disabledBackgroundImage );
158 StartCheckOutAnimation( checkBox );
159 StartCheckInAnimation();
161 mPaintState = UnselectedDisabledTransition;
169 StopCheckOutAnimation( checkBox );
170 FadeOutImage( checkBox, Background, backgroundImage );
171 FadeOutImage( checkBox, Foreground, selectedImage );
172 FadeInImage( checkBox, disabledSelectedImage );
173 FadeInImage( checkBox, disabledBackgroundImage );
174 StartCheckOutAnimation( checkBox );
175 StartCheckInAnimation();
177 mPaintState = SelectedDisabledTransition;
181 case DisabledUnselectedState:
185 StopCheckOutAnimation( checkBox );
186 FadeOutImage( checkBox, Background, disabledBackgroundImage );
187 FadeInImage( checkBox, backgroundImage );
188 StartCheckOutAnimation( checkBox );
189 StartCheckInAnimation();
191 mPaintState = DisabledUnselectedTransition;
195 case DisabledSelectedState:
199 StopCheckOutAnimation( checkBox );
200 FadeOutImage( checkBox, Background, disabledBackgroundImage );
201 FadeOutImage( checkBox, Foreground, disabledSelectedImage );
202 FadeInImage( checkBox, backgroundImage );
203 FadeInImage( checkBox, selectedImage );
204 StartCheckOutAnimation( checkBox );
205 StartCheckInAnimation();
207 mPaintState = DisabledSelectedTransition;
211 case UnselectedSelectedTransition:
218 opacity = selectedImage.GetCurrentOpacity();
220 StopCheckOutAnimation( checkBox );
221 StopCheckInAnimation();
223 FadeOutImage( checkBox, Foreground, selectedImage, opacity );
224 FadeOutImage( checkBox, Background, backgroundImage );
226 FadeInImage( checkBox, disabledSelectedImage );
227 FadeInImage( checkBox, disabledBackgroundImage );
229 StartCheckOutAnimation( checkBox );
230 StartCheckInAnimation();
232 mPaintState = SelectedDisabledTransition;
236 case SelectedUnselectedTransition:
241 if( fadeOutSelectedImage )
243 opacity = fadeOutSelectedImage.GetCurrentOpacity();
245 StopCheckOutAnimation( checkBox );
246 StopCheckInAnimation();
248 button.Add( disabledSelectedImage );
249 FadeOutImage( checkBox, Foreground, disabledSelectedImage, opacity );
250 FadeOutImage( checkBox, Background, backgroundImage );
252 FadeInImage( checkBox, disabledBackgroundImage );
254 StartCheckOutAnimation( checkBox );
255 StartCheckInAnimation();
257 mPaintState = UnselectedDisabledTransition;
261 case UnselectedDisabledTransition:
266 if( fadeOutBackgroundImage )
268 opacity = fadeOutBackgroundImage.GetCurrentOpacity();
270 StopCheckOutAnimation( checkBox, false );
271 StopCheckInAnimation();
273 FadeOutImage( checkBox, Background, disabledBackgroundImage, 1.f - opacity );
274 FadeInImage( checkBox, backgroundImage, opacity );
276 StartCheckOutAnimation( checkBox );
277 StartCheckInAnimation();
279 mPaintState = DisabledUnselectedTransition;
283 case DisabledUnselectedTransition:
288 if( fadeOutBackgroundImage )
290 opacity = fadeOutBackgroundImage.GetCurrentOpacity();
292 StopCheckOutAnimation( checkBox, false );
293 StopCheckInAnimation();
295 FadeOutImage( checkBox, Background, backgroundImage, 1.f - opacity );
296 FadeInImage( checkBox, disabledBackgroundImage, opacity );
298 StartCheckOutAnimation( checkBox );
299 StartCheckInAnimation();
301 mPaintState = UnselectedDisabledTransition;
305 case SelectedDisabledTransition:
310 if( fadeOutBackgroundImage )
312 opacity = fadeOutBackgroundImage.GetCurrentOpacity();
314 StopCheckOutAnimation( checkBox, false );
315 StopCheckInAnimation();
317 FadeOutImage( checkBox, Foreground, disabledSelectedImage, 1.f - opacity );
318 FadeOutImage( checkBox, Background, disabledBackgroundImage, 1.f - opacity );
319 FadeInImage( checkBox, selectedImage, opacity );
320 FadeInImage( checkBox, backgroundImage, opacity );
322 StartCheckOutAnimation( checkBox );
323 StartCheckInAnimation();
325 mPaintState = DisabledSelectedTransition;
329 case DisabledSelectedTransition:
334 if( fadeOutBackgroundImage )
336 opacity = fadeOutBackgroundImage.GetCurrentOpacity();
338 StopCheckOutAnimation( checkBox, false );
339 StopCheckInAnimation();
341 FadeOutImage( checkBox, Foreground, selectedImage, 1.f - opacity );
342 FadeOutImage( checkBox, Background, backgroundImage, 1.f - opacity );
343 FadeInImage( checkBox, disabledSelectedImage, opacity );
344 FadeInImage( checkBox, disabledBackgroundImage, opacity );
346 StartCheckOutAnimation( checkBox );
347 StartCheckInAnimation();
349 mPaintState = SelectedDisabledTransition;
358 void CheckBoxButtonDefaultPainter::SetAnimationTime( float animationTime )
360 mAnimationTime = animationTime;
363 float CheckBoxButtonDefaultPainter::GetAnimationTime() const
365 return mAnimationTime;
368 void CheckBoxButtonDefaultPainter::SetSelectedImage( Toolkit::Button& button, Actor image )
370 Toolkit::Internal::CheckBoxButton& checkBoxImpl = GetCheckBoxButtonImpl( button );
371 Actor& selectedImage = checkBoxImpl.GetSelectedImage();
372 Actor& fadeOutSelectedImage = checkBoxImpl.GetFadeOutSelectedImage();
374 Toolkit::CheckBoxButton& checkBox = static_cast<Toolkit::CheckBoxButton&>( button );
376 switch( mPaintState )
380 if( selectedImage && selectedImage.GetParent() )
382 StopCheckOutAnimation( checkBox );
383 FadeOutImage( checkBox, Foreground, selectedImage );
385 selectedImage = image;
387 FadeInImage( checkBox, selectedImage );
389 StartCheckOutAnimation( checkBox );
390 StartCheckInAnimation();
394 selectedImage = image;
395 checkBox.Add( selectedImage );
399 case UnselectedSelectedTransition: // FALLTHROUGH
400 case DisabledSelectedTransition:
402 StopCheckInAnimation();
403 checkBox.Remove( selectedImage );
405 selectedImage = image;
407 FadeInImage( checkBox, selectedImage );
408 StartCheckInAnimation();
411 case SelectedUnselectedTransition: // FALLTHROUGH
412 case SelectedDisabledTransition:
415 if( fadeOutSelectedImage )
417 opacity = fadeOutSelectedImage.GetCurrentOpacity();
419 StopCheckOutAnimation( checkBox );
421 // Replaces the button image.
422 selectedImage = image;
424 checkBox.Add( selectedImage );
425 FadeOutImage( checkBox, Foreground, selectedImage, opacity );
427 StartCheckOutAnimation( checkBox );
432 selectedImage = image;
437 selectedImage.SetAnchorPoint( AnchorPoint::TOP_LEFT );
438 selectedImage.SetParentOrigin( ParentOrigin::TOP_LEFT );
439 ApplySelectedConstraint( selectedImage, FOREGROUND_DEPTH );
442 void CheckBoxButtonDefaultPainter::SetBackgroundImage( Toolkit::Button& button, Actor image )
444 Toolkit::Internal::CheckBoxButton& checkBoxImpl = GetCheckBoxButtonImpl( button );
445 Actor& backgroundImage = checkBoxImpl.GetBackgroundImage();
446 Actor& fadeOutBackgroundImage = checkBoxImpl.GetFadeOutBackgroundImage();
448 Toolkit::CheckBoxButton& checkBox = static_cast<Toolkit::CheckBoxButton&>( button );
450 switch( mPaintState )
452 case UnselectedState: // FALLTHROUGH
454 case UnselectedSelectedTransition:
455 case SelectedUnselectedTransition:
457 if( backgroundImage && backgroundImage.GetParent() )
459 StopCheckOutAnimation( checkBox );
460 FadeOutImage( checkBox, Background, backgroundImage );
462 backgroundImage = image;
464 FadeInImage( checkBox, backgroundImage );
466 StartCheckOutAnimation( checkBox );
467 StartCheckInAnimation();
471 backgroundImage = image;
472 checkBox.Add( backgroundImage );
476 case DisabledUnselectedTransition: // FALLTHROUGH
477 case DisabledSelectedTransition:
479 StopCheckInAnimation();
480 checkBox.Remove( backgroundImage );
482 backgroundImage = image;
484 FadeInImage( checkBox, backgroundImage );
485 StartCheckInAnimation();
488 case SelectedDisabledTransition: // FALLTHROUGH
489 case UnselectedDisabledTransition:
492 if( fadeOutBackgroundImage )
494 opacity = fadeOutBackgroundImage.GetCurrentOpacity();
496 StopCheckOutAnimation( checkBox );
498 // Replaces the button image.
499 backgroundImage = image;
501 checkBox.Add( backgroundImage );
502 FadeOutImage( checkBox, Background, backgroundImage, opacity );
504 StartCheckOutAnimation( checkBox );
509 backgroundImage = image;
514 backgroundImage.SetAnchorPoint( AnchorPoint::TOP_LEFT );
515 backgroundImage.SetParentOrigin( ParentOrigin::TOP_LEFT );
516 ApplyConstraint( backgroundImage, BACKGROUND_DEPTH );
519 void CheckBoxButtonDefaultPainter::SetDisabledSelectedImage( Toolkit::Button& button, Actor image )
521 Toolkit::Internal::CheckBoxButton& checkBoxImpl = GetCheckBoxButtonImpl( button );
522 Actor& disabledSelectedImage = checkBoxImpl.GetDisabledSelectedImage();
523 Actor& fadeOutSelectedImage = checkBoxImpl.GetFadeOutSelectedImage();
525 Toolkit::CheckBoxButton& checkBox = static_cast<Toolkit::CheckBoxButton&>( button );
527 switch( mPaintState )
529 case DisabledSelectedState:
531 if( disabledSelectedImage && disabledSelectedImage.GetParent() )
533 StopCheckOutAnimation( checkBox );
534 FadeOutImage( checkBox, Foreground, disabledSelectedImage );
536 disabledSelectedImage = image;
538 FadeInImage( checkBox, disabledSelectedImage );
540 StartCheckOutAnimation( checkBox );
541 StartCheckInAnimation();
545 disabledSelectedImage = image;
546 checkBox.Add( disabledSelectedImage );
550 case SelectedDisabledTransition:
552 StopCheckInAnimation();
553 checkBox.Remove( disabledSelectedImage );
555 disabledSelectedImage = image;
557 FadeInImage( checkBox, disabledSelectedImage );
558 StartCheckInAnimation();
561 case DisabledSelectedTransition:
564 if( fadeOutSelectedImage )
566 opacity = fadeOutSelectedImage.GetCurrentOpacity();
568 StopCheckOutAnimation( checkBox );
570 // Replaces the button image.
571 disabledSelectedImage = image;
573 checkBox.Add( disabledSelectedImage );
574 FadeOutImage( checkBox, Foreground, disabledSelectedImage, opacity );
576 StartCheckOutAnimation( checkBox );
581 disabledSelectedImage = image;
586 disabledSelectedImage.SetAnchorPoint( AnchorPoint::TOP_LEFT );
587 disabledSelectedImage.SetParentOrigin( ParentOrigin::TOP_LEFT );
588 ApplyConstraint( disabledSelectedImage, FOREGROUND_DEPTH );
591 void CheckBoxButtonDefaultPainter::SetDisabledBackgroundImage( Toolkit::Button& button, Actor image )
593 Toolkit::Internal::CheckBoxButton& checkBoxImpl = GetCheckBoxButtonImpl( button );
594 Actor& disabledBackgroundImage = checkBoxImpl.GetDisabledBackgroundImage();
595 Actor& fadeOutBackgroundImage = checkBoxImpl.GetFadeOutBackgroundImage();
597 Toolkit::CheckBoxButton& checkBox = static_cast<Toolkit::CheckBoxButton&>( button );
599 switch( mPaintState )
601 case DisabledSelectedState: // FALLTHROUGH
602 case DisabledUnselectedState:
604 if( disabledBackgroundImage && disabledBackgroundImage.GetParent() )
606 StopCheckOutAnimation( checkBox );
607 FadeOutImage( checkBox, Background, disabledBackgroundImage );
609 disabledBackgroundImage = image;
611 FadeInImage( checkBox, disabledBackgroundImage );
613 StartCheckOutAnimation( checkBox );
614 StartCheckInAnimation();
618 disabledBackgroundImage = image;
619 checkBox.Add( disabledBackgroundImage );
623 case UnselectedDisabledTransition: // FALLTHROUGH
624 case SelectedDisabledTransition:
626 StopCheckInAnimation();
627 checkBox.Remove( disabledBackgroundImage );
629 disabledBackgroundImage = image;
631 FadeInImage( checkBox, disabledBackgroundImage );
632 StartCheckInAnimation();
635 case DisabledUnselectedTransition: // FALLTHROUGH
636 case DisabledSelectedTransition:
639 if( fadeOutBackgroundImage )
641 opacity = fadeOutBackgroundImage.GetCurrentOpacity();
643 StopCheckOutAnimation( checkBox );
645 // Replaces the button image.
646 disabledBackgroundImage = image;
648 checkBox.Add( disabledBackgroundImage );
649 FadeOutImage( checkBox, Background, disabledBackgroundImage, opacity );
651 StartCheckOutAnimation( checkBox );
656 disabledBackgroundImage = image;
661 disabledBackgroundImage.SetAnchorPoint( AnchorPoint::TOP_LEFT );
662 disabledBackgroundImage.SetParentOrigin( ParentOrigin::TOP_LEFT );
663 ApplyConstraint( disabledBackgroundImage, BACKGROUND_DEPTH );
666 void CheckBoxButtonDefaultPainter::Selected( Toolkit::Button& button )
668 Toolkit::Internal::CheckBoxButton& checkBoxImpl = GetCheckBoxButtonImpl( button );
669 Actor& selectedImage = checkBoxImpl.GetSelectedImage();
670 Actor& fadeOutSelectedImage = checkBoxImpl.GetFadeOutSelectedImage();
672 Toolkit::CheckBoxButton& checkBoxButton = static_cast<Toolkit::CheckBoxButton&>( button );
674 switch( mPaintState )
676 case UnselectedState:
678 // Fade in the 'check' actor.
679 FadeInImage( checkBoxButton, selectedImage );
680 SetupSelectedAnimation( checkBoxButton, selectedImage ); // Animate in the check actor
681 StartCheckInAnimation();
683 mPaintState = UnselectedSelectedTransition;
688 // Fade out the 'check' actor.
689 StopCheckOutAnimation( checkBoxButton );
690 FadeOutImage( checkBoxButton, Foreground, selectedImage );
691 StartCheckOutAnimation( checkBoxButton );
693 mPaintState = UnselectedState;
696 case UnselectedSelectedTransition:
698 // Stop fade in and start fade out.
699 StopCheckOutAnimation( checkBoxButton );
700 StopCheckInAnimation();
705 opacity = selectedImage.GetCurrentOpacity();
707 FadeOutImage( checkBoxButton, Foreground, selectedImage, opacity );
708 StartCheckOutAnimation( checkBoxButton );
710 mPaintState = UnselectedState;
713 case SelectedUnselectedTransition:
715 // Stop fade out and start fade in.
717 if( fadeOutSelectedImage )
719 opacity = fadeOutSelectedImage.GetCurrentOpacity();
721 StopCheckOutAnimation( checkBoxButton );
723 FadeInImage( checkBoxButton, selectedImage, opacity );
724 StartCheckInAnimation();
726 mPaintState = UnselectedSelectedTransition;
734 void CheckBoxButtonDefaultPainter::ApplyConstraint( Actor& actor, float depth )
738 actor.RemoveConstraints();
739 actor.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
744 void CheckBoxButtonDefaultPainter::ApplySelectedConstraint( Actor& actor, float depth )
748 actor.RemoveConstraints();
749 actor.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
754 void CheckBoxButtonDefaultPainter::AddToFadeInAnimation( const Actor& actor )
756 if( !mCheckInAnimation )
758 mCheckInAnimation = Dali::Animation::New( mAnimationTime );
761 mCheckInAnimation.OpacityTo( actor, 1.f );
765 void CheckBoxButtonDefaultPainter::StartCheckInAnimation()
767 if( mCheckInAnimation )
769 mCheckInAnimation.FinishedSignal().Connect( this, &CheckBoxButtonDefaultPainter::CheckInAnimationFinished );
770 mCheckInAnimation.Play();
774 void CheckBoxButtonDefaultPainter::StopCheckInAnimation()
776 if( mCheckInAnimation )
778 mCheckInAnimation.Clear();
779 mCheckInAnimation.Reset();
783 void CheckBoxButtonDefaultPainter::AddToFadeOutAnimation( const Actor& actor )
785 if( !mCheckOutAnimation )
787 mCheckOutAnimation = Dali::Animation::New( mAnimationTime );
790 mCheckOutAnimation.OpacityTo( actor, 0.f );
793 void CheckBoxButtonDefaultPainter::StartCheckOutAnimation( Toolkit::CheckBoxButton& checkBox )
795 if( mCheckOutAnimation )
797 Toolkit::Internal::CheckBoxButton& checkBoxImpl = GetCheckBoxButtonImpl( checkBox );
798 mButton = &checkBoxImpl;
800 mCheckOutAnimation.FinishedSignal().Connect( this, &CheckBoxButtonDefaultPainter::CheckOutAnimationFinished );
801 mCheckOutAnimation.Play();
805 void CheckBoxButtonDefaultPainter::StopCheckOutAnimation( Toolkit::CheckBoxButton& checkBox, bool remove )
807 if( mCheckOutAnimation )
809 mCheckOutAnimation.Clear();
810 mCheckOutAnimation.Reset();
813 Toolkit::Internal::CheckBoxButton& checkBoxImpl = GetCheckBoxButtonImpl( checkBox );
814 Actor& fadeOutSelectedImage = checkBoxImpl.GetFadeOutSelectedImage();
815 Actor& fadeOutBackgroundImage = checkBoxImpl.GetFadeOutBackgroundImage();
819 if( fadeOutSelectedImage && fadeOutSelectedImage.GetParent() )
821 fadeOutSelectedImage.GetParent().Remove( fadeOutSelectedImage );
824 if( fadeOutBackgroundImage && fadeOutBackgroundImage.GetParent() )
826 fadeOutBackgroundImage.GetParent().Remove( fadeOutBackgroundImage );
829 fadeOutSelectedImage.Reset();
830 fadeOutBackgroundImage.Reset();
834 void CheckBoxButtonDefaultPainter::FadeInImage( Toolkit::CheckBoxButton& checkBox, Actor& image, float opacity )
838 if( !image.GetParent() )
840 checkBox.Add( image );
843 image.SetOpacity( 1.0f );
847 void CheckBoxButtonDefaultPainter::FadeOutImage( Toolkit::CheckBoxButton& checkBox, ImageLayer layer, Actor& image, float opacity )
851 Toolkit::Internal::CheckBoxButton& checkBoxImpl = GetCheckBoxButtonImpl( checkBox );
852 Actor& fadeOutSelectedImage = checkBoxImpl.GetFadeOutSelectedImage();
853 Actor& fadeOutBackgroundImage = checkBoxImpl.GetFadeOutBackgroundImage();
855 Actor& actorLayer = ( ( Background == layer ) ? fadeOutBackgroundImage : fadeOutSelectedImage );
859 actorLayer.SetOpacity( 0.0f );
863 void CheckBoxButtonDefaultPainter::AddToCheckInAnimation( const Actor& actor )
865 if( !mCheckInAnimation )
867 mCheckInAnimation = Dali::Animation::New( mAnimationTime );
871 mCheckInAnimation.AnimateTo( Property( mTickUVEffect, mTickUVEffect.GetBottomRightPropertyName() ), Vector2( 1.0f, 1.0f ) );
874 Handle handle = actor; // Get rid of const
875 mCheckInAnimation.AnimateTo( Property( handle, Actor::SCALE_X ), 1.0f);
878 void CheckBoxButtonDefaultPainter::SetupSelectedAnimation( Toolkit::CheckBoxButton& checkBox, Actor& image )
884 ImageActor imageActor = ImageActor::DownCast( image );
885 mTickUVEffect = ImageRegionEffect::New();
886 imageActor.SetShaderEffect( mTickUVEffect );
889 image.SetScale( Vector3( 0.0f, 1.0f, 1.0f ) );
891 mTickUVEffect.SetBottomRight( Vector2( 0.0f, 1.0f ) );
894 if( !image.GetParent() )
896 checkBox.Add( image );
899 AddToCheckInAnimation( image );
903 void CheckBoxButtonDefaultPainter::EndCheckOutAnimation()
905 switch( mPaintState )
907 case UnselectedSelectedTransition:
909 mPaintState = SelectedState;
912 case SelectedUnselectedTransition:
914 mPaintState = UnselectedState;
917 case UnselectedDisabledTransition:
919 mPaintState = DisabledUnselectedState;
922 case DisabledUnselectedTransition:
924 mPaintState = UnselectedState;
927 case SelectedDisabledTransition:
929 mPaintState = DisabledSelectedState;
932 case DisabledSelectedTransition:
934 mPaintState = SelectedState;
944 void CheckBoxButtonDefaultPainter::CheckOutAnimationFinished( Dali::Animation& source )
946 EndCheckOutAnimation();
948 Toolkit::CheckBoxButton handle( mButton->GetOwner() );
949 StopCheckOutAnimation( handle );
953 void CheckBoxButtonDefaultPainter::CheckInAnimationFinished( Dali::Animation& source )
955 switch( mPaintState )
957 case UnselectedSelectedTransition:
959 mPaintState = SelectedState;
962 case SelectedUnselectedTransition:
964 mPaintState = UnselectedState;
967 case UnselectedDisabledTransition:
969 mPaintState = DisabledUnselectedState;
972 case DisabledUnselectedTransition:
974 mPaintState = UnselectedState;
977 case SelectedDisabledTransition:
979 mPaintState = DisabledSelectedState;
982 case DisabledSelectedTransition:
984 mPaintState = SelectedState;
993 StopCheckInAnimation();
996 } // namespace Internal
998 } // namespace Toolkit