[AT-SPI] Squashed implementation
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / buttons / button-impl.h
index f0884e1..881b0a1 100644 (file)
@@ -1,8 +1,8 @@
-#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.
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 
 // EXTERNAL INCLUDES
 #include <dali/public-api/adaptor-framework/timer.h>
+#include <dali/public-api/animation/animation.h>
 
 // INTERNAL INCLUDES
-#include <dali-toolkit/public-api/controls/buttons/button.h>
+#include <dali-toolkit/devel-api/visual-factory/visual-base.h>
+#include <dali-toolkit/devel-api/controls/buttons/button-devel.h>
 #include <dali-toolkit/public-api/controls/control-impl.h>
-#include "button-painter-impl.h"
+#include <dali-toolkit/internal/controls/control/control-data-impl.h>
 
 namespace Dali
 {
@@ -38,456 +40,467 @@ 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
 {
-public:
 
-  // Properties
-  enum
-  {
-    BUTTON_PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1,
-    BUTTON_PROPERTY_END_INDEX = BUTTON_PROPERTY_START_INDEX + 1000 ///< Reserving 1000 property indices
-  };
-
-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 )
+   * @brief Sets the button as \e disabled.
+   * @param[in] disabled Disabled property
    */
   void SetDisabled( bool disabled );
 
   /**
-   * @copydoc Dali::Toolkit::Button::IsDisabled() const
+   * @brief Returns if the button is disabled.
+   * @return \e true if the button is \e disabled
    */
   bool IsDisabled() const;
 
   /**
-   * @copydoc Dali::Toolkit::Button::SetAutoRepeating( bool autoRepeating )
+   * @brief Sets the \e autorepeating property.
+   * @param[in] autoRepeating \e autorepeating property
    */
   void SetAutoRepeating( bool autoRepeating );
 
   /**
-   * @copydoc Dali::Toolkit::Button::IsAutoRepeating() const
-   */
-  bool IsAutoRepeating() const;
-
-  /**
-   * @copydoc Dali::Toolkit::Button::SetInitialAutoRepeatingDelay( float initialAutoRepeatingDelay )
+   * @brief Sets the initial autorepeating delay.
+   * @param[in] initialAutoRepeatingDelay in seconds
    */
   void SetInitialAutoRepeatingDelay( float initialAutoRepeatingDelay );
 
   /**
-   * @copydoc Dali::Toolkit::Button::GetInitialAutoRepeatingDelay() const
+   * @brief Sets the next autorepeating delay.
+   * @param[in] nextAutoRepeatingDelay in seconds
    */
-  float GetInitialAutoRepeatingDelay() const;
+  void SetNextAutoRepeatingDelay( float nextAutoRepeatingDelay );
 
   /**
-   * @copydoc Dali::Toolkit::Button::SetNextAutoRepeatingDelay( float nextAutoRepeatingDelay )
+   * @brief Sets the \e togglable property.
+   * @param[in] togglable Togglable property
    */
-  void SetNextAutoRepeatingDelay( float nextAutoRepeatingDelay );
+  void SetTogglableButton( bool togglable );
 
   /**
-   * @copydoc Dali::Toolkit::Button::GetNextAutoRepeatingDelay() const
+   * @brief Sets the button as selected or unselected.
+   * @param[in] selected Selected property
    */
-  float GetNextAutoRepeatingDelay() const;
+  void SetSelected( bool selected );
 
   /**
-   * @copydoc Dali::Toolkit::Button::SetTogglableButton( bool togglable )
+   * @brief Returns if the selected property is set and the button is togglable.
+   * @return \e true if the button is \e selected
    */
-  void SetTogglableButton( bool togglable );
+  bool IsSelected() const;
 
   /**
-   * @copydoc Dali::Toolkit::Button::IsTogglableButton() const
+   * @brief Produces a Property::Map of Text properties to create a Text Visual, merging existing properties with supplied map
+   * 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.
+   * @param[out] properties A Property::Map of text visual properties to set after merging inMap with existing maps
    */
-  bool IsTogglableButton() const;
+  void MergeWithExistingLabelProperties( const Property::Map& inMap, Property::Map& outMap );
 
   /**
-   * @copydoc Dali::Toolkit::Button::SetSelected( bool selected )
+   * 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
    */
-  virtual void SetSelected( bool selected );
+  static bool DoAction( BaseObject* object, const std::string& actionName, const Property::Map& attributes );
+
+public:
 
   /**
-   * @copydoc Dali::Toolkit::Button::IsSelected() const
+   * Button's state
    */
-  bool IsSelected() const;
+  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
+  };
 
   /**
-   * @copydoc Dali::Toolkit::Button::SetAnimationTime()
+   * Enum to distinguish the different style-able components of the button
    */
-  void SetAnimationTime( float animationTime );
+  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
+  };
 
   /**
-   * @copydoc Dali::Toolkit::Button::GetAnimationTime()
+   * Enum to list types of visual a state can have.
    */
-  float GetAnimationTime() const;
+  enum VisualState
+  {
+    BACKGROUND = 0,
+    FOREGROUND,
+    VISUAL_STATE_COUNT
+  };
+
+protected:
 
   /**
-   * @copydoc Dali::Toolkit::Button::SetLabel( const std::string& label )
+   * 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
    */
-  void SetLabel( const std::string& label );
+  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.
+  };
 
   /**
-   * @copydoc Dali::Toolkit::Button::SetLabel( Actor label )
+   * Construct a new Button.
    */
-  virtual void SetLabel( Actor label );   // TODO: After refactoring painter, virtual will be removed
+  Button();
 
   /**
-   * @copydoc Dali::Toolkit::Button::GetLabel()
+   * A reference counted object may only be deleted by calling Unreference()
    */
-  Actor GetLabel() const;
-
+  virtual ~Button();
   /**
-   * Used by the painter only.
    * @return A reference to the label actor.
    */
-  Actor& GetLabel();
+  Actor& GetLabelActor();
 
   /**
-   * @copydoc Dali::Toolkit::PushButton::SetButtonImage( const Image image )
+   * @return A reference to the unselected button image.
    */
-  void SetButtonImage( Image image );
+  Actor GetUnselectedImage();
 
   /**
-   * @copydoc Dali::Toolkit::PushButton::SetButtonImage( Actor image )
+   * @return A reference to the selected image.
    */
-  void SetButtonImage( Actor image );
+  Actor GetSelectedImage();
 
-  /**
-   * @copydoc Dali::Toolkit::PushButton::GetButtonImage()
-   */
-  Actor GetButtonImage() const;
+private:
 
   /**
-   * Used by the painter only.
-   * @return A reference to the button image.
+   * 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.
    */
-  Actor& GetButtonImage();
+  bool DoClickAction( const Property::Map& attributes );
 
   /**
-   * @copydoc Dali::Toolkit::PushButton::SetSelectedImage( const Image image )
+   * 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.
    */
-  void SetSelectedImage( Image image );
+  virtual bool OnToggleReleased();
 
   /**
-   * @copydoc Dali::Toolkit::PushButton::SetSelectedImage( Actor image )
+   * 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.
    */
-  void SetSelectedImage( Actor image );
+  virtual void OnTouchPointLeave();
 
   /**
-   * @copydoc Dali::Toolkit::PushButton::GetSelectedImage()
+   * This method is called when the touch is interrupted.
+   * Could be reimplemented in subclasses to provide specific behaviour.
    */
-  Actor GetSelectedImage() const;
+  virtual void OnTouchPointInterrupted();
 
   /**
-   * Used by the painter only.
-   * @return A reference to the selected image.
+   * This method is called when the \e selected property is changed.
    */
-  Actor& GetSelectedImage();
+  virtual void OnStateChange( State newState ){}
 
   /**
-   * @copydoc Dali::Toolkit::PushButton::SetBackgroundImage( const Image image )
+   * This method is called when the \e disabled property is changed.
    */
-  void SetBackgroundImage( Image image );
+  virtual void OnDisabled() {}
 
   /**
-   * @copydoc Dali::Toolkit::PushButton::SetBackgroundImage( Actor image )
+   * This method is called when the button is pressed.
    */
-  void SetBackgroundImage( Actor image );
+  virtual void OnPressed() {}
 
   /**
-   * @copydoc Dali::Toolkit::PushButton::GetBackgroundImage()
+   * This method is called when the button is released.
    */
-  Actor GetBackgroundImage() const;
+  virtual void OnReleased() {}
 
-  /**
-   * Used by the painter only.
-   * @return A reference to the background image.
-   */
-  Actor& GetBackgroundImage();
+public:
 
   /**
-   * @copydoc Dali::Toolkit::PushButton::SetDisabledImage( Image image )
+   * @copydoc Dali::Toolkit::PushButton::PressedSignal()
    */
-  void SetDisabledImage( Image image );
+  Toolkit::Button::ButtonSignalType& PressedSignal();
 
   /**
-   * @copydoc Dali::Toolkit::PushButton::SetDisabledImage( Actor image )
+   * @copydoc Dali::Toolkit::PushButton::ReleasedSignal()
    */
-  void SetDisabledImage( Actor image );
+  Toolkit::Button::ButtonSignalType& ReleasedSignal();
 
   /**
-   * @copydoc Dali::Toolkit::PushButton::GetDisabledImage()
+   * @copydoc Dali::Toolkit::Button::ClickedSignal()
    */
-  Actor GetDisabledImage() const;
+  Toolkit::Button::ButtonSignalType& ClickedSignal();
 
   /**
-   * Used by the painter only.
-   * @return A reference to the disabled button image.
+   * @copydoc Dali::Toolkit::Button::StateChangedSignal()
    */
-  Actor& GetDisabledImage();
+  Toolkit::Button::ButtonSignalType& StateChangedSignal();
 
   /**
-   * @copydoc Dali::Toolkit::CheckBoxButton::SetDisabledSelectedImage( Image image )
+   * Connects a callback function with the object's signals.
+   * @param[in] object The object providing the signal.
+   * @param[in] tracker Used to disconnect the signal.
+   * @param[in] signalName The signal to connect to.
+   * @param[in] functor A newly allocated FunctorDelegate.
+   * @return True if the signal was connected.
+   * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
    */
-  void SetDisabledSelectedImage( Image image );
+  static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
 
-  /**
-   * @copydoc Dali::Toolkit::CheckBoxButton::SetDisabledSelectedImage( Actor image )
-   */
-  void SetDisabledSelectedImage( Actor image );
+  // Properties
 
   /**
-   * @copydoc Dali::Toolkit::CheckBoxButton::GetDisabledSelectedImage()
+   * Called when a property of an object of this type is set.
+   * @param[in] object The object whose property is set.
+   * @param[in] index The property index.
+   * @param[in] value The new property value.
    */
-  Actor GetDisabledSelectedImage() const;
+  static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
 
   /**
-   * Used by the painter only.
-   * @return A reference to the disabled selected image.
+   * Called to retrieve a property of an object of this type.
+   * @param[in] object The object whose property is to be retrieved.
+   * @param[in] index The property index.
+   * @return The current value of the property.
    */
-  Actor& GetDisabledSelectedImage();
+  static Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex );
+
+protected: // From Control
 
   /**
-   * @copydoc Dali::Toolkit::PushButton::SetDisabledBackgroundImage( Image image )
+   * @copydoc Toolkit::Control::OnInitialize()
+   * @note If overridden by deriving button classes, then an up-call to Button::OnInitialize MUST be made at the start.
    */
-  void SetDisabledBackgroundImage( Image image );
+  void OnInitialize() override;
 
   /**
-   * @copydoc Dali::Toolkit::PushButton::SetDisabledBackgroundImage( Actor image )
+   * @copydoc Toolkit::Control::OnAccessibilityActivated()
    */
-  void SetDisabledBackgroundImage( Actor image );
+  bool OnAccessibilityActivated() override;
 
   /**
-   * @copydoc Dali::Toolkit::PushButton::GetDisabledBackgroundImage()
+   * @copydoc Toolkit::Control::OnKeyboardEnter()
    */
-  Actor GetDisabledBackgroundImage() const;
+  bool OnKeyboardEnter() override;
 
   /**
-   * Used by the painter only.
-   * @return A reference to the disabled background image.
+   * @copydoc Toolkit::Control::OnSceneDisconnection()
+   * @note If overridden by deriving button classes, then an up-call to Button::OnSceneDisconnection MUST be made at the end.
    */
-  Actor& GetDisabledBackgroundImage();
+  void OnSceneDisconnection() override;
 
   /**
-   * Used by the painter only.
-   * @return A reference to the button image that is fading out.
+   * @copydoc Toolkit::Control::OnSceneConnection()
    */
-  Actor& GetFadeOutButtonImage();
+  void OnSceneConnection( int depth ) override;
 
   /**
-   * Used by the painter only.
-   * @return A reference to the selected image that is fading out.
+   * @copydoc Toolkit::Control::GetNaturalSize
    */
-  Actor& GetFadeOutSelectedImage();
+  Vector3 GetNaturalSize() override;
 
   /**
-   * Used by the painter only.
-   * @return A reference to the background image that is fading out.
+   * @copydoc Toolkit::Control::OnSetResizePolicy
    */
-  Actor& GetFadeOutBackgroundImage();
+  void OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension ) override;
 
   /**
-   * 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 Toolkit::Control::OnRelayout
    */
-  static bool DoAction( BaseObject* object, const std::string& actionName, const PropertyValueContainer& attributes );
+  void OnRelayout( const Vector2& size, RelayoutContainer& container ) override;
 
 private:
-  /**
-   * Perform the click action to click the button.
-   * @param[in] attributes The attributes to perfrom this action.
-   */
-  void DoClickAction( const PropertyValueContainer& attributes );
 
   /**
-   * This method is called after the button initialization.
-   * Could be reimplemented in subclasses to provide specific behaviour.
+   * @brief Handler for touch data
+   * @param[in]  actor  The touched actor.
+   * @param[in]  touch  The touch info.
+   * @return true, if consumed, false otherwise.
    */
-  virtual void OnButtonInitialize() { }
+  bool OnTouch( Actor actor, const TouchEvent& touch );
 
   /**
-   * This method is called from the OnTouchEvent method when the button is down.
-   * Could be reimplemented in subclasses to provide specific behaviour.
+   * 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).
+   * This stops any of our parents receiving a tap gesture when it occurs within our area.
+   * @param[in]  actor  The tapped actor.
+   * @param[in]  tap    The tap gesture.
    */
-  virtual void OnButtonDown();
+  void OnTap(Actor actor, const TapGesture& tap);
 
   /**
-   * This method is called from the OnTouchEvent method when the button is up.
-   * Could be reimplemented in subclasses to provide specific behaviour.
+   * Sets up the autorepeating timer.
+   * @param[in] delay The delay time in seconds.
    */
-  virtual void OnButtonUp();
+  void SetUpTimer( float delay );
 
   /**
-   * 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.
-   * Could be reimplemented in subclasses to provide specific behaviour.
+   * Button has been pressed
    */
-  virtual void OnTouchPointLeave();
+  void Pressed();
 
   /**
-   * This method is called from the OnTouchEvent method when the touch point is interrupted.
-   * Could be reimplemented in subclasses to provide specific behaviour.
+   * This method is called the button is down.
    */
-  virtual void OnTouchPointInterrupted();
+  void ButtonDown();
 
   /**
-   * This method is called when the animation time is set.
-   * Needs to be reimplemented in subclasses to set the animation time in different buttons.
-   * @param animationTime The animation time in seconds.
+   * This method is called when the button is up.
    */
-  virtual void OnAnimationTimeSet( float animationTime );
+  void ButtonUp();
 
   /**
-   * This method is called when the animation time is requested.
-   * Needs to be reimplemented in subclases to return the animation time.
-   * @return The animation time in seconds.
+   * Slot called when Dali::Timer::SignalTick signal. Resets the autorepeating timer.
    */
-  virtual float OnAnimationTimeRequested() const;
+  bool AutoRepeatingSlot();
 
   /**
-   * This method is called when the button is removed from the stage.
-   * Could be reimplemented in subclasses to provide specific behaviour.
+   *  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
    */
-  virtual void OnButtonStageDisconnection();
-
-public:
+  bool ValidateState( State requestedState );
 
   /**
-   * @copydoc Dali::Toolkit::PushButton::PressedSignal()
+   * Changes the button state when an action occurs on it
+   * @param[in] requestedState the state to change to
    */
-  Toolkit::Button::ButtonSignalType& PressedSignal();
+  void ChangeState( State requestedState );
 
   /**
-   * @copydoc Dali::Toolkit::PushButton::ReleasedSignal()
+   * This method is called when the button is released.
    */
-  Toolkit::Button::ButtonSignalType& ReleasedSignal();
+  void Released();
+
+protected:
 
   /**
-   * @copydoc Dali::Toolkit::Button::ClickedSignal()
+   * Set Text Label Padding
+   * @param[in] padding BEGIN END BOTTOM TOP
    */
-  Toolkit::Button::ButtonSignalType& ClickedSignal();
+  void SetLabelPadding( const Padding& padding );
 
   /**
-   * @copydoc Dali::Toolkit::Button::StateChangedSignal()
+   * Get Text Label padding
+   * @return Padding
    */
-  Toolkit::Button::ButtonSignalType& StateChangedSignal();
+  Padding GetLabelPadding();
 
   /**
-   * Connects a callback function with the object's signals.
-   * @param[in] object The object providing the signal.
-   * @param[in] tracker Used to disconnect the signal.
-   * @param[in] signalName The signal to connect to.
-   * @param[in] functor A newly allocated FunctorDelegate.
-   * @return True if the signal was connected.
-   * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
+   * Set Foreground/icon Padding
+   * @param[in] padding BEGIN END BOTTOM TOP
    */
-  static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
-
-  // Properties
+  void SetForegroundPadding( const Padding& padding);
 
   /**
-   * Called when a property of an object of this type is set.
-   * @param[in] object The object whose property is set.
-   * @param[in] index The property index.
-   * @param[in] value The new property value.
+   * Get Foreground padding
+   * @ return Padding
    */
-  static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
+  Padding GetForegroundPadding();
 
   /**
-   * Called to retrieve a property of an object of this type.
-   * @param[in] object The object whose property is to be retrieved.
-   * @param[in] index The property index.
-   * @return The current value of the property.
+   * @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
    */
-  static Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex );
-
-protected: // From CustomActorImpl
+  void CreateVisualsForComponent( Property::Index index, const Property::Value& value, const int visualDepth );
 
   /**
-   * @copydoc Dali::CustomActorImpl::OnTouchEvent( const TouchEvent& event )
+   * @brief Get the Property map for the given Visual
+   * @param[in] visualIndex visual index of the required visual
+   * @param[out] retreivedMap the property map used to construct the required visual
+   * @return bool success flag, true if visual found
    */
-  virtual bool OnTouchEvent( const TouchEvent& event );
-
-private: // From Control
-
+  bool GetPropertyMapForVisual( Property::Index visualIndex, Property::Map& retreivedMap ) const;
   /**
-   * @copydoc Toolkit::Control::OnInitialize()
+   * Returns the animation to be used for transition, creating the animation if needed.
+   * @return The initialised transition animation.
    */
-  virtual void OnInitialize();
+  Dali::Animation GetTransitionAnimation();
 
   /**
-   * @copydoc Toolkit::Control::OnActivated()
+   * @brief Set the position of the label relative to foreground/icon, if both present
+   * @param[in] labelAlignment given alignment setting
    */
-  virtual void OnActivated();
+  void SetLabelAlignment( Align labelAlignment);
 
   /**
-   * @copydoc Toolkit::Control::OnControlSizeSet( const Vector3& targetSize )
+   * @brief Get set alignment of label in relation to foreground/icon
+   * @return Set alignment value
    */
-  virtual void OnControlSizeSet( const Vector3& targetSize );
+  Align GetLabelAlignment();
 
   /**
-   * Callback received when the button is disconnected from the stage.
-   * It resets the button status.
+   * 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 OnControlStageDisconnection();
+  virtual void OnButtonVisualRemoval( Property::Index visualIndex );
+
 
 private:
 
   /**
-   * 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).
-   * This stops any of our parents receiving a tap gesture when it occurs within our area.
-   * @param[in]  actor  The tapped actor.
-   * @param[in]  tap    The tap gesture.
+   * Removes the visual from the button and prepares it to be transitioned out
+   * @param[in] visualIndex the visual to remove
    */
-  void OnTap(Actor actor, const TapGesture& tap);
+  void RemoveVisual( Property::Index visualIndex );
 
   /**
-   * Sets up the autorepeating timer.
-   * @param[in] delay The delay time in seconds.
+   * Adds the required visual to the button.
+   * @param[in] visualIndex The Property index of the visual required
    */
-  void SetUpTimer( float delay );
-
-  /**
-   * Slot called when Dali::Timer::SignalTick signal. Resets the autorepeating timer.
-   */
-  bool AutoRepeatingSlot();
-
-protected:
-
-  enum ButtonState
-  {
-    ButtonUp,                                  ///< The button is up.
-    ButtonDown,                                ///< The button is down.
-  };
-
-  void SetPainter(ButtonPainterPtr painter);
-
-  ButtonState GetState();
-
-  Actor mLabel;                                //TODO: After refactoring painter, this will be private
-  bool  mTogglableButton;                      //TODO: After refactoring painter, this will be private
-  bool  mSelected;                             //TODO: After refactoring painter, this will be private
-
-private:
+  void SelectRequiredVisual( Property::Index visualIndex );
 
   // Undefined
   Button( const Button& );
@@ -497,47 +510,50 @@ private:
 
 private:
 
-  ButtonPainterPtr mPainter;                   ///< Pointer to a ButtonPainter base class.
-
   // Signals
   Toolkit::Button::ButtonSignalType mPressedSignal;           ///< Signal emitted when the button is pressed.
-  Toolkit::Button::ButtonSignalType mReleasedSignal;         ///< Signal emitted when the button is released.
+  Toolkit::Button::ButtonSignalType mReleasedSignal;          ///< Signal emitted when the button is released.
   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.
+  Toolkit::Button::ButtonSignalType mStateChangedSignal;      ///< Signal emitted when the button's state is changed.
 
-//  Actor mLabel;                                ///< Stores the button label.
+  Timer            mAutoRepeatingTimer;
 
-  Actor mButtonImage;                          ///< Stores the unselected image.
-  Actor mSelectedImage;                        ///< Stores the selected image.
-  Actor mBackgroundImage;                      ///< Stores the background image.
-  Actor mDisabledImage;                        ///< Stores the disabled image.
-  Actor mDisabledSelectedImage;                ///< Stores the disabled selected image.
-  Actor mDisabledBackgroundImage;              ///< Stores the disabled background image.
+  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 mFadeOutButtonImage;                   ///< Stores a foreground image, which is in a fade out animation, to be removed when the animation finishes.
-  Actor mFadeOutSelectedImage;                 ///< Stores a foreground image, which is in a fade out animation, to be removed when the animation finishes.
-  Actor mFadeOutBackgroundImage;               ///< Stores a background image, which is in a fade out animation, to be removed when the animation finishes.
+  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.
+  bool             mAutoRepeating;              ///< Stores the autorepeating property.
+  bool             mTogglableButton;            ///< Stores the togglable property as a flag.
+  bool             mTextStringSetFlag;          ///< Stores if text has been set. Required in relayout but don't want to calculate there.
+
+  float            mInitialAutoRepeatingDelay;  ///< Stores the initial autorepeating delay in seconds.
+  float            mNextAutoRepeatingDelay;     ///< Stores the next autorepeating delay in seconds.
+
+  float            mAnimationTime;
+
+  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;
+  bool             mClickActionPerforming;      ///< Used to manage signal emissions during action
 
-  ButtonState      mState;                     ///< Stores the button state.
+protected:
+  struct AccessibleImpl : public Control::Impl::AccessibleImpl
+  {
+    using Control::Impl::AccessibleImpl::AccessibleImpl;
+
+    Dali::Accessibility::States CalculateStates() override;
+    std::string GetNameRaw() override;
+  };
 };
 
 } // namespace Internal
 
-
 // Helpers for public-api forwarding methods
 
 inline Toolkit::Internal::Button& GetImplementation( Toolkit::Button& button )
@@ -562,5 +578,4 @@ inline const Toolkit::Internal::Button& GetImplementation( const Toolkit::Button
 
 } // namespace Dali
 
-#endif // __DALI_TOOLKIT_INTERNAL_BUTTON_H__
-
+#endif // DALI_TOOLKIT_INTERNAL_BUTTON_H