+void Button::SetDisabled( bool disabled )
+{
+ if( disabled == mDisabled )
+ {
+ return;
+ }
+
+ StopTransitionAnimation();
+
+ mDisabled = disabled;
+
+ // Notifies the derived class the button has been disabled.
+ OnDisabled();
+
+ switch( mPaintState )
+ {
+ case UnselectedState:
+ {
+ //Layer Order
+ //(3) mDisabledContent (Inserted)
+ //(4) mUnselectedContent
+ //(2) mDisabledBackgroundContent (Inserted)
+ //(1) mBackgroundContent
+
+ TransitionInBetween( mUnselectedContent, mLabel, mDisabledContent );
+ TransitionInAbove( mBackgroundContent, mDisabledBackgroundContent );
+
+ TransitionOut( mUnselectedContent );
+ TransitionOut( mSelectedContent );
+ TransitionOut( mBackgroundContent );
+ TransitionOut( mSelectedBackgroundContent );
+ TransitionOut( mDisabledSelectedContent );
+
+ mPaintState = DisabledUnselectedState;
+ break;
+ }
+ case SelectedState:
+ {
+ //Layer Order
+ //(5) mDisabledSelectedContent (Inserted)
+ //(4) mSelectedContent
+ //(3) mDisabledBackgroundContent (Inserted)
+ //(2) mSelectedBackgroundContent
+ //(1) mBackgroundContent
+
+ TransitionInBetween( mSelectedContent, mLabel, mDisabledSelectedContent );
+ TransitionInAbove( mSelectedBackgroundContent, mDisabledBackgroundContent );
+
+ TransitionOut( mUnselectedContent );
+ TransitionOut( mSelectedContent );
+ TransitionOut( mBackgroundContent );
+ TransitionOut( mSelectedBackgroundContent );
+ TransitionOut( mDisabledContent );
+
+ mPaintState = DisabledSelectedState;
+ break;
+ }
+ case DisabledUnselectedState:
+ {
+ //Layer Order
+ //(3) mUnselectedContent (Inserted)
+ //(4) mDisabledContent
+ //(2) mBackgroundContent (Inserted)
+ //(1) mDisabledBackgroundContent
+
+ TransitionInBetween( mDisabledContent, mLabel, mUnselectedContent );
+ TransitionInAbove( mDisabledBackgroundContent, mBackgroundContent );
+
+ TransitionOut( mSelectedContent );
+ TransitionOut( mSelectedBackgroundContent );
+ TransitionOut( mDisabledContent );
+ TransitionOut( mDisabledSelectedContent );
+ TransitionOut( mDisabledBackgroundContent );
+
+ mPaintState = UnselectedState;
+ break;
+ }
+ case DisabledSelectedState:
+ {
+ //Layer Order
+ //(4) mSelectedContent (Inserted)
+ //(5) mDisabledSelectedContent
+ //(3) mSelectedBackgroundContent (Inserted)
+ //(2) mBackgroundContent (Inserted)
+ //(1) mDisabledBackgroundContent
+
+ TransitionInBetween( mDisabledSelectedContent, mLabel, mSelectedContent );
+ TransitionInAbove( mDisabledBackgroundContent, mSelectedBackgroundContent );
+ TransitionInAbove( mDisabledBackgroundContent, mBackgroundContent );
+
+ TransitionOut( mUnselectedContent );
+ TransitionOut( mDisabledContent );
+ TransitionOut( mDisabledSelectedContent );
+ TransitionOut( mDisabledBackgroundContent );
+
+ mPaintState = SelectedState;
+ break;
+ }
+ }
+
+ StartTransitionAnimation();
+}
+
+bool Button::IsDisabled() const
+{
+ return mDisabled;
+}
+
+void Button::SetAutoRepeating( bool autoRepeating )
+{
+ mAutoRepeating = autoRepeating;
+
+ // An autorepeating button can't be a togglable button.
+ if( autoRepeating )
+ {
+ mTogglableButton = false;
+
+ if( mSelected )
+ {
+ // Emit a signal is not wanted, only change the appearance.
+ SetSelected( false, false );
+ }
+ }
+}
+
+bool Button::IsAutoRepeating() const
+{
+ return mAutoRepeating;
+}
+
+void Button::SetInitialAutoRepeatingDelay( float initialAutoRepeatingDelay )
+{
+ DALI_ASSERT_ALWAYS( initialAutoRepeatingDelay > 0.f );
+ mInitialAutoRepeatingDelay = initialAutoRepeatingDelay;
+}
+
+float Button::GetInitialAutoRepeatingDelay() const
+{
+ return mInitialAutoRepeatingDelay;
+}
+
+void Button::SetNextAutoRepeatingDelay( float nextAutoRepeatingDelay )
+{
+ DALI_ASSERT_ALWAYS( nextAutoRepeatingDelay > 0.f );
+ mNextAutoRepeatingDelay = nextAutoRepeatingDelay;
+}
+
+float Button::GetNextAutoRepeatingDelay() const
+{
+ return mNextAutoRepeatingDelay;
+}
+
+void Button::SetTogglableButton( bool togglable )
+{
+ mTogglableButton = togglable;
+
+ // A togglable button can't be an autorepeating button.
+ if( togglable )
+ {
+ mAutoRepeating = false;
+ }
+}
+
+bool Button::IsTogglableButton() const
+{
+ return mTogglableButton;
+}
+
+void Button::SetSelected( bool selected )
+{
+ if( !mDisabled && mTogglableButton && ( selected != mSelected ) )
+ {
+ SetSelected( selected, true );
+ }
+}
+
+void Button::SetSelected( bool selected, bool emitSignal )
+{
+ StopTransitionAnimation();
+
+ mSelected = selected;
+
+ // Notifies the derived class the button has been selected.
+ OnSelected();
+
+ switch( mPaintState )
+ {
+ case UnselectedState:
+ {
+ //Layer Order
+ //(3) mSelectedContent (Inserted)
+ //(4) mUnselectedContent
+ //(2) mSelectedBackgroundContent (Inserted)
+ //(1) mBackgroundContent
+
+ TransitionInBetween( mUnselectedContent, mLabel, mSelectedContent );
+ TransitionInAbove( mBackgroundContent, mSelectedBackgroundContent );
+ TransitionInAtIndex( 0, mBackgroundContent );
+
+ TransitionOut( mUnselectedContent );
+ TransitionOut( mDisabledContent );
+ TransitionOut( mDisabledSelectedContent );
+ TransitionOut( mDisabledBackgroundContent );
+
+ mPaintState = SelectedState;
+ break;
+ }
+ case SelectedState:
+ {
+ //Layer Order
+ //(3) mUnselectedContent (Inserted)
+ //(2) mSelectedContent
+ //(1) mBackgroundContent
+
+ TransitionInBetween( mSelectedContent, mLabel, mUnselectedContent );
+ TransitionInAtIndex( 0, mBackgroundContent );
+
+ TransitionOut( mSelectedContent );
+ TransitionOut( mSelectedBackgroundContent );
+ TransitionOut( mDisabledContent );
+ TransitionOut( mDisabledSelectedContent );
+ TransitionOut( mDisabledBackgroundContent );
+
+ mPaintState = UnselectedState;
+ break;
+ }
+ case DisabledUnselectedState:
+ case DisabledSelectedState:
+ {
+ DALI_ASSERT_DEBUG( 0 && "Shouldn't be able to change paint state if the button is disabled." );
+ break;
+ }
+ }
+
+ StartTransitionAnimation();
+
+ if( emitSignal )
+ {
+ Toolkit::Button handle( GetOwner() );
+
+ // Emit signal.
+ mStateChangedSignal.Emit( handle );
+ }
+
+ RelayoutRequest();
+}
+
+bool Button::IsSelected() const
+{
+ return mTogglableButton && mSelected;
+}
+
+void Button::SetAnimationTime( float animationTime )
+{
+ mAnimationTime = animationTime;
+}
+
+float Button::GetAnimationTime() const
+{
+ return mAnimationTime;
+}
+
+void Button::SetLabel( const std::string& label )
+{
+ Toolkit::TextLabel textLabel = Toolkit::TextLabel::New( label );
+ SetLabel( textLabel );
+}
+
+void Button::SetLabel( Actor label )
+{
+ if( mLabel != label )
+ {
+ if( mLabel && mLabel.GetParent() )
+ {
+ mLabel.GetParent().Remove( mLabel );
+ }
+
+ mLabel = label;
+ mLabel.SetPosition( 0.f, 0.f );
+
+ // label should be the top of the button
+ Self().Add( mLabel );
+
+ OnLabelSet();
+
+ RelayoutRequest();
+ }
+}
+
+Actor Button::GetLabel() const