Removed OnButton virtual functions and simplified RadioButton logic
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / buttons / button-impl.h
index 89f0591..e5854d7 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef __DALI_TOOLKIT_INTERNAL_BUTTON_H__
-#define __DALI_TOOLKIT_INTERNAL_BUTTON_H__
+#ifndef DALI_TOOLKIT_INTERNAL_BUTTON_H
+#define DALI_TOOLKIT_INTERNAL_BUTTON_H
 
 /*
  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
 #include <dali/public-api/animation/animation.h>
 
 // INTERNAL INCLUDES
+#include <dali-toolkit/devel-api/visual-factory/visual-base.h>
 #include <dali-toolkit/public-api/controls/buttons/button.h>
 #include <dali-toolkit/public-api/controls/control-impl.h>
 
+//#if defined(DEBUG_ENABLED)
+//  Debug::Filter* gLogButtonFilter = Debug::Filter::New(Debug::NoLogging, true, "LOG_BUTTON_CONTROL");
+//#endif
+
 namespace Dali
 {
 
@@ -38,328 +43,344 @@ namespace Internal
 {
 
 /**
+ * @copydoc Toolkit::Button
+ *
  * Button is the base class implementation for all buttons.
+ *
+ * @note
+ *
+ * All Foreground/Icon visuals expected to be the same size.
+ * Background visuals will take the size of the control.
+ * Padding and struts take size precedence over visuals when available space is limited.
+ * Icon/Foreground visuals take size precedence over Labels when available space is limited.
  */
 class Button : public Control
 {
 
-protected:
-
-  /**
-   * Construct a new Button.
-   */
-  Button();
+public:
 
   /**
-   * A reference counted object may only be deleted by calling Unreference()
+   * Enum describing the position the text label can be in relation to the control (and foreground/icon)
    */
-  virtual ~Button();
+  enum Align
+  {
+    BEGIN,  // At the start of the control before the foreground/icon
+    END,    // At the end of the control after the foreground/icon
+    TOP,    // At the top of the control above the foreground/icon
+    BOTTOM  // At the bottom of the control below the foreground/icon
+  };
 
 public:
 
   /**
-   * @copydoc Dali::Toolkit::Button::SetDisabled( bool disabled )
+   * @copydoc Dali::Toolkit::Button::SetDisabled
    */
   void SetDisabled( bool disabled );
 
   /**
-   * @copydoc Dali::Toolkit::Button::IsDisabled() const
+   * @copydoc Dali::Toolkit::Button::IsDisabled
    */
   bool IsDisabled() const;
 
   /**
-   * @copydoc Dali::Toolkit::Button::SetAutoRepeating( bool autoRepeating )
+   * @copydoc Dali::Toolkit::Button::SetAutoRepeating
    */
   void SetAutoRepeating( bool autoRepeating );
 
   /**
-   * @copydoc Dali::Toolkit::Button::IsAutoRepeating() const
+   * @copydoc Dali::Toolkit::Button::IsAutoRepeating
    */
   bool IsAutoRepeating() const;
 
   /**
-   * @copydoc Dali::Toolkit::Button::SetInitialAutoRepeatingDelay( float initialAutoRepeatingDelay )
+   * @copydoc Dali::Toolkit::Button::SetInitialAutoRepeatingDelay
    */
   void SetInitialAutoRepeatingDelay( float initialAutoRepeatingDelay );
 
   /**
-   * @copydoc Dali::Toolkit::Button::GetInitialAutoRepeatingDelay() const
+   * @copydoc Dali::Toolkit::Button::GetInitialAutoRepeatingDelay
    */
   float GetInitialAutoRepeatingDelay() const;
 
   /**
-   * @copydoc Dali::Toolkit::Button::SetNextAutoRepeatingDelay( float nextAutoRepeatingDelay )
+   * @copydoc Dali::Toolkit::Button::SetNextAutoRepeatingDelay
    */
   void SetNextAutoRepeatingDelay( float nextAutoRepeatingDelay );
 
   /**
-   * @copydoc Dali::Toolkit::Button::GetNextAutoRepeatingDelay() const
+   * @copydoc Dali::Toolkit::Button::GetNextAutoRepeatingDelay
    */
   float GetNextAutoRepeatingDelay() const;
 
   /**
-   * @copydoc Dali::Toolkit::Button::SetTogglableButton( bool togglable )
+   * @copydoc Dali::Toolkit::Button::SetTogglableButton
    */
   void SetTogglableButton( bool togglable );
 
   /**
-   * @copydoc Dali::Toolkit::Button::IsTogglableButton() const
+   * @copydoc Dali::Toolkit::Button::IsTogglableButton
    */
   bool IsTogglableButton() const;
 
   /**
-   * @copydoc Dali::Toolkit::Button::SetSelected( bool selected )
+   * @copydoc Dali::Toolkit::Button::SetSelected
    */
   void SetSelected( bool selected );
 
   /**
-   * @copydoc Dali::Toolkit::Button::IsSelected() const
+   * @copydoc Dali::Toolkit::Button::IsSelected
    */
   bool IsSelected() const;
 
   /**
-   * @copydoc Dali::Toolkit::Button::SetAnimationTime()
+   * @copydoc Dali::Toolkit::Button::SetAnimationTime
    */
   void SetAnimationTime( float animationTime );
 
   /**
-   * @copydoc Dali::Toolkit::Button::GetAnimationTime()
+   * @copydoc Dali::Toolkit::Button::GetAnimationTime
    */
   float GetAnimationTime() const;
 
   /**
-   * @copydoc Dali::Toolkit::Button::SetLabel( const std::string& label )
+   * @copydoc Dali::Toolkit::Button::SetLabelText
    */
-  void SetLabel( const std::string& label );
+  void SetLabelText( const std::string& label );
 
   /**
-   * @copydoc Dali::Toolkit::Button::SetLabel( Actor label )
+   * @copydoc Dali::Toolkit::Button::GetLabelText
    */
-  void SetLabel( Actor label );
+  std::string GetLabelText() const;
 
   /**
-   * @copydoc Dali::Toolkit::Button::GetLabel()
+   * @brief Sets the specified properties on the button label.
+   * If the label does not exist yet, it is created.
+   * The derived buttons are notified if any properties are changed.
+   * @param[in] properties A Property::Map of key-value pairs of properties to set.
    */
-  Actor GetLabel() const;
+  void SetupLabel( const Property::Map& properties );
 
   /**
-   * @copydoc Dali::Toolkit::PushButton::SetButtonImage( Actor image )
-   */
-  void SetButtonImage( Actor image );
-
-  /**
-   * @copydoc Dali::Toolkit::PushButton::GetButtonImage()
+   * Performs actions as requested using the action name.
+   * @param[in] object The object on which to perform the action.
+   * @param[in] actionName The action to perform.
+   * @param[in] attributes The attributes with which to perfrom this action.
+   * @return true if action has been accepted by this control
    */
-  Actor GetButtonImage() const;
+  static bool DoAction( BaseObject* object, const std::string& actionName, const Property::Map& attributes );
 
-  /**
-   * Internal use only.
-   * @return A reference to the button image.
-   */
-  Actor& GetButtonImage();
+public: // Deprecated API
 
   /**
-   * @copydoc Dali::Toolkit::PushButton::SetSelectedImage( Actor image )
+   * @copydoc Dali::Toolkit::Button::SetLabel( Actor label )
    */
-  void SetSelectedImage( Actor image );
+  void SetLabel( Actor label );
 
   /**
-   * @copydoc Dali::Toolkit::PushButton::GetSelectedImage()
+   * @deprecated Sets the unselected image with an url.
+   * @param[in] image The Actor to use.
    */
-  Actor GetSelectedImage() const;
+  void SetUnselectedImage( const std::string& filename );
 
   /**
-   * Internal use only.
-   * @return A reference to the selected image.
+   * @deprecated Sets the selected image with an url.
+   * @param[in] filename The url of the image to use to use.
    */
-  Actor& GetSelectedImage();
+  void SetSelectedImage( const std::string& filename );
 
   /**
-   * @copydoc Dali::Toolkit::PushButton::SetBackgroundImage( Actor image )
+   * @deprecated Sets the selected background image with an url.
+   * @param[in] filename The url of the image to use to use.
    */
-  void SetBackgroundImage( Actor image );
+  void SetSelectedBackgroundImage( const std::string& filename );
 
   /**
-   * @copydoc Dali::Toolkit::PushButton::GetBackgroundImage()
+   * @deprecated Sets the background image with an url.
+   * @param[in] filename The url of the image to use to use.
    */
-  Actor GetBackgroundImage() const;
+  void SetBackgroundImage( const std::string& filename );
 
   /**
-   * Internal use only.
-   * @return A reference to the background image.
+   * @deprecated Sets the disabled unselected background image with an url.
+   * @param[in] filename The url of the image to use to use.
    */
-  Actor& GetBackgroundImage();
+  void SetDisabledBackgroundImage( const std::string& filename );
 
   /**
-   * @copydoc Dali::Toolkit::PushButton::SetSelectedBackgroundImage( Actor image )
+   * @deprecated Sets the disabled unselected image with an url.
+   * @param[in] filename The url of the image to use to use.
    */
-  void SetSelectedBackgroundImage( Actor image );
+  void SetDisabledImage( const std::string& filename );
 
   /**
-   * @copydoc Dali::Toolkit::PushButton::GetSelectedBackgroundImage()
+   * @deprecated Sets the disabled selected image with an url.
+   * @param[in] filename The url of the image to use to use.
    */
-  Actor GetSelectedBackgroundImage() const;
+  void SetDisabledSelectedImage( const std::string& filename );
 
   /**
-   * Internal use only.
-   * @return A reference to the selected background image.
+   * @deprecated Sets the unselected image with an Actor.
+   * @param[in] image The Actor to use.
    */
-  Actor& GetSelectedBackgroundImage();
+  void SetUnselectedImage( Actor image );
 
   /**
-   * @copydoc Dali::Toolkit::PushButton::SetDisabledImage( Actor image )
+   * @deprecated Sets the selected image with an Actor.
+   * @param[in] image The Actor to use.
    */
-  void SetDisabledImage( Actor image );
+  void SetSelectedImage( Actor image );
 
   /**
-   * @copydoc Dali::Toolkit::PushButton::GetDisabledImage()
+   * @deprecated Sets the selected background image with an Actor.
+   * @param[in] image The Actor to use.
    */
-  Actor GetDisabledImage() const;
+  void SetSelectedBackgroundImage( Actor image );
 
   /**
-   * Internal use only.
-   * @return A reference to the disabled button image.
+   * @deprecated Sets the disabled image with an Actor.
+   * @param[in] image The Actor to use.
    */
-  Actor& GetDisabledImage();
+  void SetDisabledImage( Actor image );
 
   /**
-   * @copydoc Dali::Toolkit::CheckBoxButton::SetDisabledSelectedImage( Actor image )
+   * @deprecated Sets the disabled selected image with an Actor.
+   * @param[in] image The Actor to use.
    */
   void SetDisabledSelectedImage( Actor image );
 
   /**
-   * @copydoc Dali::Toolkit::CheckBoxButton::GetDisabledSelectedImage()
-   */
-  Actor GetDisabledSelectedImage() const;
-
-  /**
-   * Internal use only.
-   * @return A reference to the disabled selected image.
-   */
-  Actor& GetDisabledSelectedImage();
-
-  /**
-   * @copydoc Dali::Toolkit::PushButton::SetDisabledBackgroundImage( Actor image )
+   * @deprecated Sets the disabled background image with an Actor.
+   * @param[in] image The Actor to use.
    */
   void SetDisabledBackgroundImage( Actor image );
 
   /**
-   * @copydoc Dali::Toolkit::PushButton::GetDisabledBackgroundImage()
+   * @Gets url of a image visual, used by GetProperty but for deprecated Properties
+   * @param[in] index Visual index of url required
+   * @return filename for the corresponding visual
    */
-  Actor GetDisabledBackgroundImage() const;
+  std::string GetUrlForImageVisual( Property::Index index );
 
-  /**
-   * Internal use only.
-   * @return A reference to the disabled background image.
-   */
-  Actor& GetDisabledBackgroundImage();
 
   /**
-   * Performs actions as requested using the action name.
-   * @param[in] object The object on which to perform the action.
-   * @param[in] actionName The action to perform.
-   * @param[in] attributes The attributes with which to perfrom this action.
-   * @return true if action has been accepted by this control
+   * @copydoc Dali::Toolkit::Button::GetButtonImage
    */
-  static bool DoAction( BaseObject* object, const std::string& actionName, const Property::Map& attributes );
-
-protected:
+  Actor GetButtonImage() const;
 
   /**
-   * @return A reference to the label actor.
+   * @copydoc Dali::Toolkit::Button::GetSelectedImage
    */
-  Actor& GetLabel();
+  Actor GetSelectedImage() const;
 
-private:
+public:
 
   /**
-   * Perform the click action to click the button.
-   * @param[in] attributes The attributes to perfrom this action.
-   * @return true if this control can perform action.
+   * Button's state
    */
-  bool DoClickAction( const Property::Map& attributes );
+  enum State
+  {
+    UNSELECTED_STATE,              ///< The button is unselected.
+    SELECTED_STATE,                ///< The button is selected.
+    DISABLED_UNSELECTED_STATE,     ///< The button is disabled and unselected.
+    DISABLED_SELECTED_STATE,       ///< The button is disabled and selected.
+    STATE_COUNT,                   ///< Number of States
+  };
 
   /**
-   * This method is called after the button initialization.
-   * Could be reimplemented in subclasses to provide specific behaviour.
+   * Enum to distinguish the different style-able components of the button
    */
-  virtual void OnButtonInitialize() { }
+  enum Visuals
+  {
+    UNSELECTED_FOREGROUND = 0,
+    SELECTED_FOREGROUND,
+    DISABLED_SELECTED_FOREGROUND,
+    DISABLED_UNSELECTED_FOREGROUND,
+    UNSELECTED_BACKGROUND,
+    SELECTED_BACKGROUND,
+    DISABLED_UNSELECTED_BACKGROUND,
+    DISABLED_SELECTED_BACKGROUND,
+    VISUALS_COUNT
+  };
 
   /**
-   * This method is called when the label is set.
+   * Enum to list types of visual a state can have.
    */
-  virtual void OnLabelSet() {}
+  enum VisualState
+  {
+    BACKGROUND = 0,
+    FOREGROUND,
+    VISUAL_STATE_COUNT
+  };
 
-  /**
-   * This method is called when the button image is set
-   */
-  virtual void OnButtonImageSet() {}
+protected:
 
   /**
-   * This method is called when the selected image is set
+   * Button press state which is not the same as the actual button's state.
+   * For example An UNSELECTED button can be DEPRESSED, but until released, the actual button state doesn't change to SELECTED
    */
-  virtual void OnSelectedImageSet() {}
+  enum PressState
+  {
+    DEPRESSED,                           ///< The button is up.
+    UNPRESSED,                           ///< The button is down.
+    TOGGLE_DEPRESSED,                    ///< The button has been pressed down and will stay depressed when released.
+  };
 
   /**
-   * This method is called when the background image is set
+   * Construct a new Button.
    */
-  virtual void OnBackgroundImageSet() {}
+  Button();
 
   /**
-   * This method is called when the selected background image is set
+   * A reference counted object may only be deleted by calling Unreference()
    */
-  virtual void OnSelectedBackgroundImageSet() {}
-
+  virtual ~Button();
   /**
-   * This method is called when the disabled button image is set
+   * @return A reference to the label actor.
    */
-  virtual void OnDisabledImageSet() {}
+  Actor& GetLabelActor();
 
   /**
-   * This method is called when the disabled selected image is set
+   * @return A reference to the unselected button image.
    */
-  virtual void OnDisabledSelectedImageSet() {}
+  Actor GetUnselectedImage();
 
   /**
-   * This method is called when the disabled background image is set
+   * @return A reference to the selected image.
    */
-  virtual void OnDisabledBackgroundImageSet() {}
+  Actor GetSelectedImage();
+
+private:
 
   /**
-   * This method is called from the OnTouchEvent method when the button is down.
-   * Could be reimplemented in subclasses to provide specific behaviour.
+   * Perform the click action to click the button.
+   * @param[in] attributes The attributes to perfrom this action.
+   * @return true if this control can perform action.
    */
-  virtual void OnButtonDown();
+  bool DoClickAction( const Property::Map& attributes );
 
   /**
-   * This method is called from the OnTouchEvent method when the button is up.
+   * This method is called when the button is a Toggle button and released
    * Could be reimplemented in subclasses to provide specific behaviour.
+   * @return bool returns true if state changed.
    */
-  virtual void OnButtonUp();
+  virtual bool OnToggleReleased();
 
   /**
-   * This method is called from the OnTouchEvent method when the touch point leaves the boundary of the button or
-   * more than one touch points are received.
+   * This method is called when touch leaves the boundary of the button or several touch points are received.
    * Could be reimplemented in subclasses to provide specific behaviour.
    */
   virtual void OnTouchPointLeave();
 
   /**
-   * This method is called from the OnTouchEvent method when the touch point is interrupted.
+   * This method is called when the touch is interrupted.
    * Could be reimplemented in subclasses to provide specific behaviour.
    */
   virtual void OnTouchPointInterrupted();
 
   /**
-   * This method is called when the button is removed from the stage.
-   * Could be reimplemented in subclasses to provide specific behaviour.
-   */
-  virtual void OnButtonStageDisconnection();
-
-  /**
    * This method is called when the \e selected property is changed.
    */
-  virtual void OnSelected() {}
+  virtual void OnStateChange( State newState ){}
 
   /**
    * This method is called when the \e disabled property is changed.
@@ -427,17 +448,11 @@ public:
    */
   static Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex );
 
-protected: // From CustomActorImpl
-
-  /**
-   * @copydoc Dali::CustomActorImpl::OnTouchEvent( const TouchEvent& event )
-   */
-  virtual bool OnTouchEvent( const TouchEvent& event );
-
-private: // From Control
+protected: // From Control
 
   /**
    * @copydoc Toolkit::Control::OnInitialize()
+   * @note If overridden by deriving button classes, then an up-call to Button::OnInitialize MUST be made at the start.
    */
   virtual void OnInitialize();
 
@@ -452,14 +467,42 @@ private: // From Control
   virtual bool OnKeyboardEnter();
 
   /**
-   * Callback received when the button is disconnected from the stage.
-   * It resets the button status.
+   * @copydoc Toolkit::Control::OnStageDisconnection()
+   * @note If overridden by deriving button classes, then an up-call to Button::OnStageDisconnection MUST be made at the end.
+   */
+  virtual void OnStageDisconnection();
+
+  /**
+   * @copydoc Toolkit::Control::OnStageConnnection()
+   */
+  virtual void OnStageConnection( int depth );
+
+  /**
+   * @copydoc Toolkit::Control::GetNaturalSize
+   */
+  virtual Vector3 GetNaturalSize();
+
+  /**
+   * @copydoc Toolkit::Control::OnSetResizePolicy
    */
-  void OnControlStageDisconnection();
+  virtual void OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension );
+
+  /**
+   * @copydoc Toolkit::Control::OnRelayout
+   */
+  virtual void OnRelayout( const Vector2& size, RelayoutContainer& container );
 
 private:
 
   /**
+   * @brief Handler for touch data
+   * @param[in]  actor  The touched actor.
+   * @param[in]  touch  The touch info.
+   * @return true, if consumed, false otherwise.
+   */
+  bool OnTouch( Actor actor, const TouchData& touch );
+
+  /**
    * Handler for tap events.
    * We do not actually do anything when we receive a tap as the button handles tap event through
    * the touch event system itself as it requires more than just tap handling (e.g. leave events).
@@ -476,147 +519,145 @@ private:
   void SetUpTimer( float delay );
 
   /**
-   * Slot called when Dali::Timer::SignalTick signal. Resets the autorepeating timer.
+   * Button has been pressed
    */
-  bool AutoRepeatingSlot();
+  void Pressed();
 
   /**
-   * Sets the button as selected or unselected.
-   * @param[in] selected \e selected property value.
-   * @param[in] emitSignal Emit a signal if this value is \e true.
+   * This method is called the button is down.
    */
-  void SetSelected( bool selected, bool emitSignal );
+  void ButtonDown();
 
   /**
-   * This method is called when the button is pressed.
+   * This method is called when the button is up.
    */
-  void Pressed();
+  void ButtonUp();
 
   /**
-   * This method is called when the button is released.
+   * Slot called when Dali::Timer::SignalTick signal. Resets the autorepeating timer.
    */
-  void Released();
-
-protected:
-
-  enum ButtonState
-  {
-    ButtonUp,                                  ///< The button is up.
-    ButtonDown,                                ///< The button is down.
-  };
+  bool AutoRepeatingSlot();
 
   /**
-   * Button paint states.
+   *  Check the requested state is an allowed transition.
+   *  Some states can not be transitioned to from certain states.
+   *  @param[in] requestedState check if can transition to this state
+   *  @return bool true if state change valid
    */
-  enum PaintState
-  {
-    UnselectedState,              ///< The button is unselected.
-    SelectedState,                ///< The button is selected.
-    DisabledUnselectedState,      ///< The button is disabled and unselected.
-    DisabledSelectedState,        ///< The button is disabled and selected.
-  };
-
-  ButtonState GetState();
-  PaintState GetPaintState();
+  bool ValidateState( State requestedState );
 
   /**
-   * Returns the animation to be used for transitioning creating the animation if needed.
-   * @return The initialised transition animation.
+   * Perform the given function on the visuals in the given state. Can be used to add and remove visuals.
+   * @param[in] functionPtr pointer to the function to perform an action on a visual
+   * @param[in] state Visuals in this state will be the target
    */
-  Dali::Animation GetTransitionAnimation();
+  void PerformFunctionOnVisualsInState( void(Button::*functionPtr)( Property::Index visualIndex), State state  );
 
   /**
-   * Prepares the actor to be transitioned in.
-   * @param[in]  actor  The actor that will be transitioned in.
+   * Changes the button state when an action occurs on it
+   * @param[in] requestedState the state to change to
    */
-  virtual void PrepareForTranstionIn( Actor actor ) {}
+  void ChangeState( State requestedState );
 
   /**
-   * Prepares the actor to be transitioned in.
-   * @param[in]  actor  The actor that will be transitioned out.
+   * @brief Get unselected button color
+   * @return color as vector4
    */
-  virtual void PrepareForTranstionOut( Actor actor ) {}
+  const Vector4 GetUnselectedColor() const;
 
   /**
-   * Transitions the actor in, allowing derived classes to configure
-   * the GetTransitionAnimation() animation ready.
-   * Button is in charge of calling Dali::Animation::Play and so derived classes
-   * only need to add the animation.
+   * @brief Get selected button color
+   * @return color as vector4
    */
-  virtual void OnTransitionIn( Actor actor ) {}
+  const Vector4 GetSelectedColor() const;
 
   /**
-   * Transitions the actor out, allowing derived classes to configure
-   * the GetTransitionAnimation() animation ready.
-   * Button is in charge of calling Dali::Animation::Play and so derived classes
-   * only need to add the animation.
+   * Sets the color of button in selected or unselected state, if image also supplied this color will be appplied to it.
+   * If no visual exists, it is created.
+   * @param[in]  color The color to use.
+   * @param[in]  visualIndex The Visual to apply the color
    */
-  virtual void OnTransitionOut( Actor actor ) {}
+  void SetColor( const Vector4& color, Property::Index visualIndex );
 
-private:
   /**
-   * Starts the transition animation.
-   * Button::TransitionFinished is called when the animation finishes.
+   * This method is called when the button is released.
    */
-  void StartTransitionAnimation();
+  void Released();
+
+protected:
 
   /**
-   * This method stops all transition animations
+   * Set Text Label Padding
+   * @param[in] padding BEGIN END BOTTOM TOP
    */
-  void StopTransitionAnimation();
+  void SetLabelPadding( const Padding& padding );
 
   /**
-   * Called when the transition animation finishes.
+   * Get Text Label padding
+   * @return Padding
    */
-  void TransitionAnimationFinished( Dali::Animation& source );
+  Padding GetLabelPadding();
 
   /**
-   * Resets the Button to the base state for the current paint state.
-   * Any additionally inserted images needed for transitions that are
-   * no longer needed and the removed.
+   * Set Foreground/icon Padding
+   * @param[in] padding BEGIN END BOTTOM TOP
    */
-  void ResetImageLayers();
+  void SetForegroundPadding( const Padding& padding);
 
   /**
-   * Transitions in the actor, inserting the actor above childLower below the childUpper.
-   * Will not insert the actor if it is already attached to a parent (and so will not reorder the actor)
+   * Get Foreground padding
+   * @ return Padding
    */
-  void TransitionInBetween( Actor childLower, Actor childUpper, Actor actor );
+  Padding GetForegroundPadding();
 
   /**
-   * Transitions in the actor, inserting the actor above the child if the child exists or at the bottom otherwise
-   * Will not insert the actor if it is already attached to a parent (and so will not reorder the actor)
+   * @brief Setup the button components for example foregrounds and background
+   * @param[in] index the index of the visual to set
+   * @param[in] value the value to set on the component
+   * @param[in] visualDepth the depth of the visual if overlapping another
    */
-  void TransitionInAbove( Actor child, Actor actor );
+  void CreateVisualsForComponent( Property::Index index ,const Property::Value& value, const float visualDepth );
 
   /**
-   * Transitions in the actor, inserting the actor at the index
-   * Will not insert the actor if it is already attached to a parent (and so will not reorder the actor)
+   * Returns the animation to be used for transition, creating the animation if needed.
+   * @return The initialised transition animation.
    */
-  void TransitionInAtIndex( unsigned int index, Actor actor );
+  Dali::Animation GetTransitionAnimation();
 
   /**
-   * Transitions out the actor
+   * @brief Set the position of the label relative to foreground/icon, if both present
+   * @param[in] labelAlignment given alignment setting
    */
-  void TransitionOut( Actor actor );
+  void SetLabelAlignment( Align labelAlignment);
 
   /**
-   * Inserts the actor to the button and prepares it to be transitioned out
-   * @return true if the child was inserted, false otherwise
+   * @brief Get set alignment of label in relation to foreground/icon
+   * @return Set alignment value
    */
-  bool InsertButtonImage( unsigned int index, Actor& actor );
+  Align GetLabelAlignment();
 
   /**
-   * Removes the actor from the button and prepares it to be transitioned out
+   * Removes the visual from the button (un-staged)
+   * If the derived button does not want the visual removed then use this virtual function to
+   * define the required behaviour.
+   * Can decide to only remove specified visuals via index
    */
-  void RemoveButtonImage( Actor& actor );
+  virtual void OnButtonVisualRemoval( Property::Index visualIndex );
+
+
+private:
 
   /**
-   * Finds the index of the actor.
-   * If the actor doesn't exist, return the last index + 1.
+   * Removes the visual from the button and prepares it to be transitioned out
+   * @param[in] visualIndex the visual to remove
    */
-  unsigned int FindChildIndex( Actor& actor );
+  void RemoveVisual( Property::Index visualIndex );
 
+  /**
+   * Adds the required visual to the button.
+   * @param[in] visualIndex The Property index of the visual required
+   */
+  void SelectRequiredVisual( Property::Index visualIndex );
 
   // Undefined
   Button( const Button& );
@@ -632,36 +673,32 @@ private:
   Toolkit::Button::ButtonSignalType mClickedSignal;           ///< Signal emitted when the button is clicked.
   Toolkit::Button::ButtonSignalType mStateChangedSignal;      ///< Signal emitted when the button's state is changed.
 
-  Timer mAutoRepeatingTimer;                   ///< Timer used to implement the autorepeating property.
+  Timer            mAutoRepeatingTimer;
 
-  Actor mLabel;                                ///< Stores the button label.
+  Actor            mLabel;                      ///< Stores the button text label.
+  Padding          mLabelPadding;               ///< The padding around the label (if present).
+  Padding          mForegroundPadding;          ///< The padding around the foreground/icon visual (if present).
 
-  Actor mUnselectedContent;                    ///< Stores the unselected content.
-  Actor mSelectedContent;                      ///< Stores the selected content.
-  Actor mBackgroundContent;                    ///< Stores the background content.
-  Actor mSelectedBackgroundContent;            ///< Stores the selected background content.
-  Actor mDisabledContent;                      ///< Stores the disabled content.
-  Actor mDisabledSelectedContent;              ///< Stores the disabled selected content.
-  Actor mDisabledBackgroundContent;            ///< Stores the disabled background content.
-
-  Animation        mTransitionAnimation;       ///< Animation used in the state transitions.
+  Align            mTextLabelAlignment;           ///< Position of text label in relation to foreground/icon when both are present.
 
   TapGestureDetector mTapDetector;
 
-  bool             mDisabled;                  ///< Stores the disabled property.
-  bool             mAutoRepeating;             ///< Stores the autorepeating property.
-  bool             mTogglableButton;           ///< Stores the togglable property.
-  bool             mSelected;                  ///< Stores the selected state.
-  float            mInitialAutoRepeatingDelay; ///< Stores the initial autorepeating delay in seconds.
-  float            mNextAutoRepeatingDelay;    ///< Stores the next autorepeating delay in seconds.
+  Vector4          mUnselectedColor;
+  Vector4          mSelectedColor;
 
-  float            mAnimationTime;             ///< The animation time.
+  bool             mAutoRepeating;              ///< Stores the autorepeating property.
+  bool             mTogglableButton;            ///< Stores the togglable property as a flag.
+  float            mInitialAutoRepeatingDelay;  ///< Stores the initial autorepeating delay in seconds.
+  float            mNextAutoRepeatingDelay;     ///< Stores the next autorepeating delay in seconds.
 
-  // Actions
-  bool             mClickActionPerforming;
+  float            mAnimationTime;
 
-  ButtonState      mState;                     ///< Stores the button state.
-  PaintState       mPaintState;                ///< Stores the paint state.
+  PressState       mButtonPressedState;         ///< In relation to the button being pressed/released
+  State            mButtonState;
+  State            mPreviousButtonState;        ///< During a transition between two states, this stores the previous state so Visuals can be removed.
+
+  // Actions
+  bool             mClickActionPerforming;      ///< Used to manage signal emissions during action
 };
 
 } // namespace Internal
@@ -690,4 +727,4 @@ inline const Toolkit::Internal::Button& GetImplementation( const Toolkit::Button
 
 } // namespace Dali
 
-#endif // __DALI_TOOLKIT_INTERNAL_BUTTON_H__
+#endif // DALI_TOOLKIT_INTERNAL_BUTTON_H