Text selection refactoring
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / text-controller-impl.h
index 5dd231a..bb03be4 100755 (executable)
@@ -21,6 +21,7 @@
 // EXTERNAL INCLUDES
 #include <dali/devel-api/adaptor-framework/clipboard.h>
 #include <dali/devel-api/text-abstraction/font-client.h>
+#include <dali/public-api/rendering/shader.h>
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/internal/text/input-style.h>
@@ -47,6 +48,8 @@ const float DEFAULT_TEXTFIT_STEP = 1.f;
 struct CursorInfo;
 struct FontDefaults;
 
+class SelectableControlInterface;
+
 struct Event
 {
   // Used to queue input events until DoRelayout()
@@ -60,7 +63,8 @@ struct Event
     LEFT_SELECTION_HANDLE_EVENT,
     RIGHT_SELECTION_HANDLE_EVENT,
     SELECT,
-    SELECT_ALL
+    SELECT_ALL,
+    SELECT_NONE,
   };
 
   union Param
@@ -306,9 +310,11 @@ struct OutlineDefaults
 struct Controller::Impl
 {
   Impl( ControlInterface* controlInterface,
-        EditableControlInterface* editableControlInterface )
+        EditableControlInterface* editableControlInterface,
+        SelectableControlInterface* selectableControlInterface )
   : mControlInterface( controlInterface ),
     mEditableControlInterface( editableControlInterface ),
+    mSelectableControlInterface( selectableControlInterface ),
     mModel(),
     mFontDefaults( NULL ),
     mUnderlineDefaults( NULL ),
@@ -618,6 +624,18 @@ struct Controller::Impl
 
   void OnSelectAllEvent();
 
+  void OnSelectNoneEvent();
+
+  /**
+   * @copydoc Text::SelectableControlInterface::SetTextSelectionRange()
+   */
+  void SetTextSelectionRange(const uint32_t *pStart, const uint32_t *pEndf);
+
+  /**
+   * @copydoc Text::SelectableControlInterface::GetTextSelectionRange()
+   */
+  Uint32Pair GetTextSelectionRange() const;
+
   /**
    * @brief Retrieves the selected text. It removes the text if the @p deleteAfterRetrieval parameter is @e true.
    *
@@ -724,6 +742,13 @@ struct Controller::Impl
    */
   void ScrollTextToMatchCursor( const CursorInfo& cursorInfo );
 
+  /**
+   * @brief Create an actor that renders the text background color
+   *
+   * @return the created actor or an empty handle if no background color needs to be rendered.
+   */
+  Actor CreateBackgroundActor();
+
 public:
 
   /**
@@ -746,6 +771,7 @@ public:
 
   ControlInterface* mControlInterface;     ///< Reference to the text controller.
   EditableControlInterface* mEditableControlInterface; ///< Reference to the editable text controller.
+  SelectableControlInterface* mSelectableControlInterface; ///< Reference to the selectable text controller.
   ModelPtr mModel;                         ///< Pointer to the text's model.
   FontDefaults* mFontDefaults;             ///< Avoid allocating this when the user does not specify a font.
   UnderlineDefaults* mUnderlineDefaults;   ///< Avoid allocating this when the user does not specify underline parameters.
@@ -780,6 +806,8 @@ public:
   bool mShouldClearFocusOnEscape:1;        ///< Whether text control should clear key input focus
   LayoutDirection::Type mLayoutDirection;  ///< Current system language direction
 
+  Shader mShaderBackground;                ///< The shader for text background.
+
   float mTextFitMinSize;                   ///< Minimum Font Size for text fit. Default 10
   float mTextFitMaxSize;                   ///< Maximum Font Size for text fit. Default 100
   float mTextFitStepSize;                  ///< Step Size for font intervalse. Default 1