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
46 * Constraint to wrap an actor in y that is moving vertically
48 Vector3 EqualToPercentageWidthConstraint( const Vector3& current,
49 const PropertyInput& percentageProperty,
50 const PropertyInput& parentSizeProperty )
52 float percentage = percentageProperty.GetFloat();
53 const Vector3& parentSize = parentSizeProperty.GetVector3();
55 Vector3 size( parentSize );
62 inline Toolkit::Internal::CheckBoxButton& GetCheckBoxButtonImpl( Toolkit::Button& button )
64 DALI_ASSERT_ALWAYS( button );
66 Dali::RefObject& handle = button.GetImplementation();
68 return static_cast<Toolkit::Internal::CheckBoxButton&>( handle );
71 inline const Toolkit::Internal::CheckBoxButton& GetCheckBoxButtonImpl( const Toolkit::Button& button )
73 DALI_ASSERT_ALWAYS( button );
75 const Dali::RefObject& handle = button.GetImplementation();
77 return static_cast<const Toolkit::Internal::CheckBoxButton&>( handle );
82 CheckBoxButtonDefaultPainter::CheckBoxButtonDefaultPainter()
83 : CheckBoxButtonPainter(),
85 mPaintState( UncheckedState ),
87 mAnimationTime( ANIMATION_TIME )
91 CheckBoxButtonDefaultPainter::~CheckBoxButtonDefaultPainter()
93 if( mCheckInAnimation )
95 mCheckInAnimation.Clear();
97 if( mCheckOutAnimation )
99 mCheckOutAnimation.Clear();
103 void CheckBoxButtonDefaultPainter::SetBackgroundImage( Toolkit::CheckBoxButton& checkBox, Actor image )
105 Toolkit::Internal::CheckBoxButton& checkBoxImpl = GetImplementation( checkBox );
106 Actor& backgroundImage = checkBoxImpl.GetBackgroundImage();
107 Actor& fadeOutBackgroundImage = checkBoxImpl.GetFadeOutBackgroundImage();
109 switch( mPaintState )
111 case UncheckedState: // FALLTHROUGH
113 case UncheckedCheckedTransition:
114 case CheckedUncheckedTransition:
116 if( backgroundImage && backgroundImage.GetParent() )
118 StopCheckOutAnimation( checkBox );
119 FadeOutImage( checkBox, Background, backgroundImage );
121 backgroundImage = image;
123 FadeInImage( checkBox, backgroundImage );
125 StartCheckOutAnimation( checkBox );
126 StartCheckInAnimation();
130 backgroundImage = image;
131 checkBox.Add( backgroundImage );
135 case DisabledUncheckedTransition: // FALLTHROUGH
136 case DisabledCheckedTransition:
138 StopCheckInAnimation();
139 checkBox.Remove( backgroundImage );
141 backgroundImage = image;
143 FadeInImage( checkBox, backgroundImage );
144 StartCheckInAnimation();
147 case CheckedDisabledTransition: // FALLTHROUGH
148 case UncheckedDisabledTransition:
151 if( fadeOutBackgroundImage )
153 opacity = fadeOutBackgroundImage.GetCurrentOpacity();
155 StopCheckOutAnimation( checkBox );
157 // Replaces the button image.
158 backgroundImage = image;
160 checkBox.Add( backgroundImage );
161 FadeOutImage( checkBox, Background, backgroundImage, opacity );
163 StartCheckOutAnimation( checkBox );
168 backgroundImage = image;
173 backgroundImage.SetAnchorPoint( AnchorPoint::TOP_LEFT );
174 backgroundImage.SetParentOrigin( ParentOrigin::TOP_LEFT );
175 ApplyConstraint( backgroundImage, BACKGROUND_DEPTH );
178 void CheckBoxButtonDefaultPainter::SetCheckedImage( Toolkit::CheckBoxButton& checkBox, Actor image )
180 Toolkit::Internal::CheckBoxButton& checkBoxImpl = GetImplementation( checkBox );
181 Actor& checkedImage = checkBoxImpl.GetCheckedImage();
182 Actor& fadeOutCheckedImage = checkBoxImpl.GetFadeOutCheckedImage();
184 switch( mPaintState )
188 if( checkedImage && checkedImage.GetParent() )
190 StopCheckOutAnimation( checkBox );
191 FadeOutImage( checkBox, Foreground, checkedImage );
193 checkedImage = image;
195 FadeInImage( checkBox, checkedImage );
197 StartCheckOutAnimation( checkBox );
198 StartCheckInAnimation();
202 checkedImage = image;
203 checkBox.Add( checkedImage );
207 case UncheckedCheckedTransition: // FALLTHROUGH
208 case DisabledCheckedTransition:
210 StopCheckInAnimation();
211 checkBox.Remove( checkedImage );
213 checkedImage = image;
215 FadeInImage( checkBox, checkedImage );
216 StartCheckInAnimation();
219 case CheckedUncheckedTransition: // FALLTHROUGH
220 case CheckedDisabledTransition:
223 if( fadeOutCheckedImage )
225 opacity = fadeOutCheckedImage.GetCurrentOpacity();
227 StopCheckOutAnimation( checkBox );
229 // Replaces the button image.
230 checkedImage = image;
232 checkBox.Add( checkedImage );
233 FadeOutImage( checkBox, Foreground, checkedImage, opacity );
235 StartCheckOutAnimation( checkBox );
240 checkedImage = image;
245 checkedImage.SetAnchorPoint( AnchorPoint::TOP_LEFT );
246 checkedImage.SetParentOrigin( ParentOrigin::TOP_LEFT );
247 ApplyCheckedConstraint( checkedImage, FOREGROUND_DEPTH );
250 void CheckBoxButtonDefaultPainter::SetDisabledCheckedImage( Toolkit::CheckBoxButton& checkBox, Actor image )
252 Toolkit::Internal::CheckBoxButton& checkBoxImpl = GetImplementation( checkBox );
253 Actor& disabledCheckedImage = checkBoxImpl.GetDisabledCheckedImage();
254 Actor& fadeOutCheckedImage = checkBoxImpl.GetFadeOutCheckedImage();
256 switch( mPaintState )
258 case DisabledCheckedState:
260 if( disabledCheckedImage && disabledCheckedImage.GetParent() )
262 StopCheckOutAnimation( checkBox );
263 FadeOutImage( checkBox, Foreground, disabledCheckedImage );
265 disabledCheckedImage = image;
267 FadeInImage( checkBox, disabledCheckedImage );
269 StartCheckOutAnimation( checkBox );
270 StartCheckInAnimation();
274 disabledCheckedImage = image;
275 checkBox.Add( disabledCheckedImage );
279 case CheckedDisabledTransition:
281 StopCheckInAnimation();
282 checkBox.Remove( disabledCheckedImage );
284 disabledCheckedImage = image;
286 FadeInImage( checkBox, disabledCheckedImage );
287 StartCheckInAnimation();
290 case DisabledCheckedTransition:
293 if( fadeOutCheckedImage )
295 opacity = fadeOutCheckedImage.GetCurrentOpacity();
297 StopCheckOutAnimation( checkBox );
299 // Replaces the button image.
300 disabledCheckedImage = image;
302 checkBox.Add( disabledCheckedImage );
303 FadeOutImage( checkBox, Foreground, disabledCheckedImage, opacity );
305 StartCheckOutAnimation( checkBox );
310 disabledCheckedImage = image;
315 disabledCheckedImage.SetAnchorPoint( AnchorPoint::TOP_LEFT );
316 disabledCheckedImage.SetParentOrigin( ParentOrigin::TOP_LEFT );
317 ApplyConstraint( disabledCheckedImage, FOREGROUND_DEPTH );
320 void CheckBoxButtonDefaultPainter::SetDisabledBackgroundImage( Toolkit::CheckBoxButton& checkBox, Actor image )
322 Toolkit::Internal::CheckBoxButton& checkBoxImpl = GetImplementation( checkBox );
323 Actor& disabledBackgroundImage = checkBoxImpl.GetDisabledBackgroundImage();
324 Actor& fadeOutBackgroundImage = checkBoxImpl.GetFadeOutBackgroundImage();
326 switch( mPaintState )
328 case DisabledCheckedState: // FALLTHROUGH
329 case DisabledUncheckedState:
331 if( disabledBackgroundImage && disabledBackgroundImage.GetParent() )
333 StopCheckOutAnimation( checkBox );
334 FadeOutImage( checkBox, Background, disabledBackgroundImage );
336 disabledBackgroundImage = image;
338 FadeInImage( checkBox, disabledBackgroundImage );
340 StartCheckOutAnimation( checkBox );
341 StartCheckInAnimation();
345 disabledBackgroundImage = image;
346 checkBox.Add( disabledBackgroundImage );
350 case UncheckedDisabledTransition: // FALLTHROUGH
351 case CheckedDisabledTransition:
353 StopCheckInAnimation();
354 checkBox.Remove( disabledBackgroundImage );
356 disabledBackgroundImage = image;
358 FadeInImage( checkBox, disabledBackgroundImage );
359 StartCheckInAnimation();
362 case DisabledUncheckedTransition: // FALLTHROUGH
363 case DisabledCheckedTransition:
366 if( fadeOutBackgroundImage )
368 opacity = fadeOutBackgroundImage.GetCurrentOpacity();
370 StopCheckOutAnimation( checkBox );
372 // Replaces the button image.
373 disabledBackgroundImage = image;
375 checkBox.Add( disabledBackgroundImage );
376 FadeOutImage( checkBox, Background, disabledBackgroundImage, opacity );
378 StartCheckOutAnimation( checkBox );
383 disabledBackgroundImage = image;
388 disabledBackgroundImage.SetAnchorPoint( AnchorPoint::TOP_LEFT );
389 disabledBackgroundImage.SetParentOrigin( ParentOrigin::TOP_LEFT );
390 ApplyConstraint( disabledBackgroundImage, BACKGROUND_DEPTH );
393 void CheckBoxButtonDefaultPainter::Initialize( Toolkit::Button& button )
395 Toolkit::Internal::CheckBoxButton& buttonImpl = GetCheckBoxButtonImpl( button );
396 Actor& backgroundImage = buttonImpl.GetBackgroundImage();
397 Actor& checkedImage = buttonImpl.GetCheckedImage();
398 Actor& disabledBackgroundImage = buttonImpl.GetDisabledBackgroundImage();
399 Actor& disabledCheckedImage = buttonImpl.GetDisabledCheckedImage();
401 Toolkit::CheckBoxButton& checkBox = static_cast<Toolkit::CheckBoxButton&>( button );
403 if( backgroundImage )
405 SetBackgroundImage( checkBox, backgroundImage );
410 SetCheckedImage( checkBox, checkedImage );
413 if( disabledBackgroundImage )
415 SetDisabledBackgroundImage( checkBox, disabledBackgroundImage );
418 if( disabledCheckedImage )
420 SetDisabledCheckedImage( checkBox, disabledCheckedImage );
423 SetDisabled( button, mDisabled );
426 void CheckBoxButtonDefaultPainter::SetSize( Toolkit::Button& button, const Vector3& size )
428 Toolkit::Internal::CheckBoxButton& buttonImpl = GetCheckBoxButtonImpl( button );
429 Actor& backgroundImage = buttonImpl.GetBackgroundImage();
430 Actor& checkedImage = buttonImpl.GetCheckedImage();
431 Actor& disabledBackgroundImage = buttonImpl.GetDisabledBackgroundImage();
432 Actor& disabledCheckedImage = buttonImpl.GetDisabledCheckedImage();
434 ApplyCheckedConstraint( checkedImage, FOREGROUND_DEPTH );
435 ApplyConstraint( backgroundImage, BACKGROUND_DEPTH );
436 ApplyConstraint( disabledCheckedImage, FOREGROUND_DEPTH );
437 ApplyConstraint( disabledBackgroundImage, BACKGROUND_DEPTH );
440 void CheckBoxButtonDefaultPainter::SetDisabled( Toolkit::Button& button, bool disabled )
442 mDisabled = disabled;
444 Toolkit::Internal::CheckBoxButton& buttonImpl = GetCheckBoxButtonImpl( button );
445 Actor& backgroundImage = buttonImpl.GetBackgroundImage();
446 Actor& checkedImage = buttonImpl.GetCheckedImage();
447 Actor& disabledBackgroundImage = buttonImpl.GetDisabledBackgroundImage();
448 Actor& disabledCheckedImage = buttonImpl.GetDisabledCheckedImage();
449 Actor& fadeOutCheckedImage = buttonImpl.GetFadeOutCheckedImage();
450 Actor& fadeOutBackgroundImage = buttonImpl.GetFadeOutBackgroundImage();
452 Toolkit::CheckBoxButton& checkBox = static_cast<Toolkit::CheckBoxButton&>( button );
454 switch( mPaintState )
460 StopCheckOutAnimation( checkBox );
461 FadeOutImage( checkBox, Background, backgroundImage );
462 FadeInImage( checkBox, disabledBackgroundImage );
463 StartCheckOutAnimation( checkBox );
464 StartCheckInAnimation();
466 mPaintState = UncheckedDisabledTransition;
474 StopCheckOutAnimation( checkBox );
475 FadeOutImage( checkBox, Background, backgroundImage );
476 FadeOutImage( checkBox, Foreground, checkedImage );
477 FadeInImage( checkBox, disabledCheckedImage );
478 FadeInImage( checkBox, disabledBackgroundImage );
479 StartCheckOutAnimation( checkBox );
480 StartCheckInAnimation();
482 mPaintState = CheckedDisabledTransition;
486 case DisabledUncheckedState:
490 StopCheckOutAnimation( checkBox );
491 FadeOutImage( checkBox, Background, disabledBackgroundImage );
492 FadeInImage( checkBox, backgroundImage );
493 StartCheckOutAnimation( checkBox );
494 StartCheckInAnimation();
496 mPaintState = DisabledUncheckedTransition;
500 case DisabledCheckedState:
504 StopCheckOutAnimation( checkBox );
505 FadeOutImage( checkBox, Background, disabledBackgroundImage );
506 FadeOutImage( checkBox, Foreground, disabledCheckedImage );
507 FadeInImage( checkBox, backgroundImage );
508 FadeInImage( checkBox, checkedImage );
509 StartCheckOutAnimation( checkBox );
510 StartCheckInAnimation();
512 mPaintState = DisabledCheckedTransition;
516 case UncheckedCheckedTransition:
523 opacity = checkedImage.GetCurrentOpacity();
525 StopCheckOutAnimation( checkBox );
526 StopCheckInAnimation();
528 FadeOutImage( checkBox, Foreground, checkedImage, opacity );
529 FadeOutImage( checkBox, Background, backgroundImage );
531 FadeInImage( checkBox, disabledCheckedImage );
532 FadeInImage( checkBox, disabledBackgroundImage );
534 StartCheckOutAnimation( checkBox );
535 StartCheckInAnimation();
537 mPaintState = CheckedDisabledTransition;
541 case CheckedUncheckedTransition:
546 if( fadeOutCheckedImage )
548 opacity = fadeOutCheckedImage.GetCurrentOpacity();
550 StopCheckOutAnimation( checkBox );
551 StopCheckInAnimation();
553 button.Add( disabledCheckedImage );
554 FadeOutImage( checkBox, Foreground, disabledCheckedImage, opacity );
555 FadeOutImage( checkBox, Background, backgroundImage );
557 FadeInImage( checkBox, disabledBackgroundImage );
559 StartCheckOutAnimation( checkBox );
560 StartCheckInAnimation();
562 mPaintState = UncheckedDisabledTransition;
566 case UncheckedDisabledTransition:
571 if( fadeOutBackgroundImage )
573 opacity = fadeOutBackgroundImage.GetCurrentOpacity();
575 StopCheckOutAnimation( checkBox, false );
576 StopCheckInAnimation();
578 FadeOutImage( checkBox, Background, disabledBackgroundImage, 1.f - opacity );
579 FadeInImage( checkBox, backgroundImage, opacity );
581 StartCheckOutAnimation( checkBox );
582 StartCheckInAnimation();
584 mPaintState = DisabledUncheckedTransition;
588 case DisabledUncheckedTransition:
593 if( fadeOutBackgroundImage )
595 opacity = fadeOutBackgroundImage.GetCurrentOpacity();
597 StopCheckOutAnimation( checkBox, false );
598 StopCheckInAnimation();
600 FadeOutImage( checkBox, Background, backgroundImage, 1.f - opacity );
601 FadeInImage( checkBox, disabledBackgroundImage, opacity );
603 StartCheckOutAnimation( checkBox );
604 StartCheckInAnimation();
606 mPaintState = UncheckedDisabledTransition;
610 case CheckedDisabledTransition:
615 if( fadeOutBackgroundImage )
617 opacity = fadeOutBackgroundImage.GetCurrentOpacity();
619 StopCheckOutAnimation( checkBox, false );
620 StopCheckInAnimation();
622 FadeOutImage( checkBox, Foreground, disabledCheckedImage, 1.f - opacity );
623 FadeOutImage( checkBox, Background, disabledBackgroundImage, 1.f - opacity );
624 FadeInImage( checkBox, checkedImage, opacity );
625 FadeInImage( checkBox, backgroundImage, opacity );
627 StartCheckOutAnimation( checkBox );
628 StartCheckInAnimation();
630 mPaintState = DisabledCheckedTransition;
634 case DisabledCheckedTransition:
639 if( fadeOutBackgroundImage )
641 opacity = fadeOutBackgroundImage.GetCurrentOpacity();
643 StopCheckOutAnimation( checkBox, false );
644 StopCheckInAnimation();
646 FadeOutImage( checkBox, Foreground, checkedImage, 1.f - opacity );
647 FadeOutImage( checkBox, Background, backgroundImage, 1.f - opacity );
648 FadeInImage( checkBox, disabledCheckedImage, opacity );
649 FadeInImage( checkBox, disabledBackgroundImage, opacity );
651 StartCheckOutAnimation( checkBox );
652 StartCheckInAnimation();
654 mPaintState = CheckedDisabledTransition;
663 void CheckBoxButtonDefaultPainter::SetAnimationTime( float animationTime )
665 mAnimationTime = animationTime;
668 float CheckBoxButtonDefaultPainter::GetAnimationTime() const
670 return mAnimationTime;
673 void CheckBoxButtonDefaultPainter::Checked( Toolkit::CheckBoxButton& button )
675 Toolkit::Internal::CheckBoxButton& checkBoxImpl = GetCheckBoxButtonImpl( button );
676 Actor& checkedImage = checkBoxImpl.GetCheckedImage();
677 Actor& fadeOutCheckedImage = checkBoxImpl.GetFadeOutCheckedImage();
679 switch( mPaintState )
683 // Fade in the 'check' actor.
684 FadeInImage( button, checkedImage );
685 SetupCheckedAnimation( button, checkedImage ); // Animate in the check actor
686 StartCheckInAnimation();
688 mPaintState = UncheckedCheckedTransition;
693 // Fade out the 'check' actor.
694 StopCheckOutAnimation( button );
695 FadeOutImage( button, Foreground, checkedImage );
696 StartCheckOutAnimation( button );
698 mPaintState = UncheckedState;
701 case UncheckedCheckedTransition:
703 // Stop fade in and start fade out.
704 StopCheckOutAnimation( button );
705 StopCheckInAnimation();
710 opacity = checkedImage.GetCurrentOpacity();
712 FadeOutImage( button, Foreground, checkedImage, opacity );
713 StartCheckOutAnimation( button );
715 mPaintState = UncheckedState;
718 case CheckedUncheckedTransition:
720 // Stop fade out and start fade in.
722 if( fadeOutCheckedImage )
724 opacity = fadeOutCheckedImage.GetCurrentOpacity();
726 StopCheckOutAnimation( button );
728 FadeInImage( button, checkedImage, opacity );
729 StartCheckInAnimation();
731 mPaintState = UncheckedCheckedTransition;
739 void CheckBoxButtonDefaultPainter::ApplyConstraint( Actor& actor, float depth )
743 actor.RemoveConstraints();
744 actor.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
749 void CheckBoxButtonDefaultPainter::ApplyCheckedConstraint( Actor& actor, float depth )
753 actor.RemoveConstraints();
754 actor.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
759 void CheckBoxButtonDefaultPainter::AddToFadeInAnimation( const Actor& actor )
761 if( !mCheckInAnimation )
763 mCheckInAnimation = Dali::Animation::New( mAnimationTime );
766 mCheckInAnimation.OpacityTo( actor, 1.f );
770 void CheckBoxButtonDefaultPainter::StartCheckInAnimation()
772 if( mCheckInAnimation )
774 mCheckInAnimation.FinishedSignal().Connect( this, &CheckBoxButtonDefaultPainter::CheckInAnimationFinished );
775 mCheckInAnimation.Play();
779 void CheckBoxButtonDefaultPainter::StopCheckInAnimation()
781 if( mCheckInAnimation )
783 mCheckInAnimation.Clear();
784 mCheckInAnimation.Reset();
788 void CheckBoxButtonDefaultPainter::AddToFadeOutAnimation( const Actor& actor )
790 if( !mCheckOutAnimation )
792 mCheckOutAnimation = Dali::Animation::New( mAnimationTime );
795 mCheckOutAnimation.OpacityTo( actor, 0.f );
798 void CheckBoxButtonDefaultPainter::StartCheckOutAnimation( Toolkit::CheckBoxButton& checkBox )
800 if( mCheckOutAnimation )
802 Toolkit::Internal::CheckBoxButton& checkBoxImpl = GetCheckBoxButtonImpl( checkBox );
803 mButton = &checkBoxImpl;
805 mCheckOutAnimation.FinishedSignal().Connect( this, &CheckBoxButtonDefaultPainter::CheckOutAnimationFinished );
806 mCheckOutAnimation.Play();
810 void CheckBoxButtonDefaultPainter::StopCheckOutAnimation( Toolkit::CheckBoxButton& checkBox, bool remove )
812 if( mCheckOutAnimation )
814 mCheckOutAnimation.Clear();
815 mCheckOutAnimation.Reset();
818 Toolkit::Internal::CheckBoxButton& checkBoxImpl = GetCheckBoxButtonImpl( checkBox );
819 Actor& fadeOutCheckedImage = checkBoxImpl.GetFadeOutCheckedImage();
820 Actor& fadeOutBackgroundImage = checkBoxImpl.GetFadeOutBackgroundImage();
824 if( fadeOutCheckedImage && fadeOutCheckedImage.GetParent() )
826 fadeOutCheckedImage.GetParent().Remove( fadeOutCheckedImage );
829 if( fadeOutBackgroundImage && fadeOutBackgroundImage.GetParent() )
831 fadeOutBackgroundImage.GetParent().Remove( fadeOutBackgroundImage );
834 fadeOutCheckedImage.Reset();
835 fadeOutBackgroundImage.Reset();
839 void CheckBoxButtonDefaultPainter::FadeInImage( Toolkit::CheckBoxButton& checkBox, Actor& image, float opacity )
843 if( !image.GetParent() )
845 checkBox.Add( image );
848 image.SetOpacity( 1.0f );
852 void CheckBoxButtonDefaultPainter::FadeOutImage( Toolkit::CheckBoxButton& checkBox, ImageLayer layer, Actor& image, float opacity )
856 Toolkit::Internal::CheckBoxButton& checkBoxImpl = GetCheckBoxButtonImpl( checkBox );
857 Actor& fadeOutCheckedImage = checkBoxImpl.GetFadeOutCheckedImage();
858 Actor& fadeOutBackgroundImage = checkBoxImpl.GetFadeOutBackgroundImage();
860 Actor& actorLayer = ( ( Background == layer ) ? fadeOutBackgroundImage : fadeOutCheckedImage );
864 actorLayer.SetOpacity( 0.0f );
868 void CheckBoxButtonDefaultPainter::AddToCheckInAnimation( const Actor& actor )
870 if( !mCheckInAnimation )
872 mCheckInAnimation = Dali::Animation::New( mAnimationTime );
876 mCheckInAnimation.AnimateTo( Property( mTickUVEffect, mTickUVEffect.GetBottomRightPropertyName() ), Vector2( 1.0f, 1.0f ) );
879 Handle handle = actor; // Get rid of const
880 mCheckInAnimation.AnimateTo( Property( handle, Actor::SCALE_X ), 1.0f);
883 void CheckBoxButtonDefaultPainter::SetupCheckedAnimation( Toolkit::CheckBoxButton& checkBox, Actor& image )
889 ImageActor imageActor = ImageActor::DownCast( image );
890 mTickUVEffect = ImageRegionEffect::New();
891 imageActor.SetShaderEffect( mTickUVEffect );
894 image.SetScale( Vector3( 0.0f, 1.0f, 1.0f ) );
896 mTickUVEffect.SetBottomRight( Vector2( 0.0f, 1.0f ) );
899 if( !image.GetParent() )
901 checkBox.Add( image );
904 AddToCheckInAnimation( image );
908 void CheckBoxButtonDefaultPainter::EndCheckOutAnimation()
910 switch( mPaintState )
912 case UncheckedCheckedTransition:
914 mPaintState = CheckedState;
917 case CheckedUncheckedTransition:
919 mPaintState = UncheckedState;
922 case UncheckedDisabledTransition:
924 mPaintState = DisabledUncheckedState;
927 case DisabledUncheckedTransition:
929 mPaintState = UncheckedState;
932 case CheckedDisabledTransition:
934 mPaintState = DisabledCheckedState;
937 case DisabledCheckedTransition:
939 mPaintState = CheckedState;
949 void CheckBoxButtonDefaultPainter::CheckOutAnimationFinished( Dali::Animation& source )
951 EndCheckOutAnimation();
953 Toolkit::CheckBoxButton handle( mButton->GetOwner() );
954 StopCheckOutAnimation( handle );
958 void CheckBoxButtonDefaultPainter::CheckInAnimationFinished( Dali::Animation& source )
960 switch( mPaintState )
962 case UncheckedCheckedTransition:
964 mPaintState = CheckedState;
967 case CheckedUncheckedTransition:
969 mPaintState = UncheckedState;
972 case UncheckedDisabledTransition:
974 mPaintState = DisabledUncheckedState;
977 case DisabledUncheckedTransition:
979 mPaintState = UncheckedState;
982 case CheckedDisabledTransition:
984 mPaintState = DisabledCheckedState;
987 case DisabledCheckedTransition:
989 mPaintState = CheckedState;
998 StopCheckInAnimation();
1001 } // namespace Internal
1003 } // namespace Toolkit