[AT-SPI] Rename AccessibleImpl to <Control>Accessible
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / buttons / push-button-impl.h
index 730b746..b04f6b7 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) 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.
@@ -19,7 +19,7 @@
  */
 
 // EXTERNAL INCLUDES
-#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>
 
 namespace Dali
 {
-
 namespace Toolkit
 {
-
 namespace Internal
 {
-
 /**
  * PushButton implementation class.
  *
@@ -42,70 +39,124 @@ namespace Internal
 class PushButton : public Button
 {
 public:
-
   /**
    * Create a new PushButton.
    * @return A smart-pointer to the newly allocated PushButton.
    */
   static Dali::Toolkit::PushButton New();
 
-protected: // From Button
+protected:
+  /**
+   * Construct a new PushButton.
+   */
+  PushButton();
 
   /**
-   * Sets the Leave signal.
+   * A reference counted object may only be deleted by calling Unreference()
    */
-  virtual void OnButtonInitialize();
+  virtual ~PushButton();
 
-protected: // From Control
+public:
+  // Properties
 
   /**
-   * @copydoc Control::GetNaturalSize()
+   * Enum for the alignment modes of the icon.
    */
-  virtual Vector3 GetNaturalSize();
+  enum IconAlignment
+  {
+    LEFT,
+    RIGHT,
+    TOP,
+    BOTTOM,
+    DEFAULT = RIGHT
+  };
 
   /**
-   * Construct a new PushButton.
+   * 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.
    */
-  PushButton();
+  static void SetProperty(BaseObject* object, Property::Index index, const Property::Value& value);
 
   /**
-   * A reference counted object may only be deleted by calling Unreference()
+   * 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 ~PushButton();
+  static Property::Value GetProperty(BaseObject* object, Property::Index propertyIndex);
+
+private: // From Button
+  /**
+   * @copydoc Toolkit::Internal::Button::OnInitialize
+   */
+  void OnInitialize() override;
 
 private:
+  /**
+   * @brief Sets the alignment mode to use to align the icon to the label.
+   *
+   * @param[in] iconAlignment The alignment mode to use
+   */
+  void SetIconAlignment(const PushButton::IconAlignment iconAlignment);
+
+  /**
+   * @brief Gets the alignment mode used to align the icon to the label.
+   *
+   * @return The alignment mode in use
+   */
+  const PushButton::IconAlignment GetIconAlignment() const;
 
+private:
   // Undefined
-  PushButton( const PushButton& );
+  PushButton(const PushButton&);
 
   // Undefined
-  PushButton& operator=( const PushButton& );
+  PushButton& operator=(const PushButton&);
+
+private:
+  IconAlignment mIconAlignment; ///< The alignment of the icon against the label.
+
+protected:
+  class PushButtonAccessible : public Button::ButtonAccessible
+  {
+  public:
+    using Button::ButtonAccessible::ButtonAccessible;
+
+    /**
+     * @copydoc Dali::Toolkit::DevelControl::ControlAccessible::CalculateStates()
+     */
+    Dali::Accessibility::States CalculateStates() override;
+  };
+
+  void OnStateChange(State newState) override;
 };
 
 } // namespace Internal
 
 // Helpers for public-api forwarding methods
 
-inline Toolkit::Internal::PushButton& GetImplementation( Toolkit::PushButton& button )
+inline Toolkit::Internal::PushButton& GetImplementation(Toolkit::PushButton& button)
 {
-  DALI_ASSERT_ALWAYS( button );
+  DALI_ASSERT_ALWAYS(button);
 
   Dali::RefObject& handle = button.GetImplementation();
 
-  return static_cast<Toolkit::Internal::PushButton&>( handle );
+  return static_cast<Toolkit::Internal::PushButton&>(handle);
 }
 
-inline const Toolkit::Internal::PushButton& GetImplementation( const Toolkit::PushButton& button )
+inline const Toolkit::Internal::PushButton& GetImplementation(const Toolkit::PushButton& button)
 {
-  DALI_ASSERT_ALWAYS( button );
+  DALI_ASSERT_ALWAYS(button);
 
   const Dali::RefObject& handle = button.GetImplementation();
 
-  return static_cast<const Toolkit::Internal::PushButton&>( handle );
+  return static_cast<const Toolkit::Internal::PushButton&>(handle);
 }
 
 } // namespace Toolkit
 
 } // namespace Dali
 
-#endif // __DALI_TOOLKIT_INTERNAL_PUSH_BUTTON_H__
+#endif // DALI_TOOLKIT_INTERNAL_PUSH_BUTTON_H