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/animation/constraints.h>
25 #include <dali/public-api/actors/image-actor.h>
26 #include <dali/public-api/object/ref-object.h>
27 #include "check-box-button-impl.h"
40 const float FOREGROUND_DEPTH( 0.5f );
41 const float BACKGROUND_DEPTH( 0.25f );
43 const float ANIMATION_TIME( 0.26f ); // EFL checkbox tick time
45 inline Toolkit::Internal::CheckBoxButton& GetCheckBoxButtonImpl( Toolkit::Button& button )
47 DALI_ASSERT_ALWAYS( button );
49 Dali::RefObject& handle = button.GetImplementation();
51 return static_cast<Toolkit::Internal::CheckBoxButton&>( handle );
54 inline const Toolkit::Internal::CheckBoxButton& GetCheckBoxButtonImpl( const Toolkit::Button& button )
56 DALI_ASSERT_ALWAYS( button );
58 const Dali::RefObject& handle = button.GetImplementation();
60 return static_cast<const Toolkit::Internal::CheckBoxButton&>( handle );
65 CheckBoxButtonDefaultPainter::CheckBoxButtonDefaultPainter()
66 : CheckBoxButtonPainter(),
68 mPaintState( UncheckedState ),
70 mAnimationTime( ANIMATION_TIME )
74 CheckBoxButtonDefaultPainter::~CheckBoxButtonDefaultPainter()
76 if( mCheckInAnimation )
78 mCheckInAnimation.Clear();
80 if( mCheckOutAnimation )
82 mCheckOutAnimation.Clear();
86 void CheckBoxButtonDefaultPainter::SetBackgroundImage( Toolkit::CheckBoxButton& checkBox, Actor image )
88 Toolkit::Internal::CheckBoxButton& checkBoxImpl = GetImplementation( checkBox );
89 Actor& backgroundImage = checkBoxImpl.GetBackgroundImage();
90 Actor& fadeOutBackgroundImage = checkBoxImpl.GetFadeOutBackgroundImage();
94 case UncheckedState: // FALLTHROUGH
96 case UncheckedCheckedTransition:
97 case CheckedUncheckedTransition:
99 if( backgroundImage && backgroundImage.GetParent() )
101 StopCheckOutAnimation( checkBox );
102 FadeOutImage( checkBox, Background, backgroundImage );
104 backgroundImage = image;
106 FadeInImage( checkBox, backgroundImage );
108 StartCheckOutAnimation( checkBox );
109 StartCheckInAnimation();
113 backgroundImage = image;
114 checkBox.Add( backgroundImage );
118 case DisabledUncheckedTransition: // FALLTHROUGH
119 case DisabledCheckedTransition:
121 StopCheckInAnimation();
122 checkBox.Remove( backgroundImage );
124 backgroundImage = image;
126 FadeInImage( checkBox, backgroundImage );
127 StartCheckInAnimation();
130 case CheckedDisabledTransition: // FALLTHROUGH
131 case UncheckedDisabledTransition:
134 if( fadeOutBackgroundImage )
136 opacity = fadeOutBackgroundImage.GetCurrentOpacity();
138 StopCheckOutAnimation( checkBox );
140 // Replaces the button image.
141 backgroundImage = image;
143 checkBox.Add( backgroundImage );
144 FadeOutImage( checkBox, Background, backgroundImage, opacity );
146 StartCheckOutAnimation( checkBox );
151 backgroundImage = image;
156 backgroundImage.SetAnchorPoint( AnchorPoint::TOP_LEFT );
157 backgroundImage.SetParentOrigin( ParentOrigin::TOP_LEFT );
158 ApplyConstraint( backgroundImage, BACKGROUND_DEPTH );
161 void CheckBoxButtonDefaultPainter::SetCheckedImage( Toolkit::CheckBoxButton& checkBox, Actor image )
163 Toolkit::Internal::CheckBoxButton& checkBoxImpl = GetImplementation( checkBox );
164 Actor& checkedImage = checkBoxImpl.GetCheckedImage();
165 Actor& fadeOutCheckedImage = checkBoxImpl.GetFadeOutCheckedImage();
167 switch( mPaintState )
171 if( checkedImage && checkedImage.GetParent() )
173 StopCheckOutAnimation( checkBox );
174 FadeOutImage( checkBox, Foreground, checkedImage );
176 checkedImage = image;
178 FadeInImage( checkBox, checkedImage );
180 StartCheckOutAnimation( checkBox );
181 StartCheckInAnimation();
185 checkedImage = image;
186 checkBox.Add( checkedImage );
190 case UncheckedCheckedTransition: // FALLTHROUGH
191 case DisabledCheckedTransition:
193 StopCheckInAnimation();
194 checkBox.Remove( checkedImage );
196 checkedImage = image;
198 FadeInImage( checkBox, checkedImage );
199 StartCheckInAnimation();
202 case CheckedUncheckedTransition: // FALLTHROUGH
203 case CheckedDisabledTransition:
206 if( fadeOutCheckedImage )
208 opacity = fadeOutCheckedImage.GetCurrentOpacity();
210 StopCheckOutAnimation( checkBox );
212 // Replaces the button image.
213 checkedImage = image;
215 checkBox.Add( checkedImage );
216 FadeOutImage( checkBox, Foreground, checkedImage, opacity );
218 StartCheckOutAnimation( checkBox );
223 checkedImage = image;
228 checkedImage.SetAnchorPoint( AnchorPoint::TOP_LEFT );
229 checkedImage.SetParentOrigin( ParentOrigin::TOP_LEFT );
230 ApplyCheckedConstraint( checkedImage, FOREGROUND_DEPTH );
233 void CheckBoxButtonDefaultPainter::SetDisabledCheckedImage( Toolkit::CheckBoxButton& checkBox, Actor image )
235 Toolkit::Internal::CheckBoxButton& checkBoxImpl = GetImplementation( checkBox );
236 Actor& disabledCheckedImage = checkBoxImpl.GetDisabledCheckedImage();
237 Actor& fadeOutCheckedImage = checkBoxImpl.GetFadeOutCheckedImage();
239 switch( mPaintState )
241 case DisabledCheckedState:
243 if( disabledCheckedImage && disabledCheckedImage.GetParent() )
245 StopCheckOutAnimation( checkBox );
246 FadeOutImage( checkBox, Foreground, disabledCheckedImage );
248 disabledCheckedImage = image;
250 FadeInImage( checkBox, disabledCheckedImage );
252 StartCheckOutAnimation( checkBox );
253 StartCheckInAnimation();
257 disabledCheckedImage = image;
258 checkBox.Add( disabledCheckedImage );
262 case CheckedDisabledTransition:
264 StopCheckInAnimation();
265 checkBox.Remove( disabledCheckedImage );
267 disabledCheckedImage = image;
269 FadeInImage( checkBox, disabledCheckedImage );
270 StartCheckInAnimation();
273 case DisabledCheckedTransition:
276 if( fadeOutCheckedImage )
278 opacity = fadeOutCheckedImage.GetCurrentOpacity();
280 StopCheckOutAnimation( checkBox );
282 // Replaces the button image.
283 disabledCheckedImage = image;
285 checkBox.Add( disabledCheckedImage );
286 FadeOutImage( checkBox, Foreground, disabledCheckedImage, opacity );
288 StartCheckOutAnimation( checkBox );
293 disabledCheckedImage = image;
298 disabledCheckedImage.SetAnchorPoint( AnchorPoint::TOP_LEFT );
299 disabledCheckedImage.SetParentOrigin( ParentOrigin::TOP_LEFT );
300 ApplyConstraint( disabledCheckedImage, FOREGROUND_DEPTH );
303 void CheckBoxButtonDefaultPainter::SetDisabledBackgroundImage( Toolkit::CheckBoxButton& checkBox, Actor image )
305 Toolkit::Internal::CheckBoxButton& checkBoxImpl = GetImplementation( checkBox );
306 Actor& disabledBackgroundImage = checkBoxImpl.GetDisabledBackgroundImage();
307 Actor& fadeOutBackgroundImage = checkBoxImpl.GetFadeOutBackgroundImage();
309 switch( mPaintState )
311 case DisabledCheckedState: // FALLTHROUGH
312 case DisabledUncheckedState:
314 if( disabledBackgroundImage && disabledBackgroundImage.GetParent() )
316 StopCheckOutAnimation( checkBox );
317 FadeOutImage( checkBox, Background, disabledBackgroundImage );
319 disabledBackgroundImage = image;
321 FadeInImage( checkBox, disabledBackgroundImage );
323 StartCheckOutAnimation( checkBox );
324 StartCheckInAnimation();
328 disabledBackgroundImage = image;
329 checkBox.Add( disabledBackgroundImage );
333 case UncheckedDisabledTransition: // FALLTHROUGH
334 case CheckedDisabledTransition:
336 StopCheckInAnimation();
337 checkBox.Remove( disabledBackgroundImage );
339 disabledBackgroundImage = image;
341 FadeInImage( checkBox, disabledBackgroundImage );
342 StartCheckInAnimation();
345 case DisabledUncheckedTransition: // FALLTHROUGH
346 case DisabledCheckedTransition:
349 if( fadeOutBackgroundImage )
351 opacity = fadeOutBackgroundImage.GetCurrentOpacity();
353 StopCheckOutAnimation( checkBox );
355 // Replaces the button image.
356 disabledBackgroundImage = image;
358 checkBox.Add( disabledBackgroundImage );
359 FadeOutImage( checkBox, Background, disabledBackgroundImage, opacity );
361 StartCheckOutAnimation( checkBox );
366 disabledBackgroundImage = image;
371 disabledBackgroundImage.SetAnchorPoint( AnchorPoint::TOP_LEFT );
372 disabledBackgroundImage.SetParentOrigin( ParentOrigin::TOP_LEFT );
373 ApplyConstraint( disabledBackgroundImage, BACKGROUND_DEPTH );
376 void CheckBoxButtonDefaultPainter::Initialize( Toolkit::Button& button )
378 Toolkit::Internal::CheckBoxButton& buttonImpl = GetCheckBoxButtonImpl( button );
379 Actor& backgroundImage = buttonImpl.GetBackgroundImage();
380 Actor& checkedImage = buttonImpl.GetCheckedImage();
381 Actor& disabledBackgroundImage = buttonImpl.GetDisabledBackgroundImage();
382 Actor& disabledCheckedImage = buttonImpl.GetDisabledCheckedImage();
384 Toolkit::CheckBoxButton& checkBox = static_cast<Toolkit::CheckBoxButton&>( button );
386 if( backgroundImage )
388 SetBackgroundImage( checkBox, backgroundImage );
393 SetCheckedImage( checkBox, checkedImage );
396 if( disabledBackgroundImage )
398 SetDisabledBackgroundImage( checkBox, disabledBackgroundImage );
401 if( disabledCheckedImage )
403 SetDisabledCheckedImage( checkBox, disabledCheckedImage );
406 SetDisabled( button, mDisabled );
409 void CheckBoxButtonDefaultPainter::SetSize( Toolkit::Button& button, const Vector3& size )
411 Toolkit::Internal::CheckBoxButton& buttonImpl = GetCheckBoxButtonImpl( button );
412 Actor& backgroundImage = buttonImpl.GetBackgroundImage();
413 Actor& checkedImage = buttonImpl.GetCheckedImage();
414 Actor& disabledBackgroundImage = buttonImpl.GetDisabledBackgroundImage();
415 Actor& disabledCheckedImage = buttonImpl.GetDisabledCheckedImage();
417 ApplyCheckedConstraint( checkedImage, FOREGROUND_DEPTH );
418 ApplyConstraint( backgroundImage, BACKGROUND_DEPTH );
419 ApplyConstraint( disabledCheckedImage, FOREGROUND_DEPTH );
420 ApplyConstraint( disabledBackgroundImage, BACKGROUND_DEPTH );
423 void CheckBoxButtonDefaultPainter::SetDisabled( Toolkit::Button& button, bool disabled )
425 mDisabled = disabled;
427 Toolkit::Internal::CheckBoxButton& buttonImpl = GetCheckBoxButtonImpl( button );
428 Actor& backgroundImage = buttonImpl.GetBackgroundImage();
429 Actor& checkedImage = buttonImpl.GetCheckedImage();
430 Actor& disabledBackgroundImage = buttonImpl.GetDisabledBackgroundImage();
431 Actor& disabledCheckedImage = buttonImpl.GetDisabledCheckedImage();
432 Actor& fadeOutCheckedImage = buttonImpl.GetFadeOutCheckedImage();
433 Actor& fadeOutBackgroundImage = buttonImpl.GetFadeOutBackgroundImage();
435 Toolkit::CheckBoxButton& checkBox = static_cast<Toolkit::CheckBoxButton&>( button );
437 switch( mPaintState )
443 StopCheckOutAnimation( checkBox );
444 FadeOutImage( checkBox, Background, backgroundImage );
445 FadeInImage( checkBox, disabledBackgroundImage );
446 StartCheckOutAnimation( checkBox );
447 StartCheckInAnimation();
449 mPaintState = UncheckedDisabledTransition;
457 StopCheckOutAnimation( checkBox );
458 FadeOutImage( checkBox, Background, backgroundImage );
459 FadeOutImage( checkBox, Foreground, checkedImage );
460 FadeInImage( checkBox, disabledCheckedImage );
461 FadeInImage( checkBox, disabledBackgroundImage );
462 StartCheckOutAnimation( checkBox );
463 StartCheckInAnimation();
465 mPaintState = CheckedDisabledTransition;
469 case DisabledUncheckedState:
473 StopCheckOutAnimation( checkBox );
474 FadeOutImage( checkBox, Background, disabledBackgroundImage );
475 FadeInImage( checkBox, backgroundImage );
476 StartCheckOutAnimation( checkBox );
477 StartCheckInAnimation();
479 mPaintState = DisabledUncheckedTransition;
483 case DisabledCheckedState:
487 StopCheckOutAnimation( checkBox );
488 FadeOutImage( checkBox, Background, disabledBackgroundImage );
489 FadeOutImage( checkBox, Foreground, disabledCheckedImage );
490 FadeInImage( checkBox, backgroundImage );
491 FadeInImage( checkBox, checkedImage );
492 StartCheckOutAnimation( checkBox );
493 StartCheckInAnimation();
495 mPaintState = DisabledCheckedTransition;
499 case UncheckedCheckedTransition:
506 opacity = checkedImage.GetCurrentOpacity();
508 StopCheckOutAnimation( checkBox );
509 StopCheckInAnimation();
511 FadeOutImage( checkBox, Foreground, checkedImage, opacity );
512 FadeOutImage( checkBox, Background, backgroundImage );
514 FadeInImage( checkBox, disabledCheckedImage );
515 FadeInImage( checkBox, disabledBackgroundImage );
517 StartCheckOutAnimation( checkBox );
518 StartCheckInAnimation();
520 mPaintState = CheckedDisabledTransition;
524 case CheckedUncheckedTransition:
529 if( fadeOutCheckedImage )
531 opacity = fadeOutCheckedImage.GetCurrentOpacity();
533 StopCheckOutAnimation( checkBox );
534 StopCheckInAnimation();
536 button.Add( disabledCheckedImage );
537 FadeOutImage( checkBox, Foreground, disabledCheckedImage, opacity );
538 FadeOutImage( checkBox, Background, backgroundImage );
540 FadeInImage( checkBox, disabledBackgroundImage );
542 StartCheckOutAnimation( checkBox );
543 StartCheckInAnimation();
545 mPaintState = UncheckedDisabledTransition;
549 case UncheckedDisabledTransition:
554 if( fadeOutBackgroundImage )
556 opacity = fadeOutBackgroundImage.GetCurrentOpacity();
558 StopCheckOutAnimation( checkBox, false );
559 StopCheckInAnimation();
561 FadeOutImage( checkBox, Background, disabledBackgroundImage, 1.f - opacity );
562 FadeInImage( checkBox, backgroundImage, opacity );
564 StartCheckOutAnimation( checkBox );
565 StartCheckInAnimation();
567 mPaintState = DisabledUncheckedTransition;
571 case DisabledUncheckedTransition:
576 if( fadeOutBackgroundImage )
578 opacity = fadeOutBackgroundImage.GetCurrentOpacity();
580 StopCheckOutAnimation( checkBox, false );
581 StopCheckInAnimation();
583 FadeOutImage( checkBox, Background, backgroundImage, 1.f - opacity );
584 FadeInImage( checkBox, disabledBackgroundImage, opacity );
586 StartCheckOutAnimation( checkBox );
587 StartCheckInAnimation();
589 mPaintState = UncheckedDisabledTransition;
593 case CheckedDisabledTransition:
598 if( fadeOutBackgroundImage )
600 opacity = fadeOutBackgroundImage.GetCurrentOpacity();
602 StopCheckOutAnimation( checkBox, false );
603 StopCheckInAnimation();
605 FadeOutImage( checkBox, Foreground, disabledCheckedImage, 1.f - opacity );
606 FadeOutImage( checkBox, Background, disabledBackgroundImage, 1.f - opacity );
607 FadeInImage( checkBox, checkedImage, opacity );
608 FadeInImage( checkBox, backgroundImage, opacity );
610 StartCheckOutAnimation( checkBox );
611 StartCheckInAnimation();
613 mPaintState = DisabledCheckedTransition;
617 case DisabledCheckedTransition:
622 if( fadeOutBackgroundImage )
624 opacity = fadeOutBackgroundImage.GetCurrentOpacity();
626 StopCheckOutAnimation( checkBox, false );
627 StopCheckInAnimation();
629 FadeOutImage( checkBox, Foreground, checkedImage, 1.f - opacity );
630 FadeOutImage( checkBox, Background, backgroundImage, 1.f - opacity );
631 FadeInImage( checkBox, disabledCheckedImage, opacity );
632 FadeInImage( checkBox, disabledBackgroundImage, opacity );
634 StartCheckOutAnimation( checkBox );
635 StartCheckInAnimation();
637 mPaintState = CheckedDisabledTransition;
646 void CheckBoxButtonDefaultPainter::SetAnimationTime( float animationTime )
648 mAnimationTime = animationTime;
651 float CheckBoxButtonDefaultPainter::GetAnimationTime() const
653 return mAnimationTime;
656 void CheckBoxButtonDefaultPainter::Checked( Toolkit::CheckBoxButton& button )
658 Toolkit::Internal::CheckBoxButton& checkBoxImpl = GetCheckBoxButtonImpl( button );
659 Actor& checkedImage = checkBoxImpl.GetCheckedImage();
660 Actor& fadeOutCheckedImage = checkBoxImpl.GetFadeOutCheckedImage();
662 switch( mPaintState )
666 // Fade in the 'check' actor.
667 FadeInImage( button, checkedImage );
668 SetupCheckedAnimation( button, checkedImage ); // Animate in the check actor
669 StartCheckInAnimation();
671 mPaintState = UncheckedCheckedTransition;
676 // Fade out the 'check' actor.
677 StopCheckOutAnimation( button );
678 FadeOutImage( button, Foreground, checkedImage );
679 StartCheckOutAnimation( button );
681 mPaintState = UncheckedState;
684 case UncheckedCheckedTransition:
686 // Stop fade in and start fade out.
687 StopCheckOutAnimation( button );
688 StopCheckInAnimation();
693 opacity = checkedImage.GetCurrentOpacity();
695 FadeOutImage( button, Foreground, checkedImage, opacity );
696 StartCheckOutAnimation( button );
698 mPaintState = UncheckedState;
701 case CheckedUncheckedTransition:
703 // Stop fade out and start fade in.
705 if( fadeOutCheckedImage )
707 opacity = fadeOutCheckedImage.GetCurrentOpacity();
709 StopCheckOutAnimation( button );
711 FadeInImage( button, checkedImage, opacity );
712 StartCheckInAnimation();
714 mPaintState = UncheckedCheckedTransition;
722 void CheckBoxButtonDefaultPainter::ApplyConstraint( Actor& actor, float depth )
726 actor.RemoveConstraints();
727 actor.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
732 void CheckBoxButtonDefaultPainter::ApplyCheckedConstraint( Actor& actor, float depth )
736 actor.RemoveConstraints();
737 actor.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
742 void CheckBoxButtonDefaultPainter::AddToFadeInAnimation( const Actor& actor )
744 if( !mCheckInAnimation )
746 mCheckInAnimation = Dali::Animation::New( mAnimationTime );
749 mCheckInAnimation.OpacityTo( actor, 1.f );
753 void CheckBoxButtonDefaultPainter::StartCheckInAnimation()
755 if( mCheckInAnimation )
757 mCheckInAnimation.FinishedSignal().Connect( this, &CheckBoxButtonDefaultPainter::CheckInAnimationFinished );
758 mCheckInAnimation.Play();
762 void CheckBoxButtonDefaultPainter::StopCheckInAnimation()
764 if( mCheckInAnimation )
766 mCheckInAnimation.Clear();
767 mCheckInAnimation.Reset();
771 void CheckBoxButtonDefaultPainter::AddToFadeOutAnimation( const Actor& actor )
773 if( !mCheckOutAnimation )
775 mCheckOutAnimation = Dali::Animation::New( mAnimationTime );
778 mCheckOutAnimation.OpacityTo( actor, 0.f );
781 void CheckBoxButtonDefaultPainter::StartCheckOutAnimation( Toolkit::CheckBoxButton& checkBox )
783 if( mCheckOutAnimation )
785 Toolkit::Internal::CheckBoxButton& checkBoxImpl = GetCheckBoxButtonImpl( checkBox );
786 mButton = &checkBoxImpl;
788 mCheckOutAnimation.FinishedSignal().Connect( this, &CheckBoxButtonDefaultPainter::CheckOutAnimationFinished );
789 mCheckOutAnimation.Play();
793 void CheckBoxButtonDefaultPainter::StopCheckOutAnimation( Toolkit::CheckBoxButton& checkBox, bool remove )
795 if( mCheckOutAnimation )
797 mCheckOutAnimation.Clear();
798 mCheckOutAnimation.Reset();
801 Toolkit::Internal::CheckBoxButton& checkBoxImpl = GetCheckBoxButtonImpl( checkBox );
802 Actor& fadeOutCheckedImage = checkBoxImpl.GetFadeOutCheckedImage();
803 Actor& fadeOutBackgroundImage = checkBoxImpl.GetFadeOutBackgroundImage();
807 if( fadeOutCheckedImage && fadeOutCheckedImage.GetParent() )
809 fadeOutCheckedImage.GetParent().Remove( fadeOutCheckedImage );
812 if( fadeOutBackgroundImage && fadeOutBackgroundImage.GetParent() )
814 fadeOutBackgroundImage.GetParent().Remove( fadeOutBackgroundImage );
817 fadeOutCheckedImage.Reset();
818 fadeOutBackgroundImage.Reset();
822 void CheckBoxButtonDefaultPainter::FadeInImage( Toolkit::CheckBoxButton& checkBox, Actor& image, float opacity )
826 if( !image.GetParent() )
828 checkBox.Add( image );
831 image.SetOpacity( 1.0f );
835 void CheckBoxButtonDefaultPainter::FadeOutImage( Toolkit::CheckBoxButton& checkBox, ImageLayer layer, Actor& image, float opacity )
839 Toolkit::Internal::CheckBoxButton& checkBoxImpl = GetCheckBoxButtonImpl( checkBox );
840 Actor& fadeOutCheckedImage = checkBoxImpl.GetFadeOutCheckedImage();
841 Actor& fadeOutBackgroundImage = checkBoxImpl.GetFadeOutBackgroundImage();
843 Actor& actorLayer = ( ( Background == layer ) ? fadeOutBackgroundImage : fadeOutCheckedImage );
847 actorLayer.SetOpacity( 0.0f );
851 void CheckBoxButtonDefaultPainter::AddToCheckInAnimation( const Actor& actor )
853 if( !mCheckInAnimation )
855 mCheckInAnimation = Dali::Animation::New( mAnimationTime );
859 mCheckInAnimation.AnimateTo( Property( mTickUVEffect, mTickUVEffect.GetBottomRightPropertyName() ), Vector2( 1.0f, 1.0f ) );
862 Handle handle = actor; // Get rid of const
863 mCheckInAnimation.AnimateTo( Property( handle, Actor::SCALE_X ), 1.0f);
866 void CheckBoxButtonDefaultPainter::SetupCheckedAnimation( Toolkit::CheckBoxButton& checkBox, Actor& image )
872 ImageActor imageActor = ImageActor::DownCast( image );
873 mTickUVEffect = ImageRegionEffect::New();
874 imageActor.SetShaderEffect( mTickUVEffect );
877 image.SetScale( Vector3( 0.0f, 1.0f, 1.0f ) );
879 mTickUVEffect.SetBottomRight( Vector2( 0.0f, 1.0f ) );
882 if( !image.GetParent() )
884 checkBox.Add( image );
887 AddToCheckInAnimation( image );
891 void CheckBoxButtonDefaultPainter::EndCheckOutAnimation()
893 switch( mPaintState )
895 case UncheckedCheckedTransition:
897 mPaintState = CheckedState;
900 case CheckedUncheckedTransition:
902 mPaintState = UncheckedState;
905 case UncheckedDisabledTransition:
907 mPaintState = DisabledUncheckedState;
910 case DisabledUncheckedTransition:
912 mPaintState = UncheckedState;
915 case CheckedDisabledTransition:
917 mPaintState = DisabledCheckedState;
920 case DisabledCheckedTransition:
922 mPaintState = CheckedState;
932 void CheckBoxButtonDefaultPainter::CheckOutAnimationFinished( Dali::Animation& source )
934 EndCheckOutAnimation();
936 Toolkit::CheckBoxButton handle( mButton->GetOwner() );
937 StopCheckOutAnimation( handle );
941 void CheckBoxButtonDefaultPainter::CheckInAnimationFinished( Dali::Animation& source )
943 switch( mPaintState )
945 case UncheckedCheckedTransition:
947 mPaintState = CheckedState;
950 case CheckedUncheckedTransition:
952 mPaintState = UncheckedState;
955 case UncheckedDisabledTransition:
957 mPaintState = DisabledUncheckedState;
960 case DisabledUncheckedTransition:
962 mPaintState = UncheckedState;
965 case CheckedDisabledTransition:
967 mPaintState = DisabledCheckedState;
970 case DisabledCheckedTransition:
972 mPaintState = CheckedState;
981 StopCheckInAnimation();
984 } // namespace Internal
986 } // namespace Toolkit