[dali_1.9.23] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / public-api / controls / buttons / button.h
index a3d0ca2..c9c79d6 100644 (file)
@@ -1,8 +1,8 @@
-#ifndef __DALI_TOOLKIT_BUTTON_H__
-#define __DALI_TOOLKIT_BUTTON_H__
+#ifndef DALI_TOOLKIT_BUTTON_H
+#define DALI_TOOLKIT_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.
@@ -31,227 +31,260 @@ namespace Internal DALI_INTERNAL
 {
 class Button;
 }
+/**
+ * @addtogroup dali_toolkit_controls_buttons
+ * @{
+ */
 
 /**
- * @brief Button is a base class for different kind of buttons.
+ * @brief Button is a base class for different kinds of buttons.
  *
  * This class provides the disabled property and the clicked signal.
  *
- * A ClickedSignal() is emitted when the button is touched and the touch
- * point doesn't leave the boundary of the button.
+ * A ClickedSignal() is emitted when the button is touched and the touch point doesn't leave the boundary of the button.
  *
  * When the \e disabled property is set to \e true, no signal is emitted.
  *
+ * Button provides the following properties which modify the signals emitted:
+ * <ul>
+ *   <li>\e autorepeating
+ *       When \e autorepeating is set to \e true, a Button::PressedSignal(), Button::ReleasedSignal() and Button::ClickedSignal() signals are emitted at regular
+ *       intervals while the button is touched.
+ *       The intervals could be modified with the Button::SetInitialAutoRepeatingDelay and Button::SetNextAutoRepeatingDelay methods.
+ *
+ *       A \e togglable button can't be \e autorepeating. If the \e autorepeating property is set to \e true, then the \e togglable property is set to
+ *       false but no signal is emitted.
+ *
+ *   <li>\e togglable
+ *       When \e togglable is set to \e true, a Button::StateChangedSignal() signal is emitted, with the selected state.
+ * </ul>
+ *
+ * 'Visual' describes not just traditional images like png, bmp but refers to whatever is used to show the button, it could be a color, gradient or some other kind of renderer.
+ *
+ * The button's appearance can be modified by setting properties for the various visuals/images.
+ *
+ * It is not mandatory to set all visuals. A button could be defined only by setting its \e background visual or by setting its \e background and \e selected visuals.
+ *
+ * The \e button visual is shown over the \e background visual.
+ * When pressed the unselected visuals are replaced by the \e selected visual. The text label is always placed on the top of all images.
+ *
+ * When the button is disabled, \e background, \e button and \e selected visuals are replaced by their \e disabled visuals.
+ *
+ *
  * Signals
- * | %Signal Name      | Method                      |
- * |-------------------|-----------------------------|
- * | pressed           | @ref PressedSignal()        |
- * | released          | @ref ReleasedSignal()       |
- * | clicked           | @ref ClickedSignal()        |
- * | state-changed     | @ref StateChangedSignal()   |
+ * | %Signal Name     | Method                      |
+ * |------------------|-----------------------------|
+ * | pressed          | @ref PressedSignal()        |
+ * | released         | @ref ReleasedSignal()       |
+ * | clicked          | @ref ClickedSignal()        |
+ * | stateChanged     | @ref StateChangedSignal()   |
  *
  * Actions
- * | %Action Name      | %Button method called       |
- * |-------------------|-----------------------------|
- * | button-click      | %DoClickAction()            |
+ * | %Action Name     | Attributes              | Description                                   |
+ * |------------------|-------------------------|-----------------------------------------------|
+ * | buttonClick      | Doesn't have attributes | Simulates a button click. See @ref DoAction() |
+ * @SINCE_1_0.0
  */
-class DALI_IMPORT_API Button : public Control
+class DALI_TOOLKIT_API Button : public Control
 {
 public:
 
   /**
-   * @brief The start and end property ranges for this control.
+   * @brief Enumeration for the start and end property ranges for this control.
+   * @SINCE_1_0.0
    */
   enum PropertyRange
   {
-    PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1,
-    PROPERTY_END_INDEX =   PROPERTY_START_INDEX + 1000              ///< Reserve property indices
+    PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1, ///< @SINCE_1_0.0
+    PROPERTY_END_INDEX =   PROPERTY_START_INDEX + 1000              ///< Reserve property indices @SINCE_1_0.0
   };
 
   /**
-   * @brief An enumeration of properties belonging to the Button class.
+   * @brief Enumeration for the instance of properties belonging to the Button class.
+   * @SINCE_1_0.0
    */
   struct Property
   {
+    /**
+     * @brief Enumeration for the instance of properties belonging to the Button class.
+     * @SINCE_1_0.0
+     */
     enum
     {
-      DISABLED = PROPERTY_START_INDEX, ///< name "disabled",                     @see SetDisabled(),                  type BOOLEAN
-      AUTO_REPEATING,                  ///< name "auto-repeating",               @see SetAutoRepeating(),             type BOOLEAN
-      INITIAL_AUTO_REPEATING_DELAY,    ///< name "initial-auto-repeating-delay", @see SetInitialAutoRepeatingDelay(), type FLOAT
-      NEXT_AUTO_REPEATING_DELAY,       ///< name "next-auto-repeating-delay",    @see SetNextAutoRepeatingDelay(),    type FLOAT
-      TOGGLABLE,                       ///< name "togglable",                    @see SetTogglableButton(),           type BOOLEAN
-      SELECTED,                        ///< name "selected",                     @see SetSelected(),                  type BOOLEAN
-      NORMAL_STATE_ACTOR,              ///< name "normal-state-actor",           @see SetButtonImage(),               type MAP
-      SELECTED_STATE_ACTOR,            ///< name "selected-state-actor",         @see SetSelectedImage(),             type MAP
-      DISABLED_STATE_ACTOR,            ///< name "disabled-state-actor",         @see SetDisabledImage(),             type MAP
-      LABEL_ACTOR,                     ///< name "label-actor",                  @see SetLabel(),                     type MAP
+      /**
+       * @brief name "disabled", type bool
+       * @details Sets the button as \e disabled.
+       * @SINCE_1_0.0
+       */
+      DISABLED = PROPERTY_START_INDEX,
+
+      /**
+       * @brief name "autoRepeating", type bool
+       * @details If the \e autorepeating property is set to \e true then the \e togglable property is set to false
+       * @SINCE_1_0.0
+       */
+      AUTO_REPEATING,
+
+      /**
+       * @brief name "initialAutoRepeatingDelay", type float
+       * @details By default this value is set to 0.15 seconds.
+       * @SINCE_1_0.0
+       */
+      INITIAL_AUTO_REPEATING_DELAY,
+
+      /**
+       * @brief name "nextAutoRepeatingDelay", type float
+       * @details default this value is set to 0.05 seconds
+       * @SINCE_1_0.0
+       */
+      NEXT_AUTO_REPEATING_DELAY,
+
+      /**
+       * @brief name "togglable", type bool
+       * @details If the \e togglable property is set to \e true, then the \e autorepeating property is set to false.
+       * @SINCE_1_0.0
+       */
+      TOGGLABLE,
+
+      /**
+       * @brief name "selected", type bool
+       * @details Sets the togglable button as either selected or unselected, \e togglable property must be set to \e true.
+       * @SINCE_1_0.0
+       */
+      SELECTED,
+
+      /**
+       * @brief name "unselectedVisual", type string if it is a url, map otherwise.
+       * @details Sets the unselected button foreground/icon visual
+       * @SINCE_1_4.32
+       */
+      UNSELECTED_VISUAL,
+
+      /**
+       * @brief name "selectedImage", type string if it is a url, map otherwise
+       * @details Sets the selected button foreground/icon visual
+       * @SINCE_1_4.32
+       */
+      SELECTED_VISUAL,
+
+      /**
+       * @brief name "disabledSelectedVisual", type string if it is a url, map otherwise
+       * @details Sets the disabled selected state foreground/icon button visual
+       * @SINCE_1_4.32
+       */
+      DISABLED_SELECTED_VISUAL,
+
+      /**
+       * @brief name "disabledUnselectedVisual", type string if it is a url, map otherwise
+       * @details Sets the disabled unselected state foreground/icon visual
+       * @SINCE_1_4.32
+       */
+      DISABLED_UNSELECTED_VISUAL,
+
+      /**
+       * @brief name "unselectedBackgroundVisual", type string if it is a url, map otherwise
+       * @details Sets the disabled in the unselected state background, button visual
+       * @SINCE_1_4.32
+       */
+      UNSELECTED_BACKGROUND_VISUAL,
+
+      /**
+       * @brief name "label", type Property::Map or std::string
+       * @SINCE_1_0.0
+       */
+      LABEL,
+
+      /**
+       * @brief name "selectedBackgroundVisual", type string if it is a url, map otherwise
+       * @details Sets the selected background button visual
+       * @SINCE_1_4.32
+       */
+      SELECTED_BACKGROUND_VISUAL,
+
+      /**
+       * @brief name "disabledUnselectedBackgroundVisual", type string if it is a url, map otherwise
+       * @details Sets the disabled while unselected background button visual
+       * @SINCE_1_4.32
+       */
+      DISABLED_UNSELECTED_BACKGROUND_VISUAL,
+
+      /**
+       * @brief name "disabledSelectedBackgroundVisual", type string if it is a url, map otherwise
+       * @details Sets the disabled while selected background button visual
+       * @SINCE_1_4.32
+       */
+      DISABLED_SELECTED_BACKGROUND_VISUAL,
     };
   };
 
 public:
 
   /**
-   * @brief Create an uninitialized Button.
+   * @brief Creates an uninitialized Button.
    *
    * Only derived versions can be instantiated.  Calling member
    * functions with an uninitialized Dali::Object is not allowed.
+   * @SINCE_1_0.0
    */
   Button();
 
   /**
    * @brief Copy constructor.
+   * @SINCE_1_0.0
+   * @param[in] button Handle to an object
    */
   Button( const Button& button );
 
   /**
-   * @brief Assignment operator.
-   */
-  Button& operator=( const Button& button );
-
-  /**
-   * @brief Downcast an Object handle to Button.
-   *
-   * If handle points to a Button the downcast produces valid
-   * handle. If not the returned handle is left uninitialized.
-   *
-   * @param[in] handle Handle to an object
-   * @return handle to a Button or an uninitialized handle
-   */
-  static Button DownCast( BaseHandle handle );
-
-  /**
-   * @brief Destructor
-   *
-   * This is non-virtual since derived Handle types must not contain data or virtual methods.
-   */
-  ~Button();
-
-  /**
-   * @brief Sets the button as \e disabled.
-   *
-   * No signals are emitted when the \e disabled property is set.
-   *
-   * @param[in] disabled property.
-   */
-  void SetDisabled( bool disabled );
-
-  /**
-   * @return \e true if the button is \e disabled.
-   */
-  bool IsDisabled() const;
-
-  /**
-   * @brief Sets the \e autorepeating property.
-   *
-   * If the \e autorepeating property is set to \e true, then the \e togglable property is set to false
-   * but no signal is emitted.
-   *
-   * @param[in] autoRepeating \e autorepeating property.
-   */
-  void SetAutoRepeating( bool autoRepeating );
-
-  /**
-   * @return \e true if the \e autorepeating property is set.
-   */
-  bool IsAutoRepeating() const;
-
-  /**
-   * @brief Sets the initial autorepeating delay.
-   *
-   * By default this value is set to 0.15 seconds.
-   *
-   * @pre initialAutoRepeatingDelay must be greater than zero.
-   * @param[in] initialAutoRepeatingDelay in seconds.
-   */
-  void SetInitialAutoRepeatingDelay( float initialAutoRepeatingDelay );
-
-  /**
-   * @return the initial autorepeating delay in seconds.
-   */
-  float GetInitialAutoRepeatingDelay() const;
-
-  /**
-   * @brief Sets the next autorepeating delay.
-   *
-   * By default this value is set to 0.05 seconds.
-   *
-   * @pre nextAutoRepeatingDelay must be greater than zero.
-   * @param[in] nextAutoRepeatingDelay in seconds.
-   */
-  void SetNextAutoRepeatingDelay( float nextAutoRepeatingDelay );
-
-  /**
-   * @return the next autorepeating delay in seconds.
-   */
-  float GetNextAutoRepeatingDelay() const;
-
-  /**
-   * @brief Sets the \e togglable property.
-   *
-   * If the \e togglable property is set to \e true, then the \e autorepeating property is set to false.
+   * @brief Move constructor
+   * @SINCE_1_9.23
    *
-   * @param[in] togglable property.
-   */
-  void SetTogglableButton( bool togglable );
-
-  /**
-   * @return \e true if the \e togglable property is set.
+   * @param[in] rhs A reference to the moved handle
    */
-  bool IsTogglableButton() const;
+  Button( Button&& rhs );
 
   /**
-   * Sets the button as selected or unselected.
-   *
-   * \e togglable property must be set to \e true.
-   *
-   * Emits a Button::StateChangedSignal() signal.
-   *
-   * @param[in] selected property.
-   */
-  void SetSelected( bool selected );
-
-  /**
-   * @return \e true if the \e selected property is set and the button is togglable.
+   * @brief Assignment operator.
+   * @SINCE_1_0.0
+   * @param[in] button Handle to an object
+   * @return A reference to this
    */
-  bool IsSelected() const;
+  Button& operator=( const Button& button );
 
   /**
-   * @brief Sets the animation time.
+   * @brief Move assignment
+   * @SINCE_1_9.23
    *
-   * @param [in] animationTime The animation time in seconds.
+   * @param[in] rhs A reference to the moved handle
+   * @return A reference to this
    */
-  void SetAnimationTime( float animationTime );
+  Button& operator=( Button&& rhs );
 
   /**
-   * @brief Retrieves button's animation time.
+   * @brief Downcasts a handle to Button handle.
    *
-   * @return The animation time in seconds.
-   */
-  float GetAnimationTime() const;
-
-  /**
-   * @brief Sets the button label.
+   * If handle points to a Button, the downcast produces valid handle.
+   * If not the returned handle is left uninitialized.
    *
-   * @param[in] label The button label.
-   */
-  void SetLabel( const std::string& label );
-
-  /**
-   * @copydoc SetLabel( const std::string& label )
+   * @SINCE_1_0.0
+   * @param[in] handle Handle to an object
+   * @return A handle to a Button or an uninitialized handle
    */
-  void SetLabel( Actor label );
+  static Button DownCast( BaseHandle handle );
 
   /**
-   * @brief Gets the label.
+   * @brief Destructor.
    *
-   * @return An actor with the label.
+   * This is non-virtual since derived Handle types must not contain data or virtual methods.
+   * @SINCE_1_0.0
    */
-  Actor GetLabel() const;
+  ~Button();
 
 public: //Signals
 
   /**
-   * @brief Button signal type
+   * @brief Button signal type.
+   * @SINCE_1_0.0
    */
   typedef Signal< bool ( Button ) > ButtonSignalType;
 
@@ -262,7 +295,8 @@ public: //Signals
    * @code
    *   bool YourCallbackName( Button button );
    * @endcode
-   * @return The signal to connect to.
+   * @SINCE_1_0.0
+   * @return The signal to connect to
    */
   ButtonSignalType& PressedSignal();
 
@@ -273,7 +307,8 @@ public: //Signals
    * @code
    *   bool YourCallbackName( Button button );
    * @endcode
-   * @return The signal to connect to.
+   * @SINCE_1_0.0
+   * @return The signal to connect to
    */
   ButtonSignalType& ReleasedSignal();
 
@@ -284,41 +319,51 @@ public: //Signals
    * @code
    *   bool YourCallbackName( Button button );
    * @endcode
-   * @return The signal to connect to.
+   * @SINCE_1_0.0
+   * @return The signal to connect to
    */
   ButtonSignalType& ClickedSignal();
 
   /**
    * @brief This signal is emitted when the button's state is changed.
+   *
    * The application can get the state by calling IsSelected().
    *
    * A callback of the following type may be connected:
    * @code
    *   bool YourCallbackName( Button button );
    * @endcode
-   * @return The signal to connect to.
+   * @SINCE_1_0.0
+   * @return The signal to connect to
    */
   ButtonSignalType& StateChangedSignal();
 
 public: // Not intended for application developers
 
+  /// @cond internal
   /**
    * @brief Creates a handle using the Toolkit::Internal implementation.
    *
-   * @param[in]  implementation  The Control implementation.
+   * @SINCE_1_0.0
+   * @param[in] implementation The Control implementation
    */
   DALI_INTERNAL Button( Internal::Button& implementation );
 
   /**
    * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
    *
-   * @param[in]  internal  A pointer to the internal CustomActor.
+   * @SINCE_1_0.0
+   * @param[in] internal A pointer to the internal CustomActor
    */
   DALI_INTERNAL Button( Dali::Internal::CustomActor* internal );
+  /// @endcond
 };
 
+/**
+ * @}
+ */
 } // namespace Toolkit
 
 } // namespace Dali
 
-#endif // __DALI_TOOLKIT_BUTTON_H__
+#endif // DALI_TOOLKIT_BUTTON_H