Apply new clipboard to text component
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / controller / text-controller.h
index 511c550..4932cec 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_TOOLKIT_TEXT_CONTROLLER_H
 
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
@@ -19,6 +19,8 @@
  */
 
 // EXTERNAL INCLUDES
+#include <dali-toolkit/devel-api/text/spanned.h>
+#include <dali/devel-api/adaptor-framework/clipboard.h>
 #include <dali/devel-api/adaptor-framework/input-method-context.h>
 #include <dali/public-api/events/gesture.h>
 
@@ -68,7 +70,7 @@ typedef IntrusivePtr<Controller> ControllerPtr;
  *
  * The text selection popup button callbacks are as well handled via the TextSelectionPopupCallbackInterface interface.
  */
-class Controller : public RefObject, public Decorator::ControllerInterface, public TextSelectionPopupCallbackInterface, public HiddenText::Observer
+class Controller : public RefObject, public Decorator::ControllerInterface, public TextSelectionPopupCallbackInterface, public HiddenText::Observer, public ConnectionTracker
 {
 public: // Enumerated types.
   /**
@@ -513,6 +515,13 @@ public: // Configure the text controller.
   bool IsTextFitChanged() const;
 
   /**
+   * @brief Sets line size valid for text fit.
+   *
+   * @param[in] lineSize line size value
+   */
+  void SetTextFitLineSize(float lineSize);
+
+  /**
    * @brief Sets disabled color opacity.
    *
    * @param[in] opacity The color opacity value in disabled state.
@@ -753,6 +762,22 @@ public: // Update.
   void GetText(std::string& text) const;
 
   /**
+   * @brief Retrieves number of characters previously set.
+   *
+   * @return A length of string of UTF-32 characters.
+   */
+  Length GetNumberOfCharacters() const;
+
+  /**
+ * @brief Set the @p spannedText
+ * the spanned text contains content (text) and  format (spans with ranges)
+ * the text is copied into text-controller and the spans are applied on ranges
+ *
+ * @param[in] spannedText the text with spans.
+ */
+  void SetSpannedText(const Text::Spanned& spannedText);
+
+  /**
    * @brief Replaces any placeholder text previously set.
    *
    * @param[in] type Different placeholder-text can be shown when the control is active/inactive.
@@ -819,7 +844,7 @@ public: // Default style & Input style
    *
    * @return The default font family.
    */
-  const std::string& GetDefaultFontFamily() const;
+  std::string GetDefaultFontFamily() const;
 
   /**
    * @brief Sets the placeholder text font family.
@@ -832,7 +857,7 @@ public: // Default style & Input style
    *
    * @return The placeholder text font family
    */
-  const std::string& GetPlaceholderFontFamily() const;
+  std::string GetPlaceholderFontFamily() const;
 
   /**
    * @brief Sets the default font weight.
@@ -1248,7 +1273,7 @@ public: // Default style & Input style
    *
    * @return The emboss's properties string.
    */
-  const std::string& GetDefaultEmbossProperties() const;
+  std::string GetDefaultEmbossProperties() const;
 
   /**
    * @brief Sets the outline's properties string.
@@ -1264,7 +1289,7 @@ public: // Default style & Input style
    *
    * @return The outline's properties string.
    */
-  const std::string& GetDefaultOutlineProperties() const;
+  std::string GetDefaultOutlineProperties() const;
 
   /**
    * @brief Sets the default line spacing.
@@ -1340,7 +1365,7 @@ public: // Default style & Input style
    *
    * @return The input text's font family name.
    */
-  const std::string& GetInputFontFamily() const;
+  std::string GetInputFontFamily() const;
 
   /**
    * @brief Sets the input font's weight.
@@ -1441,7 +1466,7 @@ public: // Default style & Input style
    *
    * @return The shadow's properties string.
    */
-  const std::string& GetInputShadowProperties() const;
+  std::string GetInputShadowProperties() const;
 
   /**
    * @brief Sets the input underline's properties string.
@@ -1457,7 +1482,7 @@ public: // Default style & Input style
    *
    * @return The underline's properties string.
    */
-  const std::string& GetInputUnderlineProperties() const;
+  std::string GetInputUnderlineProperties() const;
 
   /**
    * @brief Sets the input emboss's properties string.
@@ -1473,7 +1498,7 @@ public: // Default style & Input style
    *
    * @return The emboss's properties string.
    */
-  const std::string& GetInputEmbossProperties() const;
+  std::string GetInputEmbossProperties() const;
 
   /**
    * @brief Sets input the outline's properties string.
@@ -1489,7 +1514,7 @@ public: // Default style & Input style
    *
    * @return The outline's properties string.
    */
-  const std::string& GetInputOutlineProperties() const;
+  std::string GetInputOutlineProperties() const;
 
   /**
    * @brief Sets the input strikethrough's properties string.
@@ -1505,7 +1530,7 @@ public: // Default style & Input style
    *
    * @return The strikethrough's properties string.
    */
-  const std::string& GetInputStrikethroughProperties() const;
+  std::string GetInputStrikethroughProperties() const;
 
   /**
    * @brief Set the control's interface.
@@ -1588,7 +1613,7 @@ public: // Queries & retrieves.
    *
    * @return A pointer to the text's model.
    */
-  const ModelInterface* const GetTextModel() const;
+  const ModelInterface* GetTextModel() const;
 
   /**
    * @brief Used to get scrolled distance by user input
@@ -1751,6 +1776,16 @@ public: // Queries & retrieves.
   Rect<float> GetCharacterBoundingRectangle(const uint32_t charIndex);
 
   /**
+   * @brief Get the character index.
+   * If the text is not yet rendered or the text is empty, -1 is returned.
+   *
+   * @param[in] visualX visual x position.
+   * @param[in] visualY visual y position.
+   * @return character index.
+   */
+  int GetCharacterIndexAtPosition(float visualX, float visualY);
+
+  /**
    * @brief Gets the bounding box of a specific text range.
    *
    * @param[in] startIndex start index of the text requested to get bounding box to.
@@ -1966,8 +2001,14 @@ public: // Text-input Event Queuing.
 
   /**
    * @brief Event from Clipboard notifying an Item has been selected for pasting
+   *
+   * @param[in] id The id of the data request.
+   * @param[in] mimeType The mime type of data received.
+   * @param[in] data The data received.
+   * @note
+   * This event is executed by receiving the Clipboard's DataReceivedSignal.
    */
-  void PasteClipboardItemEvent();
+  void PasteClipboardItemEvent(uint32_t id, const char* mimeType, const char* data);
 
   /**
    * @brief Return true when text control should clear key input focus when escape key is pressed.
@@ -2084,8 +2125,9 @@ private:
   struct PlaceholderHandler;
   struct Relayouter;
   struct TextUpdater;
+  struct SpannableHandler;
 
-  Impl* mImpl;
+  std::unique_ptr<Impl> mImpl{nullptr};
 };
 
 } // namespace Dali::Toolkit::Text