Merge "Updated visuals to use VisualRenderer" into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / text-controls / text-field-impl.cpp
index 2b813da..35d06ea 100644 (file)
@@ -144,6 +144,7 @@ DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit,           TextField, "inputFilter",
 DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit,           TextField, "ellipsisPosition",                 INTEGER,   ELLIPSIS_POSITION                   )
 DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit,           TextField, "strikethrough",                    MAP,       STRIKETHROUGH                       )
 DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit,           TextField, "inputStrikethrough",               MAP,       INPUT_STRIKETHROUGH                 )
+DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit,           TextField, "characterSpacing",                 FLOAT,     CHARACTER_SPACING                   )
 
 DALI_SIGNAL_REGISTRATION(Toolkit, TextField, "textChanged",           SIGNAL_TEXT_CHANGED           )
 DALI_SIGNAL_REGISTRATION(Toolkit, TextField, "maxLengthReached",      SIGNAL_MAX_LENGTH_REACHED     )
@@ -657,6 +658,11 @@ void TextField::OnRelayout(const Vector2& size, RelayoutContainer& container)
     mActiveLayer.SetProperty(Actor::Property::POSITION, Vector2(padding.start, padding.top));
     ResizeActor(mActiveLayer, contentSize);
   }
+  if(mCursorLayer)
+  {
+    mCursorLayer.SetProperty(Actor::Property::POSITION, Vector2(padding.start, padding.top));
+    ResizeActor(mCursorLayer, contentSize);
+  }
 
   // If there is text changed, callback is called.
   if(mTextChanged)
@@ -1007,7 +1013,7 @@ void TextField::SelectionChanged(uint32_t oldStart, uint32_t oldEnd, uint32_t ne
   }
 }
 
-void TextField::AddDecoration(Actor& actor, bool needsClipping)
+void TextField::AddDecoration(Actor& actor, DecorationType type, bool needsClipping)
 {
   if(actor)
   {
@@ -1015,16 +1021,27 @@ void TextField::AddDecoration(Actor& actor, bool needsClipping)
     {
       mClippingDecorationActors.push_back(actor);
     }
-    else
+
+    // If the actor is a layer type, add it.
+    if(type == DecorationType::ACTIVE_LAYER)
+    {
+      AddLayer(mActiveLayer, actor);
+    }
+    else if(type == DecorationType::CURSOR_LAYER)
     {
-      actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
-      actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
-      Self().Add(actor);
-      mActiveLayer = actor;
+      AddLayer(mCursorLayer, actor);
     }
   }
 }
 
+void TextField::AddLayer(Actor& layer, Actor& actor)
+{
+  actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
+  actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+  Self().Add(actor);
+  layer = actor;
+}
+
 void TextField::GetControlBackgroundColor(Vector4& color) const
 {
   Property::Value propValue = Self().GetProperty(Toolkit::Control::Property::BACKGROUND);
@@ -1387,6 +1404,24 @@ bool TextField::AccessibleImpl::SetRangeOfSelection(size_t selectionIndex, size_
   return true;
 }
 
+Rect<> TextField::AccessibleImpl::GetRangeExtents(size_t startOffset, size_t endOffset, Accessibility::CoordinateType type)
+{
+  if (endOffset <= startOffset || endOffset <= 0)
+  {
+    return {0, 0, 0, 0};
+  }
+
+  auto self = Toolkit::TextField::DownCast(Self());
+  auto rect = Dali::Toolkit::GetImpl(self).GetTextController()->GetTextBoundingRectangle(startOffset, endOffset - 1);
+
+  auto componentExtents = this->GetExtents(type);
+
+  rect.x += componentExtents.x;
+  rect.y += componentExtents.y;
+
+  return rect;
+}
+
 bool TextField::AccessibleImpl::CopyText(size_t startPosition, size_t endPosition)
 {
   if(endPosition <= startPosition)