[AT-SPI] Squashed implementation
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / buttons / push-button-impl.h
index 1297fef..1db13d5 100644 (file)
@@ -1,8 +1,8 @@
-#ifndef __DALI_TOOLKIT_INTERNAL_PUSH_BUTTON_H__
-#define __DALI_TOOLKIT_INTERNAL_PUSH_BUTTON_H__
+#ifndef DALI_TOOLKIT_INTERNAL_PUSH_BUTTON_H
+#define DALI_TOOLKIT_INTERNAL_PUSH_BUTTON_H
 
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2019 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.
@@ -19,8 +19,7 @@
  */
 
 // EXTERNAL INCLUDES
-#include <dali/public-api/adaptor-framework/timer.h>
-#include <dali/public-api/common/dali-vector.h>
+#include <dali/public-api/common/vector-wrapper.h>
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/public-api/controls/buttons/push-button.h>
@@ -50,318 +49,72 @@ public:
    */
   static Dali::Toolkit::PushButton New();
 
-  /**
-   * @copydoc Dali::Toolkit::PushButton::SetAutoRepeating( bool autoRepeating )
-   */
-  void SetAutoRepeating( bool autoRepeating );
-
-  /**
-   * @copydoc Dali::Toolkit::PushButton::IsAutoRepeating() const
-   */
-  bool IsAutoRepeating() const;
-
-  /**
-   * @copydoc Dali::Toolkit::PushButton::SetInitialAutoRepeatingDelay( float initialAutoRepeatingDelay )
-   */
-  void SetInitialAutoRepeatingDelay( float initialAutoRepeatingDelay );
-
-  /**
-   * @copydoc Dali::Toolkit::PushButton::GetInitialAutoRepeatingDelay() const
-   */
-  float GetInitialAutoRepeatingDelay() const;
-
-  /**
-   * @copydoc Dali::Toolkit::PushButton::SetNextAutoRepeatingDelay( float nextAutoRepeatingDelay )
-   */
-  void SetNextAutoRepeatingDelay( float nextAutoRepeatingDelay );
-
-  /**
-   * @copydoc Dali::Toolkit::PushButton::GetNextAutoRepeatingDelay() const
-   */
-  float GetNextAutoRepeatingDelay() const;
-
-  /**
-   * @copydoc Dali::Toolkit::PushButton::SetToggleButton( bool toggle )
-   */
-  void SetToggleButton( bool toggle );
-
-  /**
-   * @copydoc Dali::Toolkit::PushButton::IsToggleButton() const
-   */
-  bool IsToggleButton() const;
-
-  /**
-   * @copydoc Dali::Toolkit::PushButton::SetToggled( bool toggle )
-   */
-  void SetToggled( bool toggle );
-
-  /**
-   * @copydoc Dali::Toolkit::PushButton::IsToggled() const
-   */
-  bool IsToggled() const;
-
-  /**
-   * @copydoc Dali::Toolkit::PushButton::SetButtonImage( const Image image )
-   */
-  void SetButtonImage( Image image );
-
-  /**
-   * @copydoc Dali::Toolkit::PushButton::SetButtonImage( Actor image )
-   */
-  void SetButtonImage( Actor image );
-
-  /**
-   * Used by the painter only.
-   * @return A reference to the button image.
-   */
-  Actor& GetButtonImage();
-
-  /**
-   * @copydoc Dali::Toolkit::PushButton::
-   */
-  Actor GetButtonImage() const;
-
-  /**
-   * @copydoc Dali::Toolkit::PushButton::SetBackgroundImage( const Image image )
-   */
-  void SetBackgroundImage( Image image );
-
-  /**
-   * @copydoc Dali::Toolkit::PushButton::SetBackgroundImage( Actor image )
-   */
-  void SetBackgroundImage( Actor image );
-
-  /**
-   * Used by the painter only.
-   * @return A reference to the background image.
-   */
-  Actor& GetBackgroundImage();
-
-  /**
-   * @copydoc Dali::Toolkit::PushButton::GetBackgroundImage()
-   */
-  Actor GetBackgroundImage() const;
-
-  /**
-   * @copydoc Dali::Toolkit::PushButton::SetSelectedImage( const Image image )
-   */
-  void SetSelectedImage( Image image );
-
-  /**
-   * @copydoc Dali::Toolkit::PushButton::SetSelectedImage( Actor image )
-   */
-  void SetSelectedImage( Actor image );
-
-  /**
-   * Used by the painter only.
-   * @return A reference to the selected image.
-   */
-  Actor& GetSelectedImage();
-
-  /**
-   * @copydoc Dali::Toolkit::PushButton::GetSelectedImage()
-   */
-  Actor GetSelectedImage() const;
-
-  /**
-   * @copydoc Dali::Toolkit::PushButton::SetDisabledBackgroundImage( Image image )
-   */
-  void SetDisabledBackgroundImage( Image image );
-
-  /**
-   * @copydoc Dali::Toolkit::PushButton::SetDisabledBackgroundImage( Actor image )
-   */
-  void SetDisabledBackgroundImage( Actor image );
-
-  /**
-   * Used by the painter only.
-   * @return A reference to the disabled background image.
-   */
-  Actor& GetDisabledBackgroundImage();
-
-  /**
-   * @copydoc Dali::Toolkit::PushButton::GetDisabledBackgroundImage()
-   */
-  Actor GetDisabledBackgroundImage() const;
-
-  /**
-   * @copydoc Dali::Toolkit::PushButton::SetDisabledImage( Image image )
-   */
-  void SetDisabledImage( Image image );
-
-  /**
-   * @copydoc Dali::Toolkit::PushButton::SetDisabledImage( Actor image )
-   */
-  void SetDisabledImage( Actor image );
-
-  /**
-   * Used by the painter only.
-   * @return A reference to the disabled button image.
-   */
-  Actor& GetDisabledImage();
+protected:
 
   /**
-   * @copydoc Dali::Toolkit::PushButton::GetDisabledImage()
-   */
-  Actor GetDisabledImage() const;
-
-  /**
-   * @copydoc Dali::Toolkit::PushButton::SetLabel( const std::string& label )
-   */
-  void SetLabel( const std::string& label );
-
-  /**
-   * @copydoc Dali::Toolkit::PushButton::SetLabel( Actor label )
-   */
-  void SetLabel( Actor label );
-
-  /**
-   * @copydoc Dali::Toolkit::PushButton::GetLabel()
-   */
-  Actor GetLabel() const;
-
-  /**
-   * Used by the painter only.
-   * @return A reference to the label actor.
-   */
-  Actor& GetLabel();
-
-  /**
-   * Used by the painter only.
-   * @return A reference to the background image that is fading out.
+   * Construct a new PushButton.
    */
-  Actor& GetFadeOutBackgroundImage();
+  PushButton();
 
   /**
-   * Used by the painter only.
-   * @return A reference to the button image that is fading out.
+   * A reference counted object may only be deleted by calling Unreference()
    */
-  Actor& GetFadeOutButtonImage();
+  virtual ~PushButton();
 
 public:
 
-  // Signals
-
-  /**
-   * @copydoc Dali::Toolkit::PushButton::PressedSignal()
-   */
-  Toolkit::PushButton::PressedSignalType& PressedSignal();
-
-  /**
-   * @copydoc Dali::Toolkit::PushButton::ReleasedSignal()
-   */
-  Toolkit::PushButton::ReleasedSignalType& ReleasedSignal();
-
-  /**
-   * 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.
-   */
-  static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
-
   // Properties
 
   /**
-   * @copydoc Button::SetProperty
-   */
-  static void SetProperty( BaseObject* object, Property::Index propertyIndex, const Property::Value& value );
-
-  /**
-   * @copydoc Button::GetProperty
-   */
-  static Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex );
-
-protected: // From Button
-
-  /**
-   * Sets the Leave signal.
+   * Enum for the alignment modes of the icon.
    */
-  virtual void OnButtonInitialize();
+  enum IconAlignment
+  {
+    LEFT,
+    RIGHT,
+    TOP,
+    BOTTOM,
+    DEFAULT = RIGHT
+  };
 
   /**
-   * Emits signals and notifies the painter accordingly with the set button
-   * properties when the button is pressed.
+   * 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.
    */
-  virtual void OnButtonDown();
+  static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
 
   /**
-   * Emits signals and notifies the painter accordingly with the set button
-   * properties when the button is released.
+   * 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.
    */
-  virtual void OnButtonUp();
-
-  /**
-   * Emits signals and notifies the painter accordingly with the set button
-   * properties when the touch point leaves the boundary of the button.
-   */
-  virtual void OnTouchPointLeave();
-
-  /**
-   * Currently it doesn't need different behaviour than @see OnTouchPointLeave()
-   */
-  virtual void OnTouchPointInterrupted();
-
-  /**
-   * Sets the push button animation time.
-   * @param animationTime The animation time in seconds.
-   */
-  virtual void OnAnimationTimeSet( float animationTime );
-
-  /**
-   * Retrieves the animation time.
-   * @return The animation time in seconds.
-   */
-  virtual float OnAnimationTimeRequested() const;
-
-  /**
-   * This method is called when the button is removed from the stage.
-   */
-  virtual void OnButtonStageDisconnection();
-
-protected: // From Control
+  static Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex );
 
-  /**
-   * Respond the activate notification.
-   */
-  virtual void OnActivated();
+private: // From Button
 
   /**
-   * @copydoc Control::GetNaturalSize()
+   * @copydoc Toolkit::Internal::Button::OnInitialize
    */
-  virtual Vector3 GetNaturalSize();
+  void OnInitialize() override;
 
 private:
 
   /**
-   * Perform the click action to click the button.
-   * @param[in] attributes The attributes to perfrom this action.
+   * @brief Sets the alignment mode to use to align the icon to the label.
+   *
+   * @param[in] iconAlignment The alignment mode to use
    */
-  void DoClickAction(const PropertyValueContainer& attributes);
-
-public:
+  void SetIconAlignment( const PushButton::IconAlignment iconAlignment );
 
   /**
-   * 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
+   * @brief Gets the alignment mode used to align the icon to the label.
+   *
+   * @return The alignment mode in use
    */
-  static bool DoAction(BaseObject* object, const std::string& actionName, const PropertyValueContainer& attributes);
-
-  /**
-   * Construct a new PushButton.
-   */
-  PushButton();
-
-  /**
-   * A reference counted object may only be deleted by calling Unreference()
-   */
-  virtual ~PushButton();
+  const PushButton::IconAlignment GetIconAlignment() const;
 
 private:
 
@@ -371,46 +124,18 @@ private:
   // Undefined
   PushButton& operator=( const PushButton& );
 
-  /**
-   * Sets up the autorepeating timer.
-   * @param[in] delay The delay time in seconds.
-   */
-  void SetUpTimer( float delay );
-
-  /**
-   * Slot called when Dali::Timer::SignalTick signal. Resets the autorepeating timer.
-   */
-  bool AutoRepeatingSlot();
-
 private:
-  bool  mAutoRepeating;             ///< Stores the autorepeating property.
-  float mInitialAutoRepeatingDelay; ///< Stores the initial autorepeating delay in seconds.
-  float mNextAutoRepeatingDelay;    ///< Stores the next autorepeating delay in seconds.
-  bool  mToggleButton;              ///< Stores the toggle property.
-
-  // AutoRepeating
-  Timer mAutoRepeatingTimer;        ///< Timer used to implement the autorepeating property.
-
-  // Toggle
-  bool  mToggled;                   ///< Stores the toggle state.
-
-  // Signals
-  Toolkit::PushButton::PressedSignalType mPressedSignal;   ///< Signal emitted when the button is pressed.
-  Toolkit::PushButton::ReleasedSignalType mReleasedSignal; ///< Signal emitted when the button is released.
-
-  Actor mButtonImage;               ///< Stores the unselected image.
-  Actor mBackgroundImage;           ///< Stores the background image.
-  Actor mSelectedImage;             ///< Stores the selected image.
-  Actor mDisabledImage;             ///< Stores the disabled image.
-  Actor mDisabledBackgroundImage;   ///< Stores the disabled background image.
 
-  Actor mLabel;                     ///< Stores the text label.
+  IconAlignment  mIconAlignment;                 ///< The alignment of the icon against the label.
 
-  Actor mFadeOutBackgroundImage;    ///< Stores a background image, which is in a fade out animation, to be removed when the animation finishes.
-  Actor mFadeOutButtonImage;        ///< Stores a foreground image, which is in a fade out animation, to be removed when the animation finishes.
+protected:
+  struct AccessibleImpl : public Button::AccessibleImpl
+  {
+    using Button::AccessibleImpl::AccessibleImpl;
 
-  // Actions
-  bool mClickActionPerforming;
+    Dali::Accessibility::States CalculateStates() override;
+  };
+  void OnStateChange( State newState ) override;
 };
 
 } // namespace Internal
@@ -439,4 +164,4 @@ inline const Toolkit::Internal::PushButton& GetImplementation( const Toolkit::Pu
 
 } // namespace Dali
 
-#endif // __DALI_TOOLKIT_INTERNAL_PUSH_BUTTON_H__
+#endif // DALI_TOOLKIT_INTERNAL_PUSH_BUTTON_H