[dali_2.3.23] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / controller / text-controller-impl.h
index 1844cb0..cc6a818 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_TOOLKIT_TEXT_CONTROLLER_IMPL_H
 
 /*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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,7 +19,6 @@
  */
 
 // EXTERNAL INCLUDES
-#include <dali/devel-api/adaptor-framework/text-clipboard.h>
 #include <dali/devel-api/text-abstraction/font-client.h>
 #include <dali/public-api/rendering/shader.h>
 
@@ -27,6 +26,7 @@
 #include <dali-toolkit/devel-api/styling/style-manager-devel.h>
 #include <dali-toolkit/internal/text/controller/text-controller.h>
 #include <dali-toolkit/internal/text/input-style.h>
+#include <dali-toolkit/internal/text/multi-language-support.h>
 #include <dali-toolkit/internal/text/text-model.h>
 #include <dali-toolkit/internal/text/text-view.h>
 #include <dali-toolkit/public-api/styling/style-manager.h>
@@ -331,17 +331,22 @@ struct Controller::Impl
     mEmbossDefaults(NULL),
     mOutlineDefaults(NULL),
     mEventData(NULL),
+    mIdleCallback(NULL),
     mFontClient(),
     mClipboard(),
     mView(),
     mMetrics(),
     mModifyEvents(),
     mTextColor(Color::BLACK),
+    mAnchorColor(Color::MEDIUM_BLUE),
+    mAnchorClickedColor(Color::DARK_MAGENTA),
     mTextUpdateInfo(),
     mOperationsPending(NO_OPERATION),
     mMaximumNumberOfCharacters(50u),
     mHiddenInput(NULL),
     mInputFilter(nullptr),
+    mTextFitContentSize(),
+    mTextFitArray(),
     mRecalculateNaturalSize(true),
     mMarkupProcessorEnabled(false),
     mClipboardHideEnabled(true),
@@ -356,6 +361,7 @@ struct Controller::Impl
     mStrikethroughSetByString(false),
     mShouldClearFocusOnEscape(true),
     mLayoutDirection(LayoutDirection::LEFT_TO_RIGHT),
+    mCurrentLineSize(0.f),
     mTextFitMinSize(DEFAULT_TEXTFIT_MIN),
     mTextFitMaxSize(DEFAULT_TEXTFIT_MAX),
     mTextFitStepSize(DEFAULT_TEXTFIT_STEP),
@@ -365,15 +371,17 @@ struct Controller::Impl
     mFontSizeScaleEnabled(true),
     mTextFitEnabled(false),
     mTextFitChanged(false),
+    mTextFitArrayEnabled(false),
     mIsLayoutDirectionChanged(false),
-    mIsUserInteractionEnabled(true)
+    mIsUserInteractionEnabled(true),
+    mProcessorRegistered(false)
   {
     mModel = Model::New();
 
     mFontClient = TextAbstraction::FontClient::Get();
-    if(mEditableControlInterface != nullptr && TextClipboard::IsAvailable())
+    if(mEditableControlInterface != nullptr && Clipboard::IsAvailable())
     {
-      mClipboard = TextClipboard::Get();
+      mClipboard = Clipboard::Get();
     }
 
     mView.SetVisualModel(mModel->mVisualModel);
@@ -390,8 +398,7 @@ struct Controller::Impl
     Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
     if(styleManager)
     {
-      const Property::Map& config                  = Toolkit::DevelStyleManager::GetConfigurations(styleManager);
-      const auto           clearFocusOnEscapeValue = config.Find("clearFocusOnEscape", Property::Type::BOOLEAN);
+      const auto clearFocusOnEscapeValue = Toolkit::DevelStyleManager::GetConfigurations(styleManager).Find("clearFocusOnEscape", Property::Type::BOOLEAN);
 
       // Default is true. If config don't have "clearFocusOnEscape" property, make it true.
       mShouldClearFocusOnEscape = (!clearFocusOnEscapeValue || clearFocusOnEscapeValue->Get<bool>());
@@ -436,6 +443,16 @@ struct Controller::Impl
   }
 
   /**
+   * @copydoc Text::Controller::ResetFontAndStyleData()
+   */
+  void ResetFontAndStyleData()
+  {
+    ClearFontData();
+    ClearStyleData();
+    RequestRelayout();
+  }
+
+  /**
    * @brief Helper to move the cursor, grab handle etc.
    */
   bool ProcessInputEvents();
@@ -513,6 +530,31 @@ struct Controller::Impl
   }
 
   /**
+   * @copydoc Controller::SetAnchorColor()
+   */
+  void SetAnchorColor(const Vector4& color);
+
+  /**
+   * @copydoc Controller::GetAnchorColor()
+   */
+  const Vector4& GetAnchorColor() const;
+
+  /**
+   * @copydoc Controller::SetAnchorClickedColor()
+   */
+  void SetAnchorClickedColor(const Vector4& color);
+
+  /**
+   * @copydoc Controller::GetAnchorClickedColor()
+   */
+  const Vector4& GetAnchorClickedColor() const;
+
+  /**
+   * @brief Updates the color of anchors.
+   */
+  void UpdateAnchorColor();
+
+  /**
    * @brief Helper to notify InputMethodContext with surrounding text & cursor changes.
    */
   void NotifyInputMethodContext();
@@ -568,25 +610,27 @@ struct Controller::Impl
   {
     if(!mClipboard)
     {
-      mClipboard = TextClipboard::Get();
+      mClipboard = Clipboard::Get();
     }
 
     return mClipboard != nullptr ? true : false;
   }
 
-  bool IsClipboardEmpty()
-  {
-    bool result(TextClipboard::IsAvailable() && EnsureClipboardCreated() && mClipboard.NumberOfItems());
-    return !result; // If NumberOfItems greater than 0, return false
-  }
-
   bool IsClipboardVisible()
   {
-    bool result(TextClipboard::IsAvailable() && EnsureClipboardCreated() && mClipboard.IsVisible());
+    bool result(Clipboard::IsAvailable() && EnsureClipboardCreated() && mClipboard.IsVisible());
     return result;
   }
 
   /**
+   * @brief Whether the clipboard is empty or not.
+   * Checks the types that the text controller can paste and returns the result.
+   *
+   * @return Return whether or not the clipboard is empty.
+   */
+  bool IsClipboardEmpty();
+
+  /**
    * @copydoc Controller::GetLayoutDirection()
    */
   Dali::LayoutDirection::Type GetLayoutDirection(Dali::Actor& actor) const;
@@ -734,8 +778,6 @@ struct Controller::Impl
 
   void SendSelectionToClipboard(bool deleteAfterSending);
 
-  void RequestGetTextFromClipboard();
-
   void RepositionSelectionHandles();
   void RepositionSelectionHandles(float visualX, float visualY, Controller::NoTextTap::Action action);
 
@@ -1015,13 +1057,16 @@ public:
   EmbossDefaults*              mEmbossDefaults;             ///< Avoid allocating this when the user does not specify emboss parameters.
   OutlineDefaults*             mOutlineDefaults;            ///< Avoid allocating this when the user does not specify outline parameters.
   EventData*                   mEventData;                  ///< Avoid allocating everything for text input until EnableTextInput().
+  CallbackBase*                mIdleCallback;               ///< Callback what would be called at idler
   TextAbstraction::FontClient  mFontClient;                 ///< Handle to the font client.
-  TextClipboard                mClipboard;                  ///< Handle to the system clipboard
+  Clipboard                    mClipboard;                  ///< Handle to the system clipboard
   View                         mView;                       ///< The view interface to the rendering back-end.
   MetricsPtr                   mMetrics;                    ///< A wrapper around FontClient used to get metrics & potentially down-scaled Emoji metrics.
   Layout::Engine               mLayoutEngine;               ///< The layout engine.
   Vector<ModifyEvent>          mModifyEvents;               ///< Temporary stores the text set until the next relayout.
   Vector4                      mTextColor;                  ///< The regular text color
+  Vector4                      mAnchorColor;                ///< The anchor color
+  Vector4                      mAnchorClickedColor;         ///< The anchor clicked color
   TextUpdateInfo               mTextUpdateInfo;             ///< Info of the characters updated.
   OperationsMask               mOperationsPending;          ///< Operations pending to be done to layout the text.
   Length                       mMaximumNumberOfCharacters;  ///< Maximum number of characters that can be inserted.
@@ -1029,6 +1074,8 @@ public:
   std::unique_ptr<InputFilter> mInputFilter;                ///< Avoid allocating this when the user does not specify input filter mode.
   Vector2                      mTextFitContentSize;         ///< Size of Text fit content
 
+  std::vector<Toolkit::DevelTextLabel::FitOption> mTextFitArray; ///< List of FitOption for TextFitArray operation.
+
   bool               mRecalculateNaturalSize : 1;         ///< Whether the natural size needs to be recalculated.
   bool               mMarkupProcessorEnabled : 1;         ///< Whether the mark-up procesor is enabled.
   bool               mClipboardHideEnabled : 1;           ///< Whether the ClipboardHide function work or not
@@ -1047,6 +1094,7 @@ public:
 
   Shader mShaderBackground; ///< The shader for text background.
 
+  float mCurrentLineSize;              ///< Used to store the MinLineSize set by user when TextFitArray is enabled.
   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
@@ -1056,8 +1104,10 @@ public:
   bool  mFontSizeScaleEnabled : 1;     ///< Whether the font size scale is enabled.
   bool  mTextFitEnabled : 1;           ///< Whether the text's fit is enabled.
   bool  mTextFitChanged : 1;           ///< Whether the text fit property has changed.
+  bool  mTextFitArrayEnabled : 1;      ///< Whether the text's fit array is enabled.
   bool  mIsLayoutDirectionChanged : 1; ///< Whether the layout has changed.
   bool  mIsUserInteractionEnabled : 1; ///< Whether the user interaction is enabled.
+  bool  mProcessorRegistered : 1;      ///< Whether the text controller registered into processor or not.
 
 private:
   friend ControllerImplEventHandler;