- if( mTransitionAnimation )
- {
- mTransitionAnimation.Clear();
- }
-}
-
-void CheckBoxButton::OnButtonInitialize()
-{
- // Wrap around all children
- Self().SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS );
-}
-
-void CheckBoxButton::OnLabelSet()
-{
- Actor& label = GetLabel();
-
- if( label )
- {
- label.SetParentOrigin( ParentOrigin::CENTER_LEFT );
- label.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
-
- if( IsDisabled() && GetDisabledBackgroundImage() )
- {
- label.SetX( GetDisabledBackgroundImage().GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
- }
- else if ( GetBackgroundImage() )
- {
- label.SetX( GetBackgroundImage().GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
- }
- else
- {
- label.SetX( DISTANCE_BETWEEN_IMAGE_AND_LABEL );
- }
- }
-}
-
-bool CheckBoxButton::OnSelected()
-{
- Actor& selectedImage = GetSelectedImage();
-
- PaintState paintState = GetPaintState();
-
- switch( paintState )
- {
- case UnselectedState:
- {
- StartTransitionAnimation( selectedImage );
- break;
- }
- case SelectedState:
- {
- RemoveChild( selectedImage );
- break;
- }
- case UnselectedSelectedTransition:
- {
- StopTransitionAnimation( false );
- RemoveChild( selectedImage );
- break;
- }
- default:
- {
- break;
- }
- }
-
- if( mTransitionAnimation )
- {
- return true;
- }
-
- return false;
-}
-
-bool CheckBoxButton::OnDisabled()
-{
- Actor& backgroundImage = GetBackgroundImage();
- Actor& selectedImage = GetSelectedImage();
- Actor& disabledBackgroundImage = GetDisabledBackgroundImage();
- Actor& disabledSelectedImage = GetDisabledSelectedImage();
-
- PaintState paintState = GetPaintState();
-
- switch( paintState )
- {
- case UnselectedState:
- {
- RemoveChild( backgroundImage );
- break;
- }
- case SelectedState:
- {
- RemoveChild( backgroundImage );
- RemoveChild( selectedImage );
- break;
- }
- case DisabledUnselectedState:
- {
- RemoveChild( disabledBackgroundImage );
- break;
- }
- case DisabledSelectedState:
- {
- RemoveChild( disabledBackgroundImage );
- RemoveChild( disabledSelectedImage );
- break;
- }
- case UnselectedSelectedTransition:
- {
- StopTransitionAnimation();
-
- RemoveChild( backgroundImage );
- RemoveChild( selectedImage );
- break;
- }
- default:
- {
- break;
- }
- }
-
- Actor& label = GetLabel();
-
- if( label )
- {
- if( IsDisabled() && disabledBackgroundImage)
- {
- label.SetX( disabledBackgroundImage.GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
- }
- else if( backgroundImage )
- {
- label.SetX( backgroundImage.GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
- }
- else
- {
- label.SetX( DISTANCE_BETWEEN_IMAGE_AND_LABEL );
- }
- }
-
- if( mTransitionAnimation )
- {
- return true;
- }
-
- return false;