+void Button::TransitionOut( Actor actor )
+{
+ OnTransitionOut( actor );
+}
+
+void Button::ResetImageLayers()
+{
+ // Ensure that all layers are in the correct order and state according to the paint state
+
+ switch( mPaintState )
+ {
+ case UnselectedState:
+ {
+ //Layer Order
+ //(2) mUnselectedContent
+ //(1) mBackgroundContent
+
+ RemoveButtonImage( mDecoration[ SELECTED_DECORATION ] );
+ RemoveButtonImage( mSelectedContent );
+ RemoveButtonImage( mSelectedBackgroundContent );
+ RemoveButtonImage( mDisabledContent );
+ RemoveButtonImage( mDisabledSelectedContent );
+ RemoveButtonImage( mDisabledBackgroundContent );
+
+ PrepareAddButtonImage( mBackgroundContent );
+ PrepareAddButtonImage( mUnselectedContent );
+
+ PrepareAddButtonImage( mDecoration[ UNSELECTED_DECORATION ] );
+ ReAddLabel();
+ break;
+ }
+ case SelectedState:
+ {
+ //Layer Order
+ //(3) mSelectedContent
+ //(2) mSelectedBackgroundContent
+ //(1) mBackgroundContent
+
+ RemoveButtonImage( mDecoration[ UNSELECTED_DECORATION ] );
+ RemoveButtonImage( mUnselectedContent );
+ RemoveButtonImage( mDisabledContent );
+ RemoveButtonImage( mDisabledSelectedContent );
+ RemoveButtonImage( mDisabledBackgroundContent );
+
+ PrepareAddButtonImage( mBackgroundContent );
+ PrepareAddButtonImage( mSelectedBackgroundContent );
+ PrepareAddButtonImage( mSelectedContent );
+
+ PrepareAddButtonImage( mDecoration[ SELECTED_DECORATION ] );
+ ReAddLabel();
+ break;
+ }
+ case DisabledUnselectedState:
+ {
+ //Layer Order
+ //(2) mDisabledContent
+ //(1) mDisabledBackgroundContent
+
+ RemoveButtonImage( mDecoration[ UNSELECTED_DECORATION ] );
+ RemoveButtonImage( mUnselectedContent );
+ RemoveButtonImage( mBackgroundContent );
+ RemoveButtonImage( mDecoration[ SELECTED_DECORATION ] );
+ RemoveButtonImage( mSelectedContent );
+ RemoveButtonImage( mDisabledSelectedContent );
+ RemoveButtonImage( mSelectedBackgroundContent );
+
+ PrepareAddButtonImage( mDisabledBackgroundContent ? mDisabledBackgroundContent : mBackgroundContent );
+ PrepareAddButtonImage( mDisabledContent ? mDisabledContent : mUnselectedContent );
+
+ PrepareAddButtonImage( mDecoration[ UNSELECTED_DECORATION ] );
+ ReAddLabel();
+ break;
+ }
+ case DisabledSelectedState:
+ {
+ //Layer Order
+ // (2) mDisabledSelectedContent
+ // (1) mDisabledBackgroundContent
+
+ RemoveButtonImage( mDecoration[ UNSELECTED_DECORATION ] );
+ RemoveButtonImage( mUnselectedContent );
+ RemoveButtonImage( mDecoration[ SELECTED_DECORATION ] );
+ RemoveButtonImage( mSelectedContent );
+ RemoveButtonImage( mBackgroundContent );
+ RemoveButtonImage( mSelectedBackgroundContent );
+ RemoveButtonImage( mDisabledContent );
+
+ if( mDisabledBackgroundContent )
+ {
+ PrepareAddButtonImage( mDisabledBackgroundContent );
+ }
+ else
+ {
+ PrepareAddButtonImage( mBackgroundContent );
+ PrepareAddButtonImage( mSelectedBackgroundContent );
+ }
+
+ PrepareAddButtonImage( mDisabledSelectedContent ? mDisabledSelectedContent : mSelectedContent );
+
+ PrepareAddButtonImage( mDecoration[ SELECTED_DECORATION ] );
+ ReAddLabel();
+ break;
+ }
+ }
+}
+
+void Button::StartTransitionAnimation()
+{
+ if( mTransitionAnimation )
+ {
+ mTransitionAnimation.Play();
+ }
+ else
+ {
+ ResetImageLayers();
+ }
+}
+
+void Button::StopTransitionAnimation()
+{
+ if( mTransitionAnimation )
+ {
+ mTransitionAnimation.Clear();
+ mTransitionAnimation.Reset();
+ }
+}
+
+Dali::Animation Button::GetTransitionAnimation()
+{
+ if( !mTransitionAnimation )
+ {
+ mTransitionAnimation = Dali::Animation::New( GetAnimationTime() );
+ mTransitionAnimation.FinishedSignal().Connect( this, &Button::TransitionAnimationFinished );
+ }
+
+ return mTransitionAnimation;
+}
+
+void Button::TransitionAnimationFinished( Dali::Animation& source )
+{
+ StopTransitionAnimation();
+ ResetImageLayers();
+}
+