-void CheckBoxButton::OnLabelSet()
-{
- Actor& label = GetLabelActor();
-
- 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 if( IsSelected() && GetSelectedImage())
- {
- label.SetX( GetSelectedImage().GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
- }
- else if( GetUnselectedImage() )
- {
- label.SetX( GetUnselectedImage().GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
- }
- else
- {
- label.SetX( DISTANCE_BETWEEN_IMAGE_AND_LABEL );
- }
- }
-}
-
-void CheckBoxButton::OnDisabled()
-{
- Actor& backgroundImage = GetBackgroundImage();
- Actor& disabledBackgroundImage = GetDisabledBackgroundImage();
-
- Actor& label = GetLabelActor();
- 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 if( IsSelected() && GetSelectedImage())
- {
- label.SetX( GetSelectedImage().GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
- }
- else if( GetUnselectedImage() )
- {
- label.SetX( GetUnselectedImage().GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
- }
- else
- {
- label.SetX( DISTANCE_BETWEEN_IMAGE_AND_LABEL );
- }
- }
-}
-
-void CheckBoxButton::PrepareForTranstionIn( Actor actor )
-{
- Actor& selectedImage = GetSelectedImage();
- if( actor == selectedImage )
- {
- actor.SetScale( Vector3( 0.0f, 1.0f, 1.0f ) );
-
- if( !mTickUVEffect )
- {
- mTickUVEffect = CreateImageRegionEffect();
- }
- mTickUVEffect.SetUniform("uBottomRight", Vector2( 0.0f, 1.0f ) );
-
- ImageActor imageActor = ImageActor::DownCast( actor );
- if( imageActor )
- {
- imageActor.SetShaderEffect( mTickUVEffect );
- }
- }
-}
-
-void CheckBoxButton::PrepareForTranstionOut( Actor actor )
-{
- Actor& selectedImage = GetSelectedImage();
- if( actor == selectedImage )
- {
- actor.SetScale( Vector3::ONE );
-
- if( !mTickUVEffect )
- {
- mTickUVEffect = CreateImageRegionEffect();
- }
- mTickUVEffect.SetUniform("uBottomRight", Vector2::ONE );
-
- ImageActor imageActor = ImageActor::DownCast( actor );
- if( imageActor )
- {
- imageActor.SetShaderEffect( mTickUVEffect );
- }
- }
-}
-
-void CheckBoxButton::OnTransitionIn( Actor actor )
-{
- Actor& selectedImage = GetSelectedImage();
- if( actor && actor == selectedImage )
- {
- if( GetPaintState() == UnselectedState )
- {
- Dali::Animation transitionAnimation = GetTransitionAnimation();
- if( transitionAnimation )
- {
- DALI_ASSERT_DEBUG( mTickUVEffect );
- if( mTickUVEffect )
- {
- // UV anim
- transitionAnimation.AnimateTo( Property( mTickUVEffect, "uBottomRight" ), Vector2::ONE );
- }
- // Actor size anim
- transitionAnimation.AnimateTo( Property( actor, Actor::Property::SCALE_X ), 1.0f );
- }
- }
- else
- {
- //explicitly end the swipe animation
- actor.SetScale( Vector3::ONE );
- if( mTickUVEffect )
- {
- mTickUVEffect.SetUniform("uBottomRight", Vector2::ONE );
- }
- }
- }
-}