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( UnselectedState ),
70 mAnimationTime( ANIMATION_TIME )
74 CheckBoxButtonDefaultPainter::~CheckBoxButtonDefaultPainter()
76 if( mCheckInAnimation )
78 mCheckInAnimation.Clear();
80 if( mCheckOutAnimation )
82 mCheckOutAnimation.Clear();
86 void CheckBoxButtonDefaultPainter::Initialize( Toolkit::Button& button )
88 Toolkit::Internal::CheckBoxButton& buttonImpl = GetCheckBoxButtonImpl( button );
89 Actor& backgroundImage = buttonImpl.GetBackgroundImage();
90 Actor& selectedImage = buttonImpl.GetSelectedImage();
91 Actor& disabledBackgroundImage = buttonImpl.GetDisabledBackgroundImage();
92 Actor& disabledSelectedImage = buttonImpl.GetDisabledSelectedImage();
94 Toolkit::CheckBoxButton& checkBox = static_cast<Toolkit::CheckBoxButton&>( button );
98 SetBackgroundImage( checkBox, backgroundImage );
103 SetSelectedImage( checkBox, selectedImage );
106 if( disabledBackgroundImage )
108 SetDisabledBackgroundImage( checkBox, disabledBackgroundImage );
111 if( disabledSelectedImage )
113 SetDisabledSelectedImage( checkBox, disabledSelectedImage );
116 SetDisabled( button, mDisabled );
119 void CheckBoxButtonDefaultPainter::SetSize( Toolkit::Button& button, const Vector3& size )
121 Toolkit::Internal::CheckBoxButton& buttonImpl = GetCheckBoxButtonImpl( button );
122 Actor& backgroundImage = buttonImpl.GetBackgroundImage();
123 Actor& selectedImage = buttonImpl.GetSelectedImage();
124 Actor& disabledBackgroundImage = buttonImpl.GetDisabledBackgroundImage();
125 Actor& disabledSelectedImage = buttonImpl.GetDisabledSelectedImage();
127 ApplySelectedConstraint( selectedImage, FOREGROUND_DEPTH );
128 ApplyConstraint( backgroundImage, BACKGROUND_DEPTH );
129 ApplyConstraint( disabledSelectedImage, FOREGROUND_DEPTH );
130 ApplyConstraint( disabledBackgroundImage, BACKGROUND_DEPTH );
133 void CheckBoxButtonDefaultPainter::SetDisabled( Toolkit::Button& button, bool disabled )
135 mDisabled = disabled;
137 Toolkit::Internal::CheckBoxButton& buttonImpl = GetCheckBoxButtonImpl( button );
138 Actor& backgroundImage = buttonImpl.GetBackgroundImage();
139 Actor& selectedImage = buttonImpl.GetSelectedImage();
140 Actor& disabledBackgroundImage = buttonImpl.GetDisabledBackgroundImage();
141 Actor& disabledSelectedImage = buttonImpl.GetDisabledSelectedImage();
142 Actor& fadeOutSelectedImage = buttonImpl.GetFadeOutSelectedImage();
143 Actor& fadeOutBackgroundImage = buttonImpl.GetFadeOutBackgroundImage();
145 Toolkit::CheckBoxButton& checkBox = static_cast<Toolkit::CheckBoxButton&>( button );
147 switch( mPaintState )
149 case UnselectedState:
153 StopCheckOutAnimation( checkBox );
154 FadeOutImage( checkBox, Background, backgroundImage );
155 FadeInImage( checkBox, disabledBackgroundImage );
156 StartCheckOutAnimation( checkBox );
157 StartCheckInAnimation();
159 mPaintState = UnselectedDisabledTransition;
167 StopCheckOutAnimation( checkBox );
168 FadeOutImage( checkBox, Background, backgroundImage );
169 FadeOutImage( checkBox, Foreground, selectedImage );
170 FadeInImage( checkBox, disabledSelectedImage );
171 FadeInImage( checkBox, disabledBackgroundImage );
172 StartCheckOutAnimation( checkBox );
173 StartCheckInAnimation();
175 mPaintState = SelectedDisabledTransition;
179 case DisabledUnselectedState:
183 StopCheckOutAnimation( checkBox );
184 FadeOutImage( checkBox, Background, disabledBackgroundImage );
185 FadeInImage( checkBox, backgroundImage );
186 StartCheckOutAnimation( checkBox );
187 StartCheckInAnimation();
189 mPaintState = DisabledUnselectedTransition;
193 case DisabledSelectedState:
197 StopCheckOutAnimation( checkBox );
198 FadeOutImage( checkBox, Background, disabledBackgroundImage );
199 FadeOutImage( checkBox, Foreground, disabledSelectedImage );
200 FadeInImage( checkBox, backgroundImage );
201 FadeInImage( checkBox, selectedImage );
202 StartCheckOutAnimation( checkBox );
203 StartCheckInAnimation();
205 mPaintState = DisabledSelectedTransition;
209 case UnselectedSelectedTransition:
216 opacity = selectedImage.GetCurrentOpacity();
218 StopCheckOutAnimation( checkBox );
219 StopCheckInAnimation();
221 FadeOutImage( checkBox, Foreground, selectedImage, opacity );
222 FadeOutImage( checkBox, Background, backgroundImage );
224 FadeInImage( checkBox, disabledSelectedImage );
225 FadeInImage( checkBox, disabledBackgroundImage );
227 StartCheckOutAnimation( checkBox );
228 StartCheckInAnimation();
230 mPaintState = SelectedDisabledTransition;
234 case SelectedUnselectedTransition:
239 if( fadeOutSelectedImage )
241 opacity = fadeOutSelectedImage.GetCurrentOpacity();
243 StopCheckOutAnimation( checkBox );
244 StopCheckInAnimation();
246 button.Add( disabledSelectedImage );
247 FadeOutImage( checkBox, Foreground, disabledSelectedImage, opacity );
248 FadeOutImage( checkBox, Background, backgroundImage );
250 FadeInImage( checkBox, disabledBackgroundImage );
252 StartCheckOutAnimation( checkBox );
253 StartCheckInAnimation();
255 mPaintState = UnselectedDisabledTransition;
259 case UnselectedDisabledTransition:
264 if( fadeOutBackgroundImage )
266 opacity = fadeOutBackgroundImage.GetCurrentOpacity();
268 StopCheckOutAnimation( checkBox, false );
269 StopCheckInAnimation();
271 FadeOutImage( checkBox, Background, disabledBackgroundImage, 1.f - opacity );
272 FadeInImage( checkBox, backgroundImage, opacity );
274 StartCheckOutAnimation( checkBox );
275 StartCheckInAnimation();
277 mPaintState = DisabledUnselectedTransition;
281 case DisabledUnselectedTransition:
286 if( fadeOutBackgroundImage )
288 opacity = fadeOutBackgroundImage.GetCurrentOpacity();
290 StopCheckOutAnimation( checkBox, false );
291 StopCheckInAnimation();
293 FadeOutImage( checkBox, Background, backgroundImage, 1.f - opacity );
294 FadeInImage( checkBox, disabledBackgroundImage, opacity );
296 StartCheckOutAnimation( checkBox );
297 StartCheckInAnimation();
299 mPaintState = UnselectedDisabledTransition;
303 case SelectedDisabledTransition:
308 if( fadeOutBackgroundImage )
310 opacity = fadeOutBackgroundImage.GetCurrentOpacity();
312 StopCheckOutAnimation( checkBox, false );
313 StopCheckInAnimation();
315 FadeOutImage( checkBox, Foreground, disabledSelectedImage, 1.f - opacity );
316 FadeOutImage( checkBox, Background, disabledBackgroundImage, 1.f - opacity );
317 FadeInImage( checkBox, selectedImage, opacity );
318 FadeInImage( checkBox, backgroundImage, opacity );
320 StartCheckOutAnimation( checkBox );
321 StartCheckInAnimation();
323 mPaintState = DisabledSelectedTransition;
327 case DisabledSelectedTransition:
332 if( fadeOutBackgroundImage )
334 opacity = fadeOutBackgroundImage.GetCurrentOpacity();
336 StopCheckOutAnimation( checkBox, false );
337 StopCheckInAnimation();
339 FadeOutImage( checkBox, Foreground, selectedImage, 1.f - opacity );
340 FadeOutImage( checkBox, Background, backgroundImage, 1.f - opacity );
341 FadeInImage( checkBox, disabledSelectedImage, opacity );
342 FadeInImage( checkBox, disabledBackgroundImage, opacity );
344 StartCheckOutAnimation( checkBox );
345 StartCheckInAnimation();
347 mPaintState = SelectedDisabledTransition;
356 void CheckBoxButtonDefaultPainter::SetAnimationTime( float animationTime )
358 mAnimationTime = animationTime;
361 float CheckBoxButtonDefaultPainter::GetAnimationTime() const
363 return mAnimationTime;
366 void CheckBoxButtonDefaultPainter::SetSelectedImage( Toolkit::Button& button, Actor image )
368 Toolkit::Internal::CheckBoxButton& checkBoxImpl = GetCheckBoxButtonImpl( button );
369 Actor& selectedImage = checkBoxImpl.GetSelectedImage();
370 Actor& fadeOutSelectedImage = checkBoxImpl.GetFadeOutSelectedImage();
372 Toolkit::CheckBoxButton& checkBox = static_cast<Toolkit::CheckBoxButton&>( button );
374 switch( mPaintState )
378 if( selectedImage && selectedImage.GetParent() )
380 StopCheckOutAnimation( checkBox );
381 FadeOutImage( checkBox, Foreground, selectedImage );
383 selectedImage = image;
385 FadeInImage( checkBox, selectedImage );
387 StartCheckOutAnimation( checkBox );
388 StartCheckInAnimation();
392 selectedImage = image;
393 checkBox.Add( selectedImage );
397 case UnselectedSelectedTransition: // FALLTHROUGH
398 case DisabledSelectedTransition:
400 StopCheckInAnimation();
401 checkBox.Remove( selectedImage );
403 selectedImage = image;
405 FadeInImage( checkBox, selectedImage );
406 StartCheckInAnimation();
409 case SelectedUnselectedTransition: // FALLTHROUGH
410 case SelectedDisabledTransition:
413 if( fadeOutSelectedImage )
415 opacity = fadeOutSelectedImage.GetCurrentOpacity();
417 StopCheckOutAnimation( checkBox );
419 // Replaces the button image.
420 selectedImage = image;
422 checkBox.Add( selectedImage );
423 FadeOutImage( checkBox, Foreground, selectedImage, opacity );
425 StartCheckOutAnimation( checkBox );
430 selectedImage = image;
435 selectedImage.SetAnchorPoint( AnchorPoint::TOP_LEFT );
436 selectedImage.SetParentOrigin( ParentOrigin::TOP_LEFT );
437 ApplySelectedConstraint( selectedImage, FOREGROUND_DEPTH );
440 void CheckBoxButtonDefaultPainter::SetBackgroundImage( Toolkit::Button& button, Actor image )
442 Toolkit::Internal::CheckBoxButton& checkBoxImpl = GetCheckBoxButtonImpl( button );
443 Actor& backgroundImage = checkBoxImpl.GetBackgroundImage();
444 Actor& fadeOutBackgroundImage = checkBoxImpl.GetFadeOutBackgroundImage();
446 Toolkit::CheckBoxButton& checkBox = static_cast<Toolkit::CheckBoxButton&>( button );
448 switch( mPaintState )
450 case UnselectedState: // FALLTHROUGH
452 case UnselectedSelectedTransition:
453 case SelectedUnselectedTransition:
455 if( backgroundImage && backgroundImage.GetParent() )
457 StopCheckOutAnimation( checkBox );
458 FadeOutImage( checkBox, Background, backgroundImage );
460 backgroundImage = image;
462 FadeInImage( checkBox, backgroundImage );
464 StartCheckOutAnimation( checkBox );
465 StartCheckInAnimation();
469 backgroundImage = image;
470 checkBox.Add( backgroundImage );
474 case DisabledUnselectedTransition: // FALLTHROUGH
475 case DisabledSelectedTransition:
477 StopCheckInAnimation();
478 checkBox.Remove( backgroundImage );
480 backgroundImage = image;
482 FadeInImage( checkBox, backgroundImage );
483 StartCheckInAnimation();
486 case SelectedDisabledTransition: // FALLTHROUGH
487 case UnselectedDisabledTransition:
490 if( fadeOutBackgroundImage )
492 opacity = fadeOutBackgroundImage.GetCurrentOpacity();
494 StopCheckOutAnimation( checkBox );
496 // Replaces the button image.
497 backgroundImage = image;
499 checkBox.Add( backgroundImage );
500 FadeOutImage( checkBox, Background, backgroundImage, opacity );
502 StartCheckOutAnimation( checkBox );
507 backgroundImage = image;
512 backgroundImage.SetAnchorPoint( AnchorPoint::TOP_LEFT );
513 backgroundImage.SetParentOrigin( ParentOrigin::TOP_LEFT );
514 ApplyConstraint( backgroundImage, BACKGROUND_DEPTH );
517 void CheckBoxButtonDefaultPainter::SetDisabledSelectedImage( Toolkit::Button& button, Actor image )
519 Toolkit::Internal::CheckBoxButton& checkBoxImpl = GetCheckBoxButtonImpl( button );
520 Actor& disabledSelectedImage = checkBoxImpl.GetDisabledSelectedImage();
521 Actor& fadeOutSelectedImage = checkBoxImpl.GetFadeOutSelectedImage();
523 Toolkit::CheckBoxButton& checkBox = static_cast<Toolkit::CheckBoxButton&>( button );
525 switch( mPaintState )
527 case DisabledSelectedState:
529 if( disabledSelectedImage && disabledSelectedImage.GetParent() )
531 StopCheckOutAnimation( checkBox );
532 FadeOutImage( checkBox, Foreground, disabledSelectedImage );
534 disabledSelectedImage = image;
536 FadeInImage( checkBox, disabledSelectedImage );
538 StartCheckOutAnimation( checkBox );
539 StartCheckInAnimation();
543 disabledSelectedImage = image;
544 checkBox.Add( disabledSelectedImage );
548 case SelectedDisabledTransition:
550 StopCheckInAnimation();
551 checkBox.Remove( disabledSelectedImage );
553 disabledSelectedImage = image;
555 FadeInImage( checkBox, disabledSelectedImage );
556 StartCheckInAnimation();
559 case DisabledSelectedTransition:
562 if( fadeOutSelectedImage )
564 opacity = fadeOutSelectedImage.GetCurrentOpacity();
566 StopCheckOutAnimation( checkBox );
568 // Replaces the button image.
569 disabledSelectedImage = image;
571 checkBox.Add( disabledSelectedImage );
572 FadeOutImage( checkBox, Foreground, disabledSelectedImage, opacity );
574 StartCheckOutAnimation( checkBox );
579 disabledSelectedImage = image;
584 disabledSelectedImage.SetAnchorPoint( AnchorPoint::TOP_LEFT );
585 disabledSelectedImage.SetParentOrigin( ParentOrigin::TOP_LEFT );
586 ApplyConstraint( disabledSelectedImage, FOREGROUND_DEPTH );
589 void CheckBoxButtonDefaultPainter::SetDisabledBackgroundImage( Toolkit::Button& button, Actor image )
591 Toolkit::Internal::CheckBoxButton& checkBoxImpl = GetCheckBoxButtonImpl( button );
592 Actor& disabledBackgroundImage = checkBoxImpl.GetDisabledBackgroundImage();
593 Actor& fadeOutBackgroundImage = checkBoxImpl.GetFadeOutBackgroundImage();
595 Toolkit::CheckBoxButton& checkBox = static_cast<Toolkit::CheckBoxButton&>( button );
597 switch( mPaintState )
599 case DisabledSelectedState: // FALLTHROUGH
600 case DisabledUnselectedState:
602 if( disabledBackgroundImage && disabledBackgroundImage.GetParent() )
604 StopCheckOutAnimation( checkBox );
605 FadeOutImage( checkBox, Background, disabledBackgroundImage );
607 disabledBackgroundImage = image;
609 FadeInImage( checkBox, disabledBackgroundImage );
611 StartCheckOutAnimation( checkBox );
612 StartCheckInAnimation();
616 disabledBackgroundImage = image;
617 checkBox.Add( disabledBackgroundImage );
621 case UnselectedDisabledTransition: // FALLTHROUGH
622 case SelectedDisabledTransition:
624 StopCheckInAnimation();
625 checkBox.Remove( disabledBackgroundImage );
627 disabledBackgroundImage = image;
629 FadeInImage( checkBox, disabledBackgroundImage );
630 StartCheckInAnimation();
633 case DisabledUnselectedTransition: // FALLTHROUGH
634 case DisabledSelectedTransition:
637 if( fadeOutBackgroundImage )
639 opacity = fadeOutBackgroundImage.GetCurrentOpacity();
641 StopCheckOutAnimation( checkBox );
643 // Replaces the button image.
644 disabledBackgroundImage = image;
646 checkBox.Add( disabledBackgroundImage );
647 FadeOutImage( checkBox, Background, disabledBackgroundImage, opacity );
649 StartCheckOutAnimation( checkBox );
654 disabledBackgroundImage = image;
659 disabledBackgroundImage.SetAnchorPoint( AnchorPoint::TOP_LEFT );
660 disabledBackgroundImage.SetParentOrigin( ParentOrigin::TOP_LEFT );
661 ApplyConstraint( disabledBackgroundImage, BACKGROUND_DEPTH );
664 void CheckBoxButtonDefaultPainter::Selected( Toolkit::Button& button )
666 Toolkit::Internal::CheckBoxButton& checkBoxImpl = GetCheckBoxButtonImpl( button );
667 Actor& selectedImage = checkBoxImpl.GetSelectedImage();
668 Actor& fadeOutSelectedImage = checkBoxImpl.GetFadeOutSelectedImage();
670 Toolkit::CheckBoxButton& checkBoxButton = static_cast<Toolkit::CheckBoxButton&>( button );
672 switch( mPaintState )
674 case UnselectedState:
676 // Fade in the 'check' actor.
677 FadeInImage( checkBoxButton, selectedImage );
678 SetupSelectedAnimation( checkBoxButton, selectedImage ); // Animate in the check actor
679 StartCheckInAnimation();
681 mPaintState = UnselectedSelectedTransition;
686 // Fade out the 'check' actor.
687 StopCheckOutAnimation( checkBoxButton );
688 FadeOutImage( checkBoxButton, Foreground, selectedImage );
689 StartCheckOutAnimation( checkBoxButton );
691 mPaintState = UnselectedState;
694 case UnselectedSelectedTransition:
696 // Stop fade in and start fade out.
697 StopCheckOutAnimation( checkBoxButton );
698 StopCheckInAnimation();
703 opacity = selectedImage.GetCurrentOpacity();
705 FadeOutImage( checkBoxButton, Foreground, selectedImage, opacity );
706 StartCheckOutAnimation( checkBoxButton );
708 mPaintState = UnselectedState;
711 case SelectedUnselectedTransition:
713 // Stop fade out and start fade in.
715 if( fadeOutSelectedImage )
717 opacity = fadeOutSelectedImage.GetCurrentOpacity();
719 StopCheckOutAnimation( checkBoxButton );
721 FadeInImage( checkBoxButton, selectedImage, opacity );
722 StartCheckInAnimation();
724 mPaintState = UnselectedSelectedTransition;
732 void CheckBoxButtonDefaultPainter::ApplyConstraint( Actor& actor, float depth )
736 actor.RemoveConstraints();
737 actor.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
742 void CheckBoxButtonDefaultPainter::ApplySelectedConstraint( Actor& actor, float depth )
746 actor.RemoveConstraints();
747 actor.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
752 void CheckBoxButtonDefaultPainter::AddToFadeInAnimation( const Actor& actor )
754 if( !mCheckInAnimation )
756 mCheckInAnimation = Dali::Animation::New( mAnimationTime );
759 mCheckInAnimation.OpacityTo( actor, 1.f );
763 void CheckBoxButtonDefaultPainter::StartCheckInAnimation()
765 if( mCheckInAnimation )
767 mCheckInAnimation.FinishedSignal().Connect( this, &CheckBoxButtonDefaultPainter::CheckInAnimationFinished );
768 mCheckInAnimation.Play();
772 void CheckBoxButtonDefaultPainter::StopCheckInAnimation()
774 if( mCheckInAnimation )
776 mCheckInAnimation.Clear();
777 mCheckInAnimation.Reset();
781 void CheckBoxButtonDefaultPainter::AddToFadeOutAnimation( const Actor& actor )
783 if( !mCheckOutAnimation )
785 mCheckOutAnimation = Dali::Animation::New( mAnimationTime );
788 mCheckOutAnimation.OpacityTo( actor, 0.f );
791 void CheckBoxButtonDefaultPainter::StartCheckOutAnimation( Toolkit::CheckBoxButton& checkBox )
793 if( mCheckOutAnimation )
795 Toolkit::Internal::CheckBoxButton& checkBoxImpl = GetCheckBoxButtonImpl( checkBox );
796 mButton = &checkBoxImpl;
798 mCheckOutAnimation.FinishedSignal().Connect( this, &CheckBoxButtonDefaultPainter::CheckOutAnimationFinished );
799 mCheckOutAnimation.Play();
803 void CheckBoxButtonDefaultPainter::StopCheckOutAnimation( Toolkit::CheckBoxButton& checkBox, bool remove )
805 if( mCheckOutAnimation )
807 mCheckOutAnimation.Clear();
808 mCheckOutAnimation.Reset();
811 Toolkit::Internal::CheckBoxButton& checkBoxImpl = GetCheckBoxButtonImpl( checkBox );
812 Actor& fadeOutSelectedImage = checkBoxImpl.GetFadeOutSelectedImage();
813 Actor& fadeOutBackgroundImage = checkBoxImpl.GetFadeOutBackgroundImage();
817 if( fadeOutSelectedImage && fadeOutSelectedImage.GetParent() )
819 fadeOutSelectedImage.GetParent().Remove( fadeOutSelectedImage );
822 if( fadeOutBackgroundImage && fadeOutBackgroundImage.GetParent() )
824 fadeOutBackgroundImage.GetParent().Remove( fadeOutBackgroundImage );
827 fadeOutSelectedImage.Reset();
828 fadeOutBackgroundImage.Reset();
832 void CheckBoxButtonDefaultPainter::FadeInImage( Toolkit::CheckBoxButton& checkBox, Actor& image, float opacity )
836 if( !image.GetParent() )
838 checkBox.Add( image );
841 image.SetOpacity( 1.0f );
845 void CheckBoxButtonDefaultPainter::FadeOutImage( Toolkit::CheckBoxButton& checkBox, ImageLayer layer, Actor& image, float opacity )
849 Toolkit::Internal::CheckBoxButton& checkBoxImpl = GetCheckBoxButtonImpl( checkBox );
850 Actor& fadeOutSelectedImage = checkBoxImpl.GetFadeOutSelectedImage();
851 Actor& fadeOutBackgroundImage = checkBoxImpl.GetFadeOutBackgroundImage();
853 Actor& actorLayer = ( ( Background == layer ) ? fadeOutBackgroundImage : fadeOutSelectedImage );
857 actorLayer.SetOpacity( 0.0f );
861 void CheckBoxButtonDefaultPainter::AddToCheckInAnimation( const Actor& actor )
863 if( !mCheckInAnimation )
865 mCheckInAnimation = Dali::Animation::New( mAnimationTime );
869 mCheckInAnimation.AnimateTo( Property( mTickUVEffect, mTickUVEffect.GetBottomRightPropertyName() ), Vector2( 1.0f, 1.0f ) );
872 Handle handle = actor; // Get rid of const
873 mCheckInAnimation.AnimateTo( Property( handle, Actor::SCALE_X ), 1.0f);
876 void CheckBoxButtonDefaultPainter::SetupSelectedAnimation( Toolkit::CheckBoxButton& checkBox, Actor& image )
882 ImageActor imageActor = ImageActor::DownCast( image );
883 mTickUVEffect = ImageRegionEffect::New();
884 imageActor.SetShaderEffect( mTickUVEffect );
887 image.SetScale( Vector3( 0.0f, 1.0f, 1.0f ) );
889 mTickUVEffect.SetBottomRight( Vector2( 0.0f, 1.0f ) );
892 if( !image.GetParent() )
894 checkBox.Add( image );
897 AddToCheckInAnimation( image );
901 void CheckBoxButtonDefaultPainter::EndCheckOutAnimation()
903 switch( mPaintState )
905 case UnselectedSelectedTransition:
907 mPaintState = SelectedState;
910 case SelectedUnselectedTransition:
912 mPaintState = UnselectedState;
915 case UnselectedDisabledTransition:
917 mPaintState = DisabledUnselectedState;
920 case DisabledUnselectedTransition:
922 mPaintState = UnselectedState;
925 case SelectedDisabledTransition:
927 mPaintState = DisabledSelectedState;
930 case DisabledSelectedTransition:
932 mPaintState = SelectedState;
942 void CheckBoxButtonDefaultPainter::CheckOutAnimationFinished( Dali::Animation& source )
944 EndCheckOutAnimation();
946 Toolkit::CheckBoxButton handle( mButton->GetOwner() );
947 StopCheckOutAnimation( handle );
951 void CheckBoxButtonDefaultPainter::CheckInAnimationFinished( Dali::Animation& source )
953 switch( mPaintState )
955 case UnselectedSelectedTransition:
957 mPaintState = SelectedState;
960 case SelectedUnselectedTransition:
962 mPaintState = UnselectedState;
965 case UnselectedDisabledTransition:
967 mPaintState = DisabledUnselectedState;
970 case DisabledUnselectedTransition:
972 mPaintState = UnselectedState;
975 case SelectedDisabledTransition:
977 mPaintState = DisabledSelectedState;
980 case DisabledSelectedTransition:
982 mPaintState = SelectedState;
991 StopCheckInAnimation();
994 } // namespace Internal
996 } // namespace Toolkit