[AT-SPI] Synchronize with AT-SPI cleanup in dali-adaptor
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / buttons / button-impl.h
index da2557f..3e36873 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) 2021 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.
 #include <dali/public-api/animation/animation.h>
 
 // INTERNAL INCLUDES
-#include <dali-toolkit/public-api/controls/buttons/button.h>
+#include <dali-toolkit/devel-api/controls/buttons/button-devel.h>
+#include <dali-toolkit/devel-api/controls/control-devel.h>
+#include <dali-toolkit/devel-api/visual-factory/visual-base.h>
 #include <dali-toolkit/public-api/controls/control-impl.h>
 
 namespace Dali
 {
-
 namespace Toolkit
 {
-
 class Button;
 
 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:
-
-  /**
-   * @copydoc Dali::Toolkit::Button::SetDisabled
-   */
-  void SetDisabled( bool disabled );
-
-  /**
-   * @copydoc Dali::Toolkit::Button::IsDisabled
-   */
-  bool IsDisabled() const;
-
-  /**
-   * @copydoc Dali::Toolkit::Button::SetAutoRepeating
-   */
-  void SetAutoRepeating( bool autoRepeating );
-
   /**
-   * @copydoc Dali::Toolkit::Button::IsAutoRepeating
+   * Enum describing the position the text label can be in relation to the control (and foreground/icon)
    */
-  bool IsAutoRepeating() const;
+  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::SetInitialAutoRepeatingDelay
+   * @brief Sets the button as \e disabled.
+   * @param[in] disabled Disabled property
    */
-  void SetInitialAutoRepeatingDelay( float initialAutoRepeatingDelay );
+  void SetDisabled(bool disabled);
 
   /**
-   * @copydoc Dali::Toolkit::Button::GetInitialAutoRepeatingDelay
+   * @brief Returns if the button is disabled.
+   * @return \e true if the button is \e disabled
    */
-  float GetInitialAutoRepeatingDelay() const;
+  bool IsDisabled() const;
 
   /**
-   * @copydoc Dali::Toolkit::Button::SetNextAutoRepeatingDelay
+   * @brief Sets the \e autorepeating property.
+   * @param[in] autoRepeating \e autorepeating property
    */
-  void SetNextAutoRepeatingDelay( float nextAutoRepeatingDelay );
+  void SetAutoRepeating(bool autoRepeating);
 
   /**
-   * @copydoc Dali::Toolkit::Button::GetNextAutoRepeatingDelay
+   * @brief Sets the initial autorepeating delay.
+   * @param[in] initialAutoRepeatingDelay in seconds
    */
-  float GetNextAutoRepeatingDelay() const;
+  void SetInitialAutoRepeatingDelay(float initialAutoRepeatingDelay);
 
   /**
-   * @copydoc Dali::Toolkit::Button::SetTogglableButton
+   * @brief Sets the next autorepeating delay.
+   * @param[in] nextAutoRepeatingDelay in seconds
    */
-  void SetTogglableButton( bool togglable );
+  void SetNextAutoRepeatingDelay(float nextAutoRepeatingDelay);
 
   /**
-   * @copydoc Dali::Toolkit::Button::IsTogglableButton
+   * @brief Sets the \e togglable property.
+   * @param[in] togglable Togglable property
    */
-  bool IsTogglableButton() const;
+  void SetTogglableButton(bool togglable);
 
   /**
-   * @copydoc Dali::Toolkit::Button::SetSelected
+   * @brief Sets the button as selected or unselected.
+   * @param[in] selected Selected property
    */
-  void SetSelected( bool selected );
+  void SetSelected(bool selected);
 
   /**
-   * @copydoc Dali::Toolkit::Button::IsSelected
+   * @brief Returns if the selected property is set and the button is togglable.
+   * @return \e true if the button is \e selected
    */
   bool IsSelected() const;
 
   /**
-   * @copydoc Dali::Toolkit::Button::SetAnimationTime
-   */
-  void SetAnimationTime( float animationTime );
-
-  /**
-   * @copydoc Dali::Toolkit::Button::GetAnimationTime
-   */
-  float GetAnimationTime() const;
-
-  /**
-   * @copydoc Dali::Toolkit::Button::SetLabelText
-   */
-  void SetLabelText( const std::string& label );
-
-  /**
-   * @copydoc Dali::Toolkit::Button::GetLabelText
-   */
-  std::string GetLabelText() const;
-
-  /**
-   * @copydoc Dali::Toolkit::PushButton::SetUnselectedImage
-   */
-  void SetUnselectedImage( const std::string& filename );
-
-  /**
-   * @copydoc Dali::Toolkit::PushButton::SetSelectedImage
-   */
-  void SetSelectedImage( const std::string& filename );
-
-  /**
-   * @copydoc Dali::Toolkit::PushButton::SetBackgroundImage
-   */
-  void SetBackgroundImage( const std::string& filename );
-
-  /**
-   * @copydoc Dali::Toolkit::PushButton::SetSelectedBackgroundImage
-   */
-  void SetSelectedBackgroundImage( const std::string& filename );
-
-  /**
-   * @copydoc Dali::Toolkit::PushButton::SetDisabledImage
-   */
-  void SetDisabledImage( const std::string& filename );
-
-  /**
-   * @copydoc Dali::Toolkit::CheckBoxButton::SetDisabledSelectedImage
-   */
-  void SetDisabledSelectedImage( const std::string& filename );
-
-  /**
-   * @copydoc Dali::Toolkit::PushButton::SetDisabledBackgroundImage
-   */
-  void SetDisabledBackgroundImage( const std::string& filename );
-
-  /**
-   * @return The filename used for the button image.
-   */
-  std::string GetUnselectedImageFilename() const;
-
-  /**
-   * @return The filename used for the selected image.
-   */
-  std::string GetSelectedImageFilename() const;
-
-  /**
-   * @return The filename used for the background image.
-   */
-  std::string GetBackgroundImageFilename() const;
-
-  /**
-   * @return The filename used for the selected background image.
-   */
-  std::string GetSelectedBackgroundImageFilename() const;
-
-  /**
-   * @return The filename used for the disabled button image.
-   */
-  std::string GetDisabledImageFilename() const;
-
-  /**
-   * @return The filename used for the disabled selected image.
-   */
-  std::string GetDisabledSelectedImageFilename() const;
-
-  /**
-   * @return The filename used for the disabled background image.
-   */
-  std::string GetDisabledBackgroundImageFilename() const;
-
-  /**
-   * @brief Sets the specified properties on the button label.
+   * @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
    */
-  void ModifyLabel( const Property::Map& properties );
+  void MergeWithExistingLabelProperties(const Property::Map& inMap, Property::Map& outMap);
 
   /**
    * Performs actions as requested using the action name.
@@ -210,94 +127,57 @@ public:
    * @param[in] attributes The attributes with which to perfrom this action.
    * @return true if action has been accepted by this control
    */
-  static bool DoAction( BaseObject* object, const std::string& actionName, const Property::Map& attributes );
-
-public: // Deprecated API
-
-  /**
-   * @copydoc Dali::Toolkit::Button::SetLabel( Actor label )
-   */
-  void SetLabel( Actor label );
-
-  /**
-   * @deprecated Sets the unselected image with an Actor.
-   * @param[in] image The Actor to use.
-   */
-  void SetButtonImage( Actor image );
-
-  /**
-   * @deprecated Sets the selected image with an Actor.
-   * @param[in] image The Actor to use.
-   */
-  void SetSelectedImage( Actor image );
-
-  /**
-   * @deprecated Sets the background image with an Actor.
-   * @param[in] image The Actor to use.
-   */
-  void SetBackgroundImage( Actor image );
-
-  /**
-   * @deprecated Sets the selected background image with an Actor.
-   * @param[in] image The Actor to use.
-   */
-  void SetSelectedBackgroundImage( Actor image );
-
-  /**
-   * @deprecated Sets the disabled image with an Actor.
-   * @param[in] image The Actor to use.
-   */
-  void SetDisabledImage( Actor image );
-
-  /**
-   * @deprecated Sets the disabled selected image with an Actor.
-   * @param[in] image The Actor to use.
-   */
-  void SetDisabledSelectedImage( Actor image );
-
-  /**
-   * @deprecated Sets the disabled background image with an Actor.
-   * @param[in] image The Actor to use.
-   */
-  void SetDisabledBackgroundImage( Actor image );
+  static bool DoAction(BaseObject* object, const std::string& actionName, const Property::Map& attributes);
 
+public:
   /**
-   * @copydoc Dali::Toolkit::Button::GetButtonImage
+   * Button's state
    */
-  Actor GetButtonImage() 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::GetSelectedImage
+   * Enum to distinguish the different style-able components of the button
    */
-  Actor GetSelectedImage() const;
-
-protected:
-
-  enum ButtonState
+  enum Visuals
   {
-    ButtonUp,                                  ///< The button is up.
-    ButtonDown,                                ///< The button is down.
+    UNSELECTED_FOREGROUND = 0,
+    SELECTED_FOREGROUND,
+    DISABLED_SELECTED_FOREGROUND,
+    DISABLED_UNSELECTED_FOREGROUND,
+    UNSELECTED_BACKGROUND,
+    SELECTED_BACKGROUND,
+    DISABLED_UNSELECTED_BACKGROUND,
+    DISABLED_SELECTED_BACKGROUND,
+    VISUALS_COUNT
   };
 
   /**
-   * Button paint states.
+   * Enum to list types of visual a state can have.
    */
-  enum PaintState
+  enum VisualState
   {
-    UnselectedState,              ///< The button is unselected.
-    SelectedState,                ///< The button is selected.
-    DisabledUnselectedState,      ///< The button is disabled and unselected.
-    DisabledSelectedState,        ///< The button is disabled and selected.
+    BACKGROUND = 0,
+    FOREGROUND,
+    VISUAL_STATE_COUNT
   };
 
+protected:
   /**
-   * Enum to specify which decoration when getting and setting decorations.
+   * 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
    */
-  enum DecorationState
+  enum PressState
   {
-    UNSELECTED_DECORATION = 0,
-    SELECTED_DECORATION,
-    DECORATION_STATES
+    DEPRESSED,        ///< The button is up.
+    UNPRESSED,        ///< The button is down.
+    TOGGLE_DEPRESSED, ///< The button has been pressed down and will stay depressed when released.
   };
 
   /**
@@ -317,99 +197,27 @@ protected:
   /**
    * @return A reference to the unselected button image.
    */
-  Actor& GetUnselectedImage();
+  Actor GetUnselectedImage();
 
   /**
    * @return A reference to the selected image.
    */
-  Actor& GetSelectedImage();
-
-  /**
-   * @return A reference to the background image.
-   */
-  Actor& GetBackgroundImage();
-
-  /**
-   * @return A reference to the selected background image.
-   */
-  Actor& GetSelectedBackgroundImage();
-
-  /**
-   * @return A reference to the disabled button image.
-   */
-  Actor& GetDisabledImage();
-
-  /**
-   * @return A reference to the disabled selected image.
-   */
-  Actor& GetDisabledSelectedImage();
-
-  /**
-   * @return A reference to the disabled background image.
-   */
-  Actor& GetDisabledBackgroundImage();
+  Actor GetSelectedImage();
 
 private:
-
   /**
    * 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.
    */
-  bool DoClickAction( const Property::Map& attributes );
+  bool DoClickAction(const Property::Map& attributes);
 
   /**
-   * This method is called when the label is set.
-   * @param[in] noPadding Used to bypass padding if the label is to be treated generically.
-   */
-  virtual void OnLabelSet( bool noPadding ) {}
-
-  /**
-   * This method is called when the unselected button image is set
-   */
-  virtual void OnUnselectedImageSet() {}
-
-  /**
-   * This method is called when the selected image is set
-   */
-  virtual void OnSelectedImageSet() {}
-
-  /**
-   * This method is called when the background image is set
-   */
-  virtual void OnBackgroundImageSet() {}
-
-  /**
-   * This method is called when the selected background image is set
-   */
-  virtual void OnSelectedBackgroundImageSet() {}
-
-  /**
-   * This method is called when the disabled button image is set
-   */
-  virtual void OnDisabledImageSet() {}
-
-  /**
-   * This method is called when the disabled selected image is set
-   */
-  virtual void OnDisabledSelectedImageSet() {}
-
-  /**
-   * This method is called when the disabled background image is set
-   */
-  virtual void OnDisabledBackgroundImageSet() {}
-
-  /**
-   * This method is called the button is down.
+   * 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 OnButtonDown();
-
-  /**
-   * This method is called when the button is up.
-   * Could be reimplemented in subclasses to provide specific behaviour.
-   */
-  virtual void OnButtonUp();
+  virtual bool OnToggleReleased();
 
   /**
    * This method is called when touch leaves the boundary of the button or several touch points are received.
@@ -426,25 +234,32 @@ private:
   /**
    * 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.
    */
-  virtual void OnDisabled() {}
+  virtual void OnDisabled()
+  {
+  }
 
   /**
    * This method is called when the button is pressed.
    */
-  virtual void OnPressed() {}
+  virtual void OnPressed()
+  {
+  }
 
   /**
    * This method is called when the button is released.
    */
-  virtual void OnReleased() {}
+  virtual void OnReleased()
+  {
+  }
 
 public:
-
   /**
    * @copydoc Dali::Toolkit::PushButton::PressedSignal()
    */
@@ -474,7 +289,7 @@ public:
    * @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.
    */
-  static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
+  static bool DoConnectSignal(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor);
 
   // Properties
 
@@ -484,7 +299,7 @@ public:
    * @param[in] index The property index.
    * @param[in] value The new property value.
    */
-  static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
+  static void SetProperty(BaseObject* object, Property::Index index, const Property::Value& value);
 
   /**
    * Called to retrieve a property of an object of this type.
@@ -492,42 +307,59 @@ public:
    * @param[in] index The property index.
    * @return The current value of the property.
    */
-  static Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex );
+  static Property::Value GetProperty(BaseObject* object, Property::Index propertyIndex);
 
 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();
+  void OnInitialize() override;
 
   /**
    * @copydoc Toolkit::Control::OnAccessibilityActivated()
    */
-  virtual bool OnAccessibilityActivated();
+  bool OnAccessibilityActivated() override;
 
   /**
    * @copydoc Toolkit::Control::OnKeyboardEnter()
    */
-  virtual bool OnKeyboardEnter();
+  bool OnKeyboardEnter() override;
 
   /**
-   * @copydoc Toolkit::Control::OnStageDisconnection()
-   * @note If overridden by deriving button classes, then an up-call to Button::OnStageDisconnection MUST be made at the end.
+   * @copydoc Toolkit::Control::OnSceneDisconnection()
+   * @note If overridden by deriving button classes, then an up-call to Button::OnSceneDisconnection MUST be made at the end.
    */
-  void OnStageDisconnection();
+  void OnSceneDisconnection() override;
 
+  /**
+   * @copydoc Toolkit::Control::OnSceneConnection()
+   */
+  void OnSceneConnection(int depth) override;
 
-private:
+  /**
+   * @copydoc Toolkit::Control::GetNaturalSize
+   */
+  Vector3 GetNaturalSize() override;
 
   /**
+   * @copydoc Toolkit::Control::OnSetResizePolicy
+   */
+  void OnSetResizePolicy(ResizePolicy::Type policy, Dimension::Type dimension) override;
+
+  /**
+   * @copydoc Toolkit::Control::OnRelayout
+   */
+  void OnRelayout(const Vector2& size, RelayoutContainer& container) override;
+
+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 );
+  bool OnTouch(Actor actor, const TouchEvent& touch);
 
   /**
    * Handler for tap events.
@@ -543,239 +375,200 @@ private:
    * Sets up the autorepeating timer.
    * @param[in] delay The delay time in seconds.
    */
-  void SetUpTimer( float delay );
+  void SetUpTimer(float delay);
 
   /**
-   * Slot called when Dali::Timer::SignalTick signal. Resets the autorepeating timer.
-   */
-  bool AutoRepeatingSlot();
-
-  /**
-   * 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.
-   */
-  void SetSelected( bool selected, bool emitSignal );
-
-  /**
-   * This method is called when the button is pressed.
+   * Button has been pressed
    */
   void Pressed();
 
   /**
-   * This method is called when the button is released.
-   */
-  void Released();
-
-  /**
-   * Used to perform common setup applied to images within button.
-   * This will replace the current image with the specifed one.
-   * @param[in]  actorToModify The image to replace.
-   * @param[out] newActor The new image to use.
-   */
-  void SetupContent( Actor& actorToModify, Actor newActor );
-
-  /**
-   * Gets the unselected content color.
-   * @return     The currently used unselected color.
-   */
-  const Vector4 GetUnselectedColor() const;
-
-  /**
-   * 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]  selectedState The state to apply the color to, SelectedState or DisabledUnselectedState.
+   * This method is called the button is down.
    */
-  void SetColor( const Vector4& color, PaintState selectedState );
+  void ButtonDown();
 
   /**
-   * Gets the selected content color.
-   * @return     The currently used selected color.
+   * This method is called when the button is up.
    */
-  const Vector4 GetSelectedColor() const;
-
-protected:
-
-  ButtonState GetState();
-  PaintState GetPaintState();
-  void SetDecoration( DecorationState state, Actor actor );
-  Actor& GetDecoration( DecorationState state );
-
+  void ButtonUp();
 
   /**
-   * Returns the animation to be used for transitioning creating the animation if needed.
-   * @return The initialised transition animation.
+   * Slot called when Dali::Timer::SignalTick signal. Resets the autorepeating timer.
    */
-  Dali::Animation GetTransitionAnimation();
+  bool AutoRepeatingSlot();
 
   /**
-   * Prepares the actor to be transitioned in.
-   * @param[in]  actor  The actor that will be transitioned in.
+   *  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 PrepareForTranstionIn( Actor actor ) {}
+  bool ValidateState(State requestedState);
 
   /**
-   * Prepares the actor to be transitioned in.
-   * @param[in]  actor  The actor that will be transitioned out.
+   * Changes the button state when an action occurs on it
+   * @param[in] requestedState the state to change to
    */
-  virtual void PrepareForTranstionOut( Actor actor ) {}
+  void ChangeState(State requestedState);
 
   /**
-   * 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.
+   * This method is called when the button is released.
    */
-  virtual void OnTransitionIn( Actor actor ) {}
+  void Released();
 
+protected:
   /**
-   * 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.
+   * Set Text Label Padding
+   * @param[in] padding BEGIN END BOTTOM TOP
    */
-  virtual void OnTransitionOut( Actor actor ) {}
-
-private:
+  void SetLabelPadding(const Padding& padding);
 
   /**
-   * Starts the transition animation.
-   * Button::TransitionFinished is called when the animation finishes.
+   * Get Text Label padding
+   * @return Padding
    */
-  void StartTransitionAnimation();
+  Padding GetLabelPadding();
 
   /**
-   * This method stops all transition animations
+   * Set Foreground/icon Padding
+   * @param[in] padding BEGIN END BOTTOM TOP
    */
-  void StopTransitionAnimation();
+  void SetForegroundPadding(const Padding& padding);
 
   /**
-   * Called when the transition animation finishes.
+   * Get Foreground padding
+   * @ return Padding
    */
-  void TransitionAnimationFinished( Dali::Animation& source );
+  Padding GetForegroundPadding();
 
   /**
-   * 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.
+   * @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 ResetImageLayers();
+  void CreateVisualsForComponent(Property::Index index, const Property::Value& value, const int visualDepth);
 
   /**
-   * Transitions out the actor
+   * @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
    */
-  void TransitionOut( Actor actor );
-
+  bool GetPropertyMapForVisual(Property::Index visualIndex, Property::Map& retreivedMap) const;
   /**
-   * Removes the actor from the button and prepares it to be transitioned out
+   * Returns the animation to be used for transition, creating the animation if needed.
+   * @return The initialised transition animation.
    */
-  void RemoveButtonImage( Actor& actor );
+  Dali::Animation GetTransitionAnimation();
 
   /**
-   * Finds the index of the actor.
-   * If the actor doesn't exist, return the last index + 1.
+   * @brief Set the position of the label relative to foreground/icon, if both present
+   * @param[in] labelAlignment given alignment setting
    */
-  unsigned int FindChildIndex( Actor& actor );
+  void SetLabelAlignment(Align labelAlignment);
 
   /**
-   * Adds an actor to the hierarchy and prepares it to be transitioned.
-   * @param[in] actor The actor to add
+   * @brief Get set alignment of label in relation to foreground/icon
+   * @return Set alignment value
    */
-  void PrepareAddButtonImage( Actor& actor );
+  Align GetLabelAlignment();
 
   /**
-   * Adds an actor to the hierarchy and marks it to be transitioned.
-   * @param[in] actor The actor to add
+   * 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 TransitionButtonImage( Actor& actor );
+  virtual void OnButtonVisualRemoval(Property::Index visualIndex);
 
+private:
   /**
-   * Adds an actor to the hierarchy.
-   * @param[in] actor The actor to add
+   * Removes the visual from the button and prepares it to be transitioned out
+   * @param[in] visualIndex the visual to remove
    */
-  void AddButtonImage( Actor& actor );
+  void RemoveVisual(Property::Index visualIndex);
 
   /**
-   * (Re)Adds the label (if exists) to the hierarchy (so it is always on top).
+   * Adds the required visual to the button.
+   * @param[in] visualIndex The Property index of the visual required
    */
-  void ReAddLabel();
+  void SelectRequiredVisual(Property::Index visualIndex);
 
   // Undefined
-  Button( const Button& );
+  Button(const Button&);
 
   // Undefined
-  Button& operator = ( const Button& );
+  Button& operator=(const Button&);
 
 private:
-
   // 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 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 mPressedSignal;      ///< Signal emitted when the button is pressed.
+  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.
 
-  Actor mLabel;                                ///< Stores the button label.
+  Timer mAutoRepeatingTimer;
 
-  Actor mDecoration[ DECORATION_STATES ];      ///< Stores the decorations for both selected and unselected states.
+  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;
 
-  Vector4          mUnselectedColor;           ///< Color to use for unselected content.
-  Vector4          mSelectedColor;             ///< Color to use for selected content.
+  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.
 
-  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.
+  float mAnimationTime;
 
-  float            mAnimationTime;             ///< The animation time.
+  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
+
+protected:
+  struct AccessibleImpl : public DevelControl::ControlAccessible
+  {
+    using DevelControl::ControlAccessible::ControlAccessible;
 
-  ButtonState      mState;                     ///< Stores the button state.
-  PaintState       mPaintState;                ///< Stores the paint state.
+    Dali::Accessibility::States CalculateStates() override;
+    std::string                 GetNameRaw() const override;
+    Property::Index             GetNamePropertyIndex() override;
+  };
 };
 
 } // namespace Internal
 
 // Helpers for public-api forwarding methods
 
-inline Toolkit::Internal::Button& GetImplementation( Toolkit::Button& button )
+inline Toolkit::Internal::Button& GetImplementation(Toolkit::Button& button)
 {
-  DALI_ASSERT_ALWAYS( button );
+  DALI_ASSERT_ALWAYS(button);
 
   Dali::RefObject& handle = button.GetImplementation();
 
-  return static_cast<Toolkit::Internal::Button&>( handle );
+  return static_cast<Toolkit::Internal::Button&>(handle);
 }
 
-inline const Toolkit::Internal::Button& GetImplementation( const Toolkit::Button& button )
+inline const Toolkit::Internal::Button& GetImplementation(const Toolkit::Button& button)
 {
-  DALI_ASSERT_ALWAYS( button );
+  DALI_ASSERT_ALWAYS(button);
 
   const Dali::RefObject& handle = button.GetImplementation();
 
-  return static_cast<const Toolkit::Internal::Button&>( handle );
+  return static_cast<const Toolkit::Internal::Button&>(handle);
 }
 
 } // namespace Toolkit
 
 } // namespace Dali
 
-#endif // __DALI_TOOLKIT_INTERNAL_BUTTON_H__
+#endif // DALI_TOOLKIT_INTERNAL_BUTTON_H