Split text-controller files in text-controller and text-controller-impl.
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / text-controller.h
index 5623a11..d37efab 100644 (file)
  *
  */
 
-// INTERNAL INCLUDES
-#include <dali-toolkit/internal/text/decorator/text-decorator.h>
-#include <dali-toolkit/internal/text/text-control-interface.h>
-#include <dali-toolkit/internal/text/text-view.h>
-
 // EXTERNAL INCLUDES
+#include <string>
+#include <dali/public-api/common/dali-vector.h>
 #include <dali/public-api/common/intrusive-ptr.h>
+#include <dali/public-api/events/gesture.h>
 #include <dali/public-api/events/key-event.h>
 #include <dali/public-api/math/vector3.h>
 #include <dali/public-api/math/vector2.h>
 #include <dali/public-api/object/ref-object.h>
-#include <string>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/text/decorator/text-decorator.h>
+#include <dali-toolkit/internal/text/font-run.h>
+#include <dali-toolkit/internal/text/text-control-interface.h>
+#include <dali-toolkit/internal/text/text-view.h>
 
 namespace Dali
 {
@@ -70,14 +73,13 @@ private:
     VALIDATE_FONTS     = 0x0004,
     GET_LINE_BREAKS    = 0x0008,
     GET_WORD_BREAKS    = 0x0010,
-    SHAPE_TEXT         = 0x0020,
-    GET_GLYPH_METRICS  = 0x0040,
-    LAYOUT             = 0x0080,
-    UPDATE_ACTUAL_SIZE = 0x0100,
-    UPDATE_POSITIONS   = 0x0200,
+    BIDI_INFO          = 0x0020,
+    SHAPE_TEXT         = 0x0040,
+    GET_GLYPH_METRICS  = 0x0080,
+    LAYOUT             = 0x0100,
+    UPDATE_ACTUAL_SIZE = 0x0200,
     REORDER            = 0x0400,
-    ALIGNMENT          = 0x0800,
-    RENDER             = 0x1000,
+    ALIGN              = 0x0800,
     ALL_OPERATIONS     = 0xFFFF
   };
 
@@ -132,7 +134,7 @@ public:
    *
    * @return The default font family.
    */
-   const std::string& GetDefaultFontFamily() const;
+  const std::string& GetDefaultFontFamily() const;
 
   /**
    * @brief Set the default font style.
@@ -146,7 +148,7 @@ public:
    *
    * @return The default font style.
    */
-   const std::string& GetDefaultFontStyle() const;
+  const std::string& GetDefaultFontStyle() const;
 
   /**
    * @brief Set the default point size.
@@ -160,7 +162,99 @@ public:
    *
    * @return The default point size.
    */
-   float GetDefaultPointSize() const;
+  float GetDefaultPointSize() const;
+
+  /**
+   * @brief Retrieve the default fonts.
+   *
+   * @param[out] fonts The default font family, style and point sizes.
+   * @param[in] numberOfCharacters The number of characters in the logical model.
+   */
+  void GetDefaultFonts( Dali::Vector<FontRun>& fonts, Length numberOfCharacters ) const;
+
+  /**
+   * @brief Set the text color
+   *
+   * @param textColor The text color
+   */
+  void SetTextColor( const Vector4& textColor );
+
+  /**
+   * @brief Retrieve the text color
+   *
+   * @return The text color
+   */
+  const Vector4& GetTextColor() const;
+
+  /**
+   * @brief Set the shadow offset.
+   *
+   * @param[in] shadowOffset The shadow offset, 0,0 indicates no shadow.
+   */
+  void SetShadowOffset( const Vector2& shadowOffset );
+
+  /**
+   * @brief Retrieve the shadow offset.
+   *
+   * @return The shadow offset.
+   */
+  const Vector2& GetShadowOffset() const;
+
+  /**
+   * @brief Set the shadow color.
+   *
+   * @param[in] shadowColor The shadow color.
+   */
+  void SetShadowColor( const Vector4& shadowColor );
+
+  /**
+   * @brief Retrieve the shadow color.
+   *
+   * @return The shadow color.
+   */
+  const Vector4& GetShadowColor() const;
+
+  /**
+   * @brief Set the underline color.
+   *
+   * @param[in] color color of underline.
+   */
+  void SetUnderlineColor( const Vector4& color );
+
+  /**
+   * @brief Retrieve the underline color.
+   *
+   * @return The underline color.
+   */
+  const Vector4& GetUnderlineColor() const;
+
+  /**
+   * @brief Set the underline enabled flag.
+   *
+   * @param[in] enabled The underline enabled flag.
+   */
+  void SetUnderlineEnabled( bool enabled );
+
+  /**
+   * @brief Returns whether the text is underlined or not.
+   *
+   * @return The underline state.
+   */
+  bool IsUnderlineEnabled() const;
+
+  /**
+   * @brief Set the override used for underline height, 0 indicates height will be supplied by font metrics
+   *
+   * @param[in] height The height in pixels of the underline
+   */
+  void SetUnderlineHeight( float height );
+
+  /**
+   * @brief Retrieves the override height of an underline, 0 indicates height is supplied by font metrics
+   *
+   * @return The height of the underline, or 0 if height is not overrided.
+   */
+  float GetUnderlineHeight() const;
 
   /**
    * @brief Called to enable text input.
@@ -171,13 +265,83 @@ public:
   void EnableTextInput( DecoratorPtr decorator );
 
   /**
+   * @brief Called to enable/disable cursor blink.
+   *
+   * @note Only editable controls should calls this.
+   * @param[in] enabled Whether the cursor should blink or not.
+   */
+  void SetEnableCursorBlink( bool enable );
+
+  /**
+   * @brief Query whether cursor blink is enabled.
+   *
+   * @return Whether the cursor should blink or not.
+   */
+  bool GetEnableCursorBlink() const;
+
+  /**
+   * @brief Query the current scroll position; the UI control is responsible for moving actors to this position.
+   *
+   * @return The scroll position.
+   */
+  const Vector2& GetScrollPosition() const;
+
+  /**
+   * @brief Query the alignment offset.
+   *
+   * @return The alignmnet offset.
+   */
+  const Vector2& GetAlignmentOffset() const;
+
+  /**
+   * @copydoc Control::GetNaturalSize()
+   */
+  Vector3 GetNaturalSize();
+
+  /**
+   * @copydoc Control::GetHeightForWidth()
+   */
+  float GetHeightForWidth( float width );
+
+  /**
    * @brief Triggers a relayout which updates View (if necessary).
    *
    * @note UI Controls are expected to minimize calls to this method e.g. call once after size negotiation.
    * @param[in] size A the size of a bounding box to layout text within.
    * @return True if the text model or decorations were updated.
    */
-  bool Relayout( const Vector2& size );
+  bool Relayout( const Size& size );
+
+  /**
+   * @brief Process queued events which modify the model.
+   */
+  void ProcessModifyEvents();
+
+  /**
+   * @brief Used to process an event queued from SetText()
+   *
+   * @param[in] newText The new text to store in the logical model.
+   */
+  void ReplaceTextEvent( const std::string& newText );
+
+  /**
+   * @brief Used to process an event queued from key events etc.
+   *
+   * @param[in] text The text to insert into the logical model.
+   */
+  void InsertTextEvent( const std::string& text );
+
+  /**
+   * @brief Used to process an event queued from backspace key etc.
+   */
+  void DeleteTextEvent();
+
+  /**
+   * @brief Update the model following text replace/insert etc.
+   *
+   * @param[in] operationsRequired The layout operations which need to be done.
+   */
+  void UpdateModel( OperationsMask operationsRequired );
 
   /**
    * @brief Lays-out the text.
@@ -188,19 +352,16 @@ public:
    * @param[in] operations The layout operations which need to be done.
    * @param[out] layoutSize The size of the laid-out text.
    */
-  bool DoRelayout( const Vector2& size,
+  bool DoRelayout( const Size& size,
                    OperationsMask operations,
                    Size& layoutSize );
 
   /**
-   * @copydoc Control::GetNaturalSize()
-   */
-  Vector3 GetNaturalSize();
-
-  /**
-   * @copydoc Control::GetHeightForWidth()
+   * @brief Calulates the alignment of the whole text inside the bounding box.
+   *
+   * @param[in] size The size of the bounding box.
    */
-  float GetHeightForWidth( float width );
+  void CalculateTextAlignment( const Size& size );
 
   /**
    * @brief Return the layout engine.
@@ -216,6 +377,8 @@ public:
    */
   View& GetView();
 
+  // Text-input Event Queuing
+
   /**
    * @brief Caller by editable UI controls when keyboard focus is gained.
    */
@@ -242,6 +405,14 @@ public:
   void TapEvent( unsigned int tapCount, float x, float y );
 
   /**
+   * @brief Caller by editable UI controls when a pan gesture occurs.
+   *
+   * @param[in] state The state of the gesture.
+   * @param[in] displacement This distance panned since the last pan gesture.
+   */
+  void PanEvent( Gesture::State state, const Vector2& displacement );
+
+  /**
    * @copydoc Dali::Toolkit::Text::Decorator::Observer::GrabHandleEvent()
    */
   virtual void GrabHandleEvent( GrabHandleState state, float x, float y );
@@ -256,11 +427,6 @@ protected:
 private:
 
   /**
-   * @brief Request a relayout using the ControlInterface.
-   */
-  void RequestRelayout();
-
-  /**
    * @brief Private constructor.
    */
   Controller( ControlInterface& controlInterface );
@@ -275,12 +441,6 @@ private:
 
   struct Impl;
   Impl* mImpl;
-
-  // Avoid allocating this when the user does not specify a font
-  struct FontDefaults;
-
-  // Avoid allocating this for non-editable controls
-  struct TextInput;
 };
 
 } // namespace Text