Merge "Use Renderer::BlendMode::USE_ACTOR_OPACITY instead to use depth write mode...
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / controller / text-controller.cpp
index 5f775f7..9e9b0f0 100644 (file)
 #include <dali-toolkit/internal/text/controller/text-controller-input-properties.h>
 #include <dali-toolkit/internal/text/controller/text-controller-placeholder-handler.h>
 #include <dali-toolkit/internal/text/controller/text-controller-relayouter.h>
+#include <dali-toolkit/internal/text/controller/text-controller-spannable-handler.h>
 #include <dali-toolkit/internal/text/controller/text-controller-text-updater.h>
 #include <dali-toolkit/internal/text/text-editable-control-interface.h>
 #include <dali-toolkit/internal/text/text-geometry.h>
-
 namespace
 {
 #if defined(DEBUG_ENABLED)
@@ -473,6 +473,11 @@ void Controller::GetText(std::string& text) const
   mImpl->GetText(text);
 }
 
+void Controller::SetSpannedText(const Text::Spanned& spannedText)
+{
+  SpannableHandler::SetSpannedText(*this, spannedText);
+}
+
 void Controller::SetPlaceholderText(PlaceholderType type, const std::string& text)
 {
   PlaceholderHandler::SetPlaceholderText(*this, type, text);
@@ -1279,7 +1284,7 @@ int Controller::GetLineCount(float width)
   return mImpl->mModel->GetNumberOfLines();
 }
 
-const ModelInterface* const Controller::GetTextModel() const
+const ModelInterface* Controller::GetTextModel() const
 {
   return mImpl->mModel.Get();
 }
@@ -1416,6 +1421,16 @@ Vector<Vector2> Controller::GetTextPosition(CharacterIndex startIndex, Character
   return positionsList;
 }
 
+Rect<float> Controller::GetLineBoundingRectangle(const uint32_t lineIndex)
+{
+  return GetLineBoundingRect(mImpl->mModel, lineIndex);
+}
+
+Rect<float> Controller::GetCharacterBoundingRectangle(const uint32_t charIndex)
+{
+  return GetCharacterBoundingRect(mImpl->mModel, charIndex);
+}
+
 Rect<> Controller::GetTextBoundingRectangle(CharacterIndex startIndex, CharacterIndex endIndex)
 {
   Vector<Vector2> sizeList;
@@ -1428,10 +1443,11 @@ Rect<> Controller::GetTextBoundingRectangle(CharacterIndex startIndex, Character
     return {0, 0, 0, 0};
   }
 
-  auto minX      = positionList[0].x;
-  auto minY      = positionList[0].y;
-  auto maxRight  = positionList[0].x + sizeList[0].x;
-  auto maxBottom = positionList[0].y + sizeList[0].y;
+  auto controlWidth = mImpl->mModel->mVisualModel->mControlSize.width;
+  auto minX         = positionList[0].x;
+  auto minY         = positionList[0].y;
+  auto maxRight     = positionList[0].x + sizeList[0].x;
+  auto maxBottom    = positionList[0].y + sizeList[0].y;
 
   for(unsigned int i = 1; i < sizeList.Size(); i++)
   {
@@ -1441,6 +1457,16 @@ Rect<> Controller::GetTextBoundingRectangle(CharacterIndex startIndex, Character
     maxBottom = std::max(maxBottom, positionList[i].y + sizeList[i].y);
   }
 
+  if(minX < 0.0f)
+  {
+    minX = 0.0f;
+  }
+
+  if(maxRight > controlWidth)
+  {
+    maxRight = controlWidth;
+  }
+
   return {minX, minY, maxRight - minX, maxBottom - minY};
 }