Render control background without creating extra actor
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / public-api / controls / control.h
index 6e88177..51f6bd1 100644 (file)
@@ -2,7 +2,7 @@
 #define __DALI_TOOLKIT_CONTROL_H__
 
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2015 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.
@@ -40,6 +40,10 @@ namespace Internal
 {
 class Control;
 }
+/**
+ * @addtogroup dali_toolkit_controls
+ * @{
+ */
 
 /**
  * @brief Control is the base class for all controls.
@@ -48,18 +52,20 @@ class Control;
  * @see Internal::Control
  *
  * Signals
- * | %Signal Name      | Method                                              |
- * |-------------------|-----------------------------------------------------|
- * | key-event         | @ref KeyEventSignal()                               |
- * | tapped            | @ref GetTapGestureDetector().DetectedSignal()       |
- * | panned            | @ref GetPanGestureDetector().DetectedSignal()       |
- * | pinched           | @ref GetPinchGestureDetector().DetectedSignal()     |
- * | long-pressed      | @ref GetLongPressGestureDetector().DetectedSignal() |
+ * | %Signal Name           | Method                                              |
+ * |------------------------|-----------------------------------------------------|
+ * | key-event              | @ref KeyEventSignal()                               |
+ * | key-input-focus-gained | @ref KeyInputFocusGainedSignal()                    |
+ * | key-input-focus-lost   | @ref KeyInputFocusLostSignal()                      |
+ * | tapped                 | @ref GetTapGestureDetector().DetectedSignal()       |
+ * | panned                 | @ref GetPanGestureDetector().DetectedSignal()       |
+ * | pinched                | @ref GetPinchGestureDetector().DetectedSignal()     |
+ * | long-pressed           | @ref GetLongPressGestureDetector().DetectedSignal() |
  *
  * Actions
- * | %Action Name      | %Control method called                              |
- * |-------------------|-----------------------------------------------------|
- * | control-activated | %OnActivated()                                      |
+ * | %Action Name            | %Control method called                             |
+ * |-------------------------|----------------------------------------------------|
+ * | accessibility-activated | %OnAccessibilityActivated()                        |
  */
 class DALI_IMPORT_API Control : public CustomActor
 {
@@ -83,47 +89,23 @@ public:
     enum
     {
       STYLE_NAME = PROPERTY_START_INDEX,       ///< name "style-name",       @see SetStyleName,       type std::string
-      BACKGROUND_COLOR,                        ///< name "background-color", @see SetBackgroundColor, type Vector4
-      BACKGROUND,                              ///< name "background",       @see SetBackground,      type Map
-      WIDTH_POLICY,                            ///< name "width-policy",     @see SetSizePolicy,      type std::string
-      HEIGHT_POLICY,                           ///< name "height-policy",    @see SetSizePolicy,      type std::string
-      MINIMUM_SIZE,                            ///< name "minimum-size",     @see SetMinimumSize,     type Vector3
-      MAXIMUM_SIZE,                            ///< name "maximum-size",     @see SetMaximumSize,     type Vector3
+      BACKGROUND,                              ///< name "background",       @since DALi 1.1.4,       type Map
       KEY_INPUT_FOCUS,                         ///< name "key-input-focus",  @see SetKeyInputFocus,   type bool
     };
   };
 
   /**
-   * @brief Describes how a control could be resized.
-   */
-  enum SizePolicy
-  {
-    Fixed,    ///< Size can't grow or shrink.
-    Minimum,  ///< Size can grow but shrink up to a minimum level.
-    Maximum,  ///< Size can shrink but grow up to a maximum value.
-    Range,    ///< Size can grow or shrink between a minimum and a maximum values.
-    Flexible, ///< Size can grow or shrink with no limits.
-  };
-
-  /**
-   * @brief Describes what a control should do when a contained actor/control exceeds the boundary of the control.
-   */
-  enum ExceedPolicy
-  {
-    Crop,   ///< Control's contents will be cropped.
-    Shrink, ///< Control's contents will be shrunk.
-    Scroll  ///< Control's contents will be added to a scroll.
-  };
-
-  /**
    * @brief Describes the direction to move the keyboard focus towards.
    */
-  enum KeyboardFocusNavigationDirection
+  struct KeyboardFocus
   {
-    Left,   ///< Move keyboard focus towards the left direction
-    Right,  ///< Move keyboard focus towards the right direction
-    Up,     ///< Move keyboard focus towards the up direction
-    Down    ///< Move keyboard focus towards the down direction
+    enum Direction
+    {
+      LEFT,   ///< Move keyboard focus towards the left direction
+      RIGHT,  ///< Move keyboard focus towards the right direction
+      UP,     ///< Move keyboard focus towards the up direction
+      DOWN    ///< Move keyboard focus towards the down direction
+    };
   };
 
   // Typedefs
@@ -131,6 +113,9 @@ public:
   /// @brief Key Event signal type;
   typedef Signal<bool ( Control, const KeyEvent& ) > KeyEventSignalType;
 
+  /// @brief Key InputFocusType signal type;
+  typedef Signal<void ( Control ) > KeyInputFocusSignalType;
+
 public: // Creation & Destruction
 
   /**
@@ -187,93 +172,6 @@ public:
    */
   static Control DownCast( BaseHandle handle );
 
-  /**
-   * @brief Retrieve the Control implementation.
-   *
-   * @return The implementation.
-   */
-  Internal::Control& GetImplementation();
-
-  /**
-   * @brief Retrieve the Control implementation.
-   *
-   * @return The implementation.
-   */
-  const Internal::Control& GetImplementation() const;
-
-  // Size Negotiation
-
-  /**
-   * @brief Sets the size policies for the width and height dimensions.
-   *
-   * @param[in] widthPolicy Size policy for the width dimension.
-   * @param[in] heightPolicy Size policy for the height dimension.
-   */
-  void SetSizePolicy( SizePolicy widthPolicy, SizePolicy heightPolicy );
-
-  /**
-   * @brief Retrieves the size policies for the width and height dimensions.
-   *
-   * @param[out] widthPolicy Width's size policy.
-   * @param[out] heightPolicy Height's size policy.
-   */
-  void GetSizePolicy( SizePolicy& widthPolicy, SizePolicy& heightPolicy ) const;
-
-  /**
-   * @brief Sets the minimum size for the control.
-   *
-   * @param[in] size The minimum size.
-   */
-  void SetMinimumSize( const Vector3& size );
-
-  /**
-   * @brief Retrieves the minimum size.
-   *
-   * @return The minimum size.
-   */
-  const Vector3& GetMinimumSize() const;
-
-  /**
-   * @brief Sets the maximum size.
-   *
-   * @param[in] size The maximum size.
-   */
-  void SetMaximumSize( const Vector3& size );
-
-  /**
-   * @brief Retrieves the maximum size.
-   *
-   * @return The maximum size.
-   */
-  const Vector3& GetMaximumSize() const;
-
-  /**
-   * @brief Works out the natural size.
-   *
-   * Natural size is the control's size with any restriction.
-   *
-   * @return The natural size.
-   */
-  Vector3 GetNaturalSize();
-
-  /**
-   * @brief Works out the control's height for a given width.
-   *
-   * @param[in] width The control's width.
-   *
-   * @return The control's height for the given width.
-   */
-  float GetHeightForWidth( float width );
-
-  /**
-   * @brief Works out the control's width for a given height.
-   *
-   * @param[in] height The control's height.
-   *
-   * @return The control's width for the given height.
-   */
-  float GetWidthForHeight( float height );
-
   // Key Input
 
   /**
@@ -342,7 +240,7 @@ public:
    */
   LongPressGestureDetector GetLongPressGestureDetector() const;
 
-  // Background
+  // Styling
 
   /**
    * @brief Sets the name of the style to be applied to the control.
@@ -372,6 +270,8 @@ public:
   /**
    * @brief Retrieves the background color of the control.
    *
+   * @deprecated DALi 1.1.3 API removed.
+   *
    * @return The background color of the control.
    */
   Vector4 GetBackgroundColor() const;
@@ -379,24 +279,15 @@ public:
   /**
    * @brief Sets an image as the background of the control.
    *
-   * The color of this image is blended with the background color @see SetBackgroundColor
-   *
    * @param[in] image The image to set as the background.
    */
-  void SetBackground( Image image );
+  void SetBackgroundImage( Image image );
 
   /**
    * @brief Clears the background.
    */
   void ClearBackground();
 
-  /**
-   * @brief Retrieves the actor used as the background for this control.
-   *
-   * @return The actor that used as the background for this control.
-   */
-  Actor GetBackgroundActor() const;
-
   // Signals
 
   /**
@@ -406,13 +297,43 @@ public:
    * @code
    *   bool YourCallbackName(Control control, const KeyEvent& event);
    * @endcode
-   * The return value of True, indicates that the touch event should be consumed.
-   * Otherwise the signal will be emitted on the next sensitive parent of the actor.
+   * The return value of True, indicates that the event should be consumed.
+   * Otherwise the signal will be emitted on the next parent of the actor.
    * @pre The Control has been initialized.
    * @return The signal to connect to.
    */
   KeyEventSignalType& KeyEventSignal();
 
+  /**
+   * @brief This signal is emitted when the control gets Key Input Focus
+   *
+   * A callback of the following type may be connected:
+   * @code
+   *   bool YourCallbackName( Control control );
+   * @endcode
+   * The return value of True, indicates that the event should be consumed.
+   * Otherwise the signal will be emitted on the next parent of the actor.
+   * @pre The Control has been initialized.
+   * @return The signal to connect to.
+   */
+  KeyInputFocusSignalType& KeyInputFocusGainedSignal();
+
+  /**
+   * @brief This signal is emitted when the control loses Key Input Focus
+   * which could be due to it being gained by another Control or Actor or just cleared from
+   * this control as no longer required.
+   *
+   * A callback of the following type may be connected:
+   * @code
+   *   bool YourCallbackName( Control control );
+   * @endcode
+   * The return value of True, indicates that the event should be consumed.
+   * Otherwise the signal will be emitted on the next parent of the actor.
+   * @pre The Control has been initialized.
+   * @return The signal to connect to.
+   */
+  KeyInputFocusSignalType& KeyInputFocusLostSignal();
+
 public: // Intended for control developers
 
   /**
@@ -485,6 +406,9 @@ public: // Templates for Deriving Classes
 
 };
 
+/**
+ * @}
+ */
 } // namespace Toolkit
 
 } // namespace Dali