Merge branch 'tizen' into new_text
[platform/core/uifw/dali-toolkit.git] / base / dali-toolkit / internal / controls / text-input / text-input-popup-impl.h
index 41b9bb6..8c951ad 100644 (file)
  *
  */
 
-// INTERNAL INCLUDES
-#include <dali/dali.h>
+// EXTERNAL INCLUDES
+#include <dali/public-api/actors/image-actor.h>
+#include <dali/public-api/actors/layer.h>
+#include <dali/public-api/animation/animation.h>
 
+// INTERNAL INCLUDES
 #include <dali-toolkit/public-api/controls/text-view/text-view.h>
 #include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view.h>
 
@@ -162,6 +165,14 @@ public:
   void CreateOrderedListOfOptions();
 
   /**
+   * Get the TextSize after constrained by the Popup margins.
+   * @param[in] textSize Natural size of text
+   * @return Vector2 constrained text size.
+   *
+   */
+  Vector2 GetConstrainedTextSize( const Vector2& textSize );
+
+  /**
    * Adds a popup option.
    * @note Creates popup frame if not already created.
    * @param[in] name The unique name for this option.
@@ -181,16 +192,9 @@ public:
   /**
    * Shows the popup
    * @param[in] animate (optional) whether to animate popup to show state over time (i.e. tween).
+   * @param[in] target Actor to parent popup.
    */
-  void Show(bool animate = true);
-
-  /**
-   * Sets Alternative offset property.
-   * The alternative offset property is how much to move in the horizontal and vertical
-   * axes when the popup goes out of the screen on the left/right sides or top/bottom sides.
-   * @param[in] offset Vector holding the left/right offset (x) and top/bottom offset (y)
-   */
-  void SetAlternativeOffset(Vector2 offset);
+  void Show( Actor target, bool animate = true );
 
   /**
    * Returns the current state of the popup.
@@ -315,16 +319,17 @@ public:
   void AddPopupOptions();
 
   /**
-   * Set Boundary that Popup should stay within
-   * @param[in] boundingRectangle coordinates of bounding box from Top Left
+   * Get Visible size of the Popup, excludes content that needs scrolling
+   * @return Vector3 size of Popup
    */
-  void SetPopupBoundary( const Rect<float>& boundingRectangle );
+  const Vector3& GetVisibileSize() const;
 
   /**
-   * Sets the positon of the Popup tail relative to TextInput
-   * @param position Position to set
+   * Sets the positon of the PopUp tail relative to TextInput
+   * @param[in] position Position to set
+   * @param[in] yAxisFlip If tail should be flipped in y axis
    */
-  void SetTailPosition( const Vector3& position );
+  void SetTailPosition( const Vector3& position, const bool yAxisFlip );
 
 private:
 
@@ -341,9 +346,15 @@ private:
                                                                           const std::string& name, const std::string& caption, Image iconImage, bool enabled );
 
   /**
-   * Adds Popup to the stage (ideally on a separate top-most layer and as an overlay)
+   * @brief Adds popup to the given parent
+   * @paran[in] parent target to add Popup to
+   */
+  void AddToParent( Actor parent );
+
+  /**
+   * @brief Removes Popup from Parent
    */
-  void AddToStage();
+  void RemoveFromParent();
 
   /**
    * Applies constraint to keep Popup in view within the desired area.
@@ -356,6 +367,12 @@ private:
   void ApplyTailConstraint();
 
   /**
+   * Create Layer to be used with stencil to allow scrolling of buttons which do not fit in visible popup
+   * @param[in] size of the layer.
+   */
+  void CreateLayer( const Vector2& size );
+
+  /**
    * Create a stencil to clip the scroll view content
    * @param[in] size of the stencil.
    */
@@ -382,12 +399,7 @@ private:
    * Set the scroll view size and ruler.
    * @param[in] visibleSize size of the visible scroll view
    */
-  void UpdateScrollViewProperty( const Vector2& visibleSize );
-
-  /**
-   * Removes Popup from the stage.
-   */
-  void RemoveFromStage();
+  void UpdateScrollViewRulerAndSize( const Vector2& visibleSize );
 
   /**
    * Called when a button is pressed in the Popup
@@ -412,9 +424,8 @@ private:
 private:
 
   State mState;                                       ///< Popup State.
-  Layer mRoot;                                       ///< The actor which all popup content is added to (i.e. panel and buttons)
-  Property::Index mAlternativeOffsetProperty;         ///< Property [Vector3] how much to offset the popup if it goes out of the screen
-  Property::Index mRequestionPositionProperty;        ///< Prperty [Vector3] Requested position to place popup
+  Layer mRoot;                                        ///< The actor which all popup content is added to (i.e. panel and buttons)
+  Actor mButtons;                                     ///< Actor which holds all the buttons, sensitivity can be set on all buttons via this actor
   ImageActor mBackground;                             ///< The background popup panel
   ImageActor mBackgroundEffect;                       ///< The background effect
   ImageActor mBackgroundLine;                         ///< The background line
@@ -422,13 +433,14 @@ private:
   ImageActor mTailEffect;                             ///< the tail effect
   ImageActor mTailLine;                               ///< The border/outline around the tail
 
-  float mPopupTailXPosition;                          ///< X position of Popup tail.
+  Vector3 mVisiblePopUpSize;                          ///< Visible Size of Popup excluding content that needs scrolling.
+  float mPopupTailXPosition;                          ///< X position of PopUp tail.
 
   Vector2 mContentSize;                               ///< Size of Content (i.e. Buttons)
-  ActorContainer mButtonContainer;                    ///< List of buttons added to popup.
   ActorContainer mDividerContainer;                   ///< List of dividers added to popup.
   Animation mAnimation;                               ///< Popup Hide/Show animation.
 
+  Layer mLayer;                                       ///< Layer to be used with Stencil
   Actor mStencil;                                     ///< Stencil to clip scrollview
   Toolkit::ScrollView mScrollView;                    ///< Scrollview to house the popup
 
@@ -442,8 +454,6 @@ private:
   Vector4 mTextColor;                    // Color of the popup text.
   Vector4 mTextPressedColor;             // Color of the popup text when pressed.
 
-  Rect<float> mBoundingRect; // Boundary that Popup must stay within.
-
   // Priority of Options/Buttons in the Cut and Paste pop-up, higher priority buttons are displayed first, left to right.
   std::size_t mSelectOptionPriority;  // Position of Select Button
   std::size_t mSelectAllOptionPriority; // Position of Select All button