-
- StopTransitionAnimation();
- FadeOutImage( selectedBackgroundImage, opacity );
- FadeOutImage( selectedImage, opacity );
- FadeInImage( buttonImage );
- StartTransitionAnimation();
- break;
- }
- default:
- {
- break;
- }
- }
-
- if( mTransitionAnimation )
- {
- return true;
- }
-
- return false;
-}
-
-void PushButton::StopAllAnimations()
-{
- StopTransitionAnimation();
-}
-
-void PushButton::OnControlSizeSet( const Vector3& targetSize )
-{
- if( targetSize != mSize )
- {
- mSize = targetSize;
-
- Actor& label = GetLabel();
-
- if( label )
- {
- label.SetSize( mSize );
- }
- }
-}
-
-void PushButton::StartTransitionAnimation()
-{
- if( mTransitionAnimation )
- {
- mTransitionAnimation.FinishedSignal().Connect( this, &PushButton::TransitionAnimationFinished );
- mTransitionAnimation.Play();
- }
-}
-
-void PushButton::StopTransitionAnimation( bool remove )
-{
- if( mTransitionAnimation )
- {
- mTransitionAnimation.Clear();
- mTransitionAnimation.Reset();
- }
-
- if( remove )
- {
- UpdatePaintTransitionState();
- }
-}
-
-void PushButton::FadeInImage( Actor& image, float opacity, Vector3 scale )
-{
- if( image )
- {
- image.SetOpacity( opacity );
- image.SetScale( scale );
-
- if( !mTransitionAnimation )
- {
- mTransitionAnimation = Dali::Animation::New( GetAnimationTime() );
- }
-
- mTransitionAnimation.AnimateTo( Property( image, Actor::Property::COLOR_ALPHA ), 1.f );
- }
-}
-
-void PushButton::FadeOutImage( Actor& image, float opacity, Vector3 scale )
-{
- if( image )
- {
- image.SetOpacity( opacity );
- image.SetScale( scale );
-
- if( !mTransitionAnimation )
- {
- mTransitionAnimation = Dali::Animation::New( GetAnimationTime() );
- }
-
- mTransitionAnimation.AnimateTo( Property( image, Actor::Property::COLOR_ALPHA ), 0.f );
- }
-}
-
-void PushButton::TransitionAnimationFinished( Dali::Animation& source )
-{
- StopTransitionAnimation();
-}
-
-Vector3 PushButton::GetNaturalSize()
-{
- Vector3 size;
-
- // If label, test against it's size
- Toolkit::TextLabel label = Toolkit::TextLabel::DownCast( GetLabel() );
- if( label )
- {
- size.width = std::max( size.width, label.GetRelayoutSize( Dimension::WIDTH ) );
- size.height = std::max( size.height, label.GetRelayoutSize( Dimension::HEIGHT ) );
- }
- else
- {
- // Check Image and Background image and use the largest size as the control's Natural size.
- SizeOfActorIfLarger( GetButtonImage(), size );
- SizeOfActorIfLarger( GetBackgroundImage(), size );
- }
-
- return size;
-}
-
-void PushButton::OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension )
-{
- ConfigureSizeNegotiation();
-}
-
-void PushButton::ConfigureSizeNegotiation()
-{
- std::vector< Actor > images;
- images.reserve( 7 );
-
- images.push_back( GetButtonImage() );
- images.push_back( GetSelectedImage() );
- images.push_back( GetSelectedBackgroundImage() );
- images.push_back( GetBackgroundImage() );
- images.push_back( GetDisabledImage() );
- images.push_back( GetDisabledSelectedImage() );
- images.push_back( GetDisabledBackgroundImage() );
-
- Actor label = GetLabel();
-
- for( unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i )
- {
- ConfigureSizeNegotiationDimension( static_cast< Dimension::Type >( 1 << i ), images, label );
- }
-
- if( label )
- {
- Padding padding;
-
- if( label.GetResizePolicy( Dimension::WIDTH ) == ResizePolicy::USE_NATURAL_SIZE )
- {
- padding.left = TEXT_PADDING;
- padding.right = TEXT_PADDING;
- }
-
- if( label.GetResizePolicy( Dimension::HEIGHT ) == ResizePolicy::USE_NATURAL_SIZE )
- {
- padding.top = TEXT_PADDING;
- padding.bottom = TEXT_PADDING;
- }
-
- label.SetPadding( padding );
- }
-}
-
-void PushButton::ConfigureSizeNegotiationDimension( Dimension::Type dimension, const std::vector< Actor >& images, Actor& label )
-{
- ResizePolicy::Type imageResizePolicy = ResizePolicy::FILL_TO_PARENT;
- ResizePolicy::Type labelResizePolicy = ResizePolicy::FILL_TO_PARENT;
-
- switch( Self().GetResizePolicy( dimension ) )
- {
- case ResizePolicy::FIT_TO_CHILDREN:
- {
- imageResizePolicy = labelResizePolicy = ResizePolicy::USE_NATURAL_SIZE;
- break;
- }
- case ResizePolicy::USE_NATURAL_SIZE:
- {
- if( label )