- 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()
-{
- ActorContainer 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 )
- {
- label.SetPadding( Padding( TEXT_PADDING, TEXT_PADDING, TEXT_PADDING, TEXT_PADDING) );
- }
-}
-
-void PushButton::ConfigureSizeNegotiationDimension( Dimension::Type dimension, const ActorContainer& 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 )
- {
- labelResizePolicy = ResizePolicy::USE_NATURAL_SIZE;
- }
- else
- {
- imageResizePolicy = ResizePolicy::USE_NATURAL_SIZE;
- }
- break;
- }
- default:
- {
- break;
- }
- }
-
- if( label )
- {
- label.SetResizePolicy( labelResizePolicy, dimension );
- }
-
- for( ActorConstIter it = images.begin(), itEnd = images.end(); it != itEnd; ++it )
- {
- Actor actor = *it;
- if( actor )