+Actor& Button::GetDisabledSelectedImage()
+{
+ return mDisabledSelectedContent;
+}
+
+void Button::SetDisabledBackgroundImage( const std::string& filename )
+{
+ SetupContent( mDisabledBackgroundContent, Toolkit::ImageView::New( filename ) );
+
+ OnDisabledBackgroundImageSet();
+ RelayoutRequest();
+}
+
+Actor& Button::GetDisabledBackgroundImage()
+{
+ return mDisabledBackgroundContent;
+}
+
+std::string Button::GetUnselectedImageFilename() const
+{
+ if( mUnselectedContent )
+ {
+ ResourceImage image = ResourceImage::DownCast( mUnselectedContent );
+ if( image )
+ {
+ return image.GetUrl();
+ }
+ }
+ return std::string();
+}
+
+std::string Button::GetSelectedImageFilename() const
+{
+ if( mSelectedContent )
+ {
+ ResourceImage image = ResourceImage::DownCast( mSelectedContent );
+ if( image )
+ {
+ return image.GetUrl();
+ }
+ }
+ return std::string();
+}
+
+std::string Button::GetBackgroundImageFilename() const
+{
+ if( mBackgroundContent )
+ {
+ ResourceImage image = ResourceImage::DownCast( mBackgroundContent );
+ if( image )
+ {
+ return image.GetUrl();
+ }
+ }
+ return std::string();
+}
+
+std::string Button::GetSelectedBackgroundImageFilename() const
+{
+ if( mSelectedBackgroundContent )
+ {
+ ResourceImage image = ResourceImage::DownCast( mSelectedBackgroundContent );
+ if( image )
+ {
+ return image.GetUrl();
+ }
+ }
+ return std::string();
+}
+
+std::string Button::GetDisabledImageFilename() const
+{
+ if( mDisabledContent )
+ {
+ ResourceImage image = ResourceImage::DownCast( mDisabledContent );
+ if( image )
+ {
+ return image.GetUrl();
+ }
+ }
+ return std::string();
+}
+
+std::string Button::GetDisabledSelectedImageFilename() const
+{
+ if( mDisabledSelectedContent )
+ {
+ ResourceImage image = ResourceImage::DownCast( mDisabledSelectedContent );
+ if( image )
+ {
+ return image.GetUrl();
+ }
+ }
+ return std::string();
+}
+
+std::string Button::GetDisabledBackgroundImageFilename() const
+{
+ if( mDisabledBackgroundContent )
+ {
+ ResourceImage image = ResourceImage::DownCast( mDisabledBackgroundContent );
+ if( image )
+ {
+ return image.GetUrl();
+ }
+ }
+ return std::string();
+}
+
+bool Button::DoAction( BaseObject* object, const std::string& actionName, const Property::Map& attributes )
+{
+ bool ret = false;
+
+ Dali::BaseHandle handle( object );
+
+ Toolkit::Button button = Toolkit::Button::DownCast( handle );
+
+ DALI_ASSERT_ALWAYS( button );
+
+ if( 0 == strcmp( actionName.c_str(), ACTION_BUTTON_CLICK ) )
+ {
+ ret = GetImplementation( button ).DoClickAction( attributes );
+ }
+
+ return ret;
+}
+
+bool Button::DoClickAction( const Property::Map& attributes )
+{
+ // Prevents the button signals from doing a recursive loop by sending an action
+ // and re-emitting the signals.
+ if( !mClickActionPerforming )
+ {
+ mClickActionPerforming = true;
+ OnButtonDown();
+ mState = ButtonDown;
+ OnButtonUp();
+ mClickActionPerforming = false;
+
+ return true;
+ }
+
+ return false;
+}
+
+void Button::OnButtonStageDisconnection()
+{
+ if( ButtonDown == mState )
+ {
+ if( !mTogglableButton )
+ {
+ Released();
+
+ if( mAutoRepeating )
+ {
+ mAutoRepeatingTimer.Reset();
+ }
+ }
+ }
+}
+
+void Button::OnButtonDown()
+{
+ if( !mTogglableButton )
+ {
+ Pressed();
+
+ if( mAutoRepeating )
+ {
+ SetUpTimer( mInitialAutoRepeatingDelay );
+ }
+ }
+
+ // The pressed signal should be emitted regardless of toggle mode.
+ Toolkit::Button handle( GetOwner() );
+ mPressedSignal.Emit( handle );
+}
+
+void Button::OnButtonUp()
+{
+ if( ButtonDown == mState )
+ {
+ if( mTogglableButton )
+ {
+ SetSelected( !mSelected );
+ }
+ else
+ {
+ Released();
+
+ if( mAutoRepeating )
+ {
+ mAutoRepeatingTimer.Reset();
+ }
+ }
+
+ // The clicked and released signals should be emitted regardless of toggle mode.
+ Toolkit::Button handle( GetOwner() );
+ mReleasedSignal.Emit( handle );
+ mClickedSignal.Emit( handle );
+ }
+}
+
+void Button::OnTouchPointLeave()
+{
+ if( ButtonDown == mState )
+ {
+ if( !mTogglableButton )
+ {
+ Released();
+
+ if( mAutoRepeating )
+ {
+ mAutoRepeatingTimer.Reset();
+ }
+ }
+
+ // The released signal should be emitted regardless of toggle mode.
+ Toolkit::Button handle( GetOwner() );
+ mReleasedSignal.Emit( handle );
+ }
+}
+
+void Button::OnTouchPointInterrupted()
+{
+ OnTouchPointLeave();
+}
+
+Toolkit::Button::ButtonSignalType& Button::PressedSignal()
+{
+ return mPressedSignal;
+}
+
+Toolkit::Button::ButtonSignalType& Button::ReleasedSignal()
+{
+ return mReleasedSignal;
+}
+
+Toolkit::Button::ButtonSignalType& Button::ClickedSignal()
+{
+ return mClickedSignal;
+}
+
+Toolkit::Button::ButtonSignalType& Button::StateChangedSignal()
+{
+ return mStateChangedSignal;
+}
+
+bool Button::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
+{
+ Dali::BaseHandle handle( object );
+
+ bool connected( true );
+ Toolkit::Button button = Toolkit::Button::DownCast( handle );
+
+ if( 0 == strcmp( signalName.c_str(), SIGNAL_PRESSED ) )
+ {
+ button.PressedSignal().Connect( tracker, functor );
+ }
+ else if( 0 == strcmp( signalName.c_str(), SIGNAL_RELEASED ) )
+ {
+ button.ReleasedSignal().Connect( tracker, functor );
+ }
+ else if( 0 == strcmp( signalName.c_str(), SIGNAL_CLICKED ) )
+ {
+ button.ClickedSignal().Connect( tracker, functor );
+ }
+ else if( 0 == strcmp( signalName.c_str(), SIGNAL_STATE_CHANGED ) )
+ {
+ button.StateChangedSignal().Connect( tracker, functor );
+ }
+ else
+ {
+ // signalName does not match any signal
+ connected = false;
+ }
+
+ return connected;
+}
+
+bool Button::OnTouchEvent(const TouchEvent& event)
+{
+ // Only events are processed when the button is not disabled and the touch event has only
+ // one touch point.
+ if( ( !mDisabled ) && ( 1 == event.GetPointCount() ) )
+ {
+ switch( event.GetPoint(0).state )
+ {
+ case TouchPoint::Down:
+ {
+ OnButtonDown(); // Notification for derived classes.
+
+ // Sets the button state to ButtonDown.
+ mState = ButtonDown;
+ break;
+ }
+ case TouchPoint::Up:
+ {
+ OnButtonUp(); // Notification for derived classes.
+
+ // Sets the button state to ButtonUp.
+ mState = ButtonUp;
+ break;
+ }
+ case TouchPoint::Interrupted:
+ {
+ OnTouchPointInterrupted(); // Notification for derived classes.
+
+ // Sets the button state to the default (ButtonUp).
+ mState = ButtonUp;
+ break;
+ }
+ case TouchPoint::Leave:
+ {
+ OnTouchPointLeave(); // Notification for derived classes.
+
+ // Sets the button state to the default (ButtonUp).
+ mState = ButtonUp;
+ break;
+ }
+ case TouchPoint::Motion:
+ case TouchPoint::Stationary: // FALLTHROUGH
+ {
+ // Nothing to do
+ break;
+ }
+ default:
+ {
+ DALI_ASSERT_ALWAYS( !"Point status unhandled." );
+ break;
+ }
+ }
+ }
+ else if( 1 < event.GetPointCount() )
+ {
+ OnTouchPointLeave(); // Notification for derived classes.
+
+ // Sets the button state to the default (ButtonUp).
+ mState = ButtonUp;
+ }
+
+ return false;
+}
+
+void Button::OnInitialize()
+{
+ Actor self = Self();
+
+ mTapDetector = TapGestureDetector::New();
+ mTapDetector.Attach( self );
+ mTapDetector.DetectedSignal().Connect(this, &Button::OnTap);
+
+ OnButtonInitialize();
+
+ self.SetKeyboardFocusable( true );
+}
+
+bool Button::OnAccessibilityActivated()
+{
+ return OnKeyboardEnter();
+}
+
+bool Button::OnKeyboardEnter()
+{
+ // When the enter key is pressed, or button is activated, the click action is performed.
+ Property::Map attributes;
+ bool ret = DoClickAction( attributes );
+
+ return ret;
+}
+
+void Button::OnStageDisconnection()
+{
+ OnButtonStageDisconnection(); // Notification for derived classes.
+ mState = ButtonUp;
+
+ Control::OnStageDisconnection();
+}
+
+void Button::OnTap(Actor actor, const TapGesture& tap)
+{
+ // Do nothing.
+}
+
+void Button::SetUpTimer( float delay )
+{
+ mAutoRepeatingTimer = Dali::Timer::New( static_cast<unsigned int>( 1000.f * delay ) );
+ mAutoRepeatingTimer.TickSignal().Connect( this, &Button::AutoRepeatingSlot );
+ mAutoRepeatingTimer.Start();
+}
+
+bool Button::AutoRepeatingSlot()
+{
+ bool consumed = false;
+ if( !mDisabled )
+ {
+ // Restart the autorepeat timer.
+ SetUpTimer( mNextAutoRepeatingDelay );
+
+ Pressed();
+
+ Toolkit::Button handle( GetOwner() );
+
+ //Emit signal.
+ consumed = mReleasedSignal.Emit( handle );
+ consumed |= mClickedSignal.Emit( handle );
+ consumed |= mPressedSignal.Emit( handle );
+ }
+
+ return consumed;
+}
+
+void Button::Pressed()
+{
+ if( mPaintState == UnselectedState )
+ {
+ StopTransitionAnimation();
+
+ // Notifies the derived class the button has been pressed.
+ OnPressed();
+
+ //Layer Order
+ //(4) mSelectedContent (Inserted)
+ //(3) mUnselectedContent
+ //(2) mSelectedBackgroundContent (Inserted)
+ //(1) mBackgroundContent
+
+ AddButtonImage( mBackgroundContent );
+ TransitionButtonImage( mSelectedBackgroundContent );
+ AddButtonImage( mUnselectedContent );
+ TransitionButtonImage( mSelectedContent );
+
+ AddButtonImage( mDecoration[ UNSELECTED_DECORATION ] );
+ TransitionButtonImage( mDecoration[ SELECTED_DECORATION ] );
+ ReAddLabel();
+
+ TransitionOut( mDecoration[ UNSELECTED_DECORATION ] );
+ TransitionOut( mUnselectedContent );
+ TransitionOut( mDisabledContent );
+ TransitionOut( mDisabledSelectedContent );
+ TransitionOut( mDisabledBackgroundContent );
+
+ mPaintState = SelectedState;
+
+ StartTransitionAnimation();
+ }
+}
+
+void Button::Released()
+{
+ if( mPaintState == SelectedState )
+ {
+ StopTransitionAnimation();
+
+ // Notifies the derived class the button has been released.
+ OnReleased();
+
+ //Layer Order
+ //(3) mUnselectedContent (Inserted)
+ //(2) mSelectedContent
+ //(1) mBackgroundContent
+
+ AddButtonImage( mBackgroundContent );
+ AddButtonImage( mSelectedContent );
+ TransitionButtonImage( mUnselectedContent );
+
+ AddButtonImage( mDecoration[ SELECTED_DECORATION ] );
+ TransitionButtonImage( mDecoration[ UNSELECTED_DECORATION ] );
+ ReAddLabel();
+
+ TransitionOut( mDecoration[ SELECTED_DECORATION ] );
+ TransitionOut( mSelectedContent );
+ TransitionOut( mSelectedBackgroundContent );
+ TransitionOut( mDisabledContent );
+ TransitionOut( mDisabledSelectedContent );
+ TransitionOut( mDisabledBackgroundContent );
+
+ mPaintState = UnselectedState;
+
+ StartTransitionAnimation();
+ }
+}
+
+Button::ButtonState Button::GetState()
+{
+ return mState;
+}
+
+Button::PaintState Button::GetPaintState()
+{
+ return mPaintState;
+}
+
+void Button::PrepareAddButtonImage( Actor& actor )
+{
+ if( actor )
+ {
+ Self().Add( actor );
+ PrepareForTranstionOut( actor );
+ }
+}
+
+void Button::TransitionButtonImage( Actor& actor )
+{
+ if( actor )
+ {
+ if( !actor.GetParent() )
+ {
+ Self().Add( actor );
+ }
+
+ OnTransitionIn( actor );
+ }
+}
+
+void Button::AddButtonImage( Actor& actor )
+{
+ if( actor )
+ {
+ Self().Add( actor );
+ }
+}
+
+void Button::ReAddLabel()
+{
+ if( mLabel )
+ {
+ mLabel.Unparent();
+ Self().Add( mLabel );
+ }
+}
+
+void Button::RemoveButtonImage( Actor& actor )
+{
+ if( actor )
+ {
+ if( actor.GetParent() )
+ {
+ Self().Remove( actor );
+ }
+ PrepareForTranstionIn( actor );
+ }
+}
+
+unsigned int Button::FindChildIndex( Actor& actor )
+{
+ Actor self = Self();
+ unsigned int childrenNum = self.GetChildCount();
+
+ for( unsigned int i = 0; i < childrenNum; i++ )
+ {
+ Actor child = self.GetChildAt( i );
+ if( child == actor )
+ {
+ return i;
+ }
+ }
+
+ return childrenNum;
+}
+
+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();
+}
+
+void Button::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )
+{
+ Toolkit::Button button = Toolkit::Button::DownCast( Dali::BaseHandle( object ) );
+
+ if ( button )
+ {
+ switch ( index )
+ {
+ case Toolkit::Button::Property::DISABLED:
+ {
+ GetImplementation( button ).SetDisabled( value.Get< bool >() );
+ break;
+ }
+
+ case Toolkit::Button::Property::AUTO_REPEATING:
+ {
+ GetImplementation( button ).SetAutoRepeating( value.Get< bool >() );
+ break;
+ }
+
+ case Toolkit::Button::Property::INITIAL_AUTO_REPEATING_DELAY:
+ {
+ GetImplementation( button ).SetInitialAutoRepeatingDelay( value.Get< float >() );
+ break;
+ }
+
+ case Toolkit::Button::Property::NEXT_AUTO_REPEATING_DELAY:
+ {
+ GetImplementation( button ).SetNextAutoRepeatingDelay( value.Get< float >() );
+ break;
+ }
+
+ case Toolkit::Button::Property::TOGGLABLE:
+ {
+ GetImplementation( button ).SetTogglableButton( value.Get< bool >() );
+ break;
+ }
+
+ case Toolkit::Button::Property::SELECTED:
+ {
+ GetImplementation( button ).SetSelected( value.Get< bool >() );
+ break;
+ }
+
+ case Toolkit::Button::Property::UNSELECTED_STATE_IMAGE:
+ {
+ GetImplementation( button ).SetUnselectedImage( value.Get< std::string >() );
+ break;
+ }
+
+ case Toolkit::Button::Property::SELECTED_STATE_IMAGE:
+ {
+ GetImplementation( button ).SetSelectedImage( value.Get< std::string >() );
+ break;
+ }
+
+ case Toolkit::Button::Property::DISABLED_STATE_IMAGE:
+ {
+ GetImplementation( button ).SetDisabledImage( value.Get< std::string >() );
+ break;
+ }
+
+ case Toolkit::Button::Property::UNSELECTED_COLOR:
+ {
+ GetImplementation( button ).SetUnselectedColor( value.Get< Vector4 >() );
+ break;
+ }
+
+ case Toolkit::Button::Property::SELECTED_COLOR:
+ {
+ GetImplementation( button ).SetSelectedColor( value.Get< Vector4 >() );
+ break;
+ }
+
+ case Toolkit::Button::Property::LABEL_TEXT:
+ {
+ GetImplementation( button ).SetLabelText( value.Get< std::string >() );
+ break;
+ }
+
+ case Toolkit::Button::Property::LABEL:
+ {
+ // Get a Property::Map from the property if possible.
+ Property::Map setPropertyMap;
+ if( value.Get( setPropertyMap ) )
+ {
+ GetImplementation( button ).ModifyLabel( setPropertyMap );
+ }
+ }
+ break;
+ }
+ }
+}
+
+Property::Value Button::GetProperty( BaseObject* object, Property::Index propertyIndex )
+{
+ Property::Value value;
+
+ Toolkit::Button button = Toolkit::Button::DownCast( Dali::BaseHandle( object ) );
+
+ if ( button )
+ {
+ switch ( propertyIndex )
+ {
+ case Toolkit::Button::Property::DISABLED:
+ {
+ value = GetImplementation( button ).mDisabled;
+ break;
+ }
+
+ case Toolkit::Button::Property::AUTO_REPEATING:
+ {
+ value = GetImplementation( button ).mAutoRepeating;
+ break;
+ }
+
+ case Toolkit::Button::Property::INITIAL_AUTO_REPEATING_DELAY:
+ {
+ value = GetImplementation( button ).mInitialAutoRepeatingDelay;
+ break;
+ }
+
+ case Toolkit::Button::Property::NEXT_AUTO_REPEATING_DELAY:
+ {
+ value = GetImplementation( button ).mNextAutoRepeatingDelay;
+ break;
+ }
+
+ case Toolkit::Button::Property::TOGGLABLE:
+ {
+ value = GetImplementation( button ).mTogglableButton;
+ break;
+ }
+
+ case Toolkit::Button::Property::SELECTED:
+ {
+ value = GetImplementation( button ).mSelected;
+ break;
+ }
+
+ case Toolkit::Button::Property::UNSELECTED_STATE_IMAGE:
+ {
+ value = GetImplementation( button ).GetUnselectedImageFilename();
+ break;
+ }
+
+ case Toolkit::Button::Property::SELECTED_STATE_IMAGE:
+ {
+ value = GetImplementation( button ).GetSelectedImageFilename();
+ break;
+ }
+
+ case Toolkit::Button::Property::DISABLED_STATE_IMAGE:
+ {
+ value = GetImplementation( button ).GetDisabledImageFilename();
+ break;
+ }
+
+ case Toolkit::Button::Property::UNSELECTED_COLOR:
+ {
+ value = GetImplementation( button ).GetUnselectedColor();
+ break;
+ }
+
+ case Toolkit::Button::Property::SELECTED_COLOR:
+ {
+ value = GetImplementation( button ).GetSelectedColor();
+ break;
+ }
+
+ case Toolkit::Button::Property::LABEL_TEXT:
+ {
+ value = GetImplementation( button ).GetLabelText();
+ break;
+ }
+
+ case Toolkit::Button::Property::LABEL:
+ {
+ Property::Map emptyMap;
+ value = emptyMap;
+ break;
+ }
+ }
+ }
+
+ return value;
+}
+
+// Deprecated API
+
+void Button::SetLabel( Actor label )
+{
+ if( mLabel != label )
+ {
+ if( mLabel && mLabel.GetParent() )
+ {
+ mLabel.GetParent().Remove( mLabel );
+ }
+
+ mLabel = label;
+ mLabel.SetPosition( 0.0f, 0.0f );
+
+ // label should be the top of the button
+ Self().Add( mLabel );
+
+ ResetImageLayers();
+ OnLabelSet( true );
+
+ RelayoutRequest();
+ }
+}
+
+void Button::SetButtonImage( Actor image )
+{
+ if( image )
+ {
+ StopTransitionAnimation();
+
+ SetupContent( mUnselectedContent, image );
+
+ OnUnselectedImageSet();
+ RelayoutRequest();
+ }
+}
+
+void Button::SetSelectedImage( Actor image )
+{
+ if( image )
+ {
+ StopTransitionAnimation();
+
+ SetupContent( mSelectedContent, image );
+
+ OnSelectedImageSet();
+ RelayoutRequest();
+ }
+}
+
+void Button::SetBackgroundImage( Actor image )
+{
+ if( image )
+ {
+ StopTransitionAnimation();
+
+ SetupContent( mBackgroundContent, image );
+
+ OnBackgroundImageSet();
+ RelayoutRequest();
+ }
+}
+
+void Button::SetSelectedBackgroundImage( Actor image )
+{
+ if( image )
+ {
+ StopTransitionAnimation();
+
+ SetupContent( mSelectedBackgroundContent, image );
+
+ OnSelectedBackgroundImageSet();
+ RelayoutRequest();
+ }
+}
+
+void Button::SetDisabledImage( Actor image )
+{
+ if( image )
+ {
+ StopTransitionAnimation();
+
+ SetupContent( mDisabledContent, image );
+
+ OnDisabledImageSet();
+ RelayoutRequest();
+ }
+}
+
+void Button::SetDisabledSelectedImage( Actor image )
+{
+ if( image )
+ {
+ StopTransitionAnimation();
+
+ SetupContent( mDisabledSelectedContent, image );
+
+ OnDisabledSelectedImageSet();
+ RelayoutRequest();
+ }
+}
+
+void Button::SetDisabledBackgroundImage( Actor image )
+{
+ if( image )
+ {
+ StopTransitionAnimation();
+
+ SetupContent( mDisabledBackgroundContent, image );
+
+ OnDisabledBackgroundImageSet();
+ RelayoutRequest();
+ }
+}
+
+Actor Button::GetButtonImage() const
+{
+ return mUnselectedContent;
+}
+
+Actor Button::GetSelectedImage() const
+{
+ return mSelectedContent;
+}
+
+