[dali_2.1.3] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / text-controls / text-field-impl.cpp
index b48faa0..9cefc6c 100644 (file)
@@ -204,8 +204,8 @@ Toolkit::TextField::InputStyle::Mask ConvertInputStyle(Text::InputStyle::Mask in
 bool IsHiddenInput(Toolkit::TextField textField)
 {
   Property::Map hiddenInputSettings = textField.GetProperty<Property::Map>(Toolkit::TextField::Property::HIDDEN_INPUT_SETTINGS);
-  auto mode  = hiddenInputSettings.Find(Toolkit::HiddenInput::Property::MODE);
-  if (mode && (mode->Get<int>() != Toolkit::HiddenInput::Mode::HIDE_NONE))
+  auto          mode                = hiddenInputSettings.Find(Toolkit::HiddenInput::Property::MODE);
+  if(mode && (mode->Get<int>() != Toolkit::HiddenInput::Mode::HIDE_NONE))
   {
     return true;
   }
@@ -215,8 +215,8 @@ bool IsHiddenInput(Toolkit::TextField textField)
 char GetSubstituteCharacter(Toolkit::TextField textField)
 {
   Property::Map hiddenInputSettings = textField.GetProperty<Property::Map>(Toolkit::TextField::Property::HIDDEN_INPUT_SETTINGS);
-  auto substChar = hiddenInputSettings.Find(Toolkit::HiddenInput::Property::SUBSTITUTE_CHARACTER);
-  if (substChar)
+  auto          substChar           = hiddenInputSettings.Find(Toolkit::HiddenInput::Property::SUBSTITUTE_CHARACTER);
+  if(substChar)
   {
     return static_cast<char>(substChar->Get<int>());
   }
@@ -463,6 +463,11 @@ DevelTextField::SelectionClearedSignalType& TextField::SelectionClearedSignal()
   return mSelectionClearedSignal;
 }
 
+void TextField::OnAccessibilityStatusChanged()
+{
+  CommonTextUtils::SynchronizeTextAnchorsInParent(Self(), mController, mAnchorActors);
+}
+
 void TextField::OnInitialize()
 {
   Actor self = Self();
@@ -541,6 +546,9 @@ void TextField::OnInitialize()
     return std::unique_ptr<Dali::Accessibility::Accessible>(
       new AccessibleImpl(actor, Dali::Accessibility::Role::ENTRY));
   });
+
+  Accessibility::Bridge::EnabledSignal().Connect(this, &TextField::OnAccessibilityStatusChanged);
+  Accessibility::Bridge::DisabledSignal().Connect(this, &TextField::OnAccessibilityStatusChanged);
 }
 
 void TextField::OnStyleChange(Toolkit::StyleManager styleManager, StyleChange::Type change)
@@ -702,7 +710,7 @@ Text::ControllerPtr TextField::GetTextController()
 
 void TextField::RenderText(Text::Controller::UpdateTextType updateTextType)
 {
-  CommonTextUtils::RenderText(Self(), mRenderer, mController, mDecorator, mAlignmentOffset, mRenderableActor, mBackgroundActor, mStencil, mClippingDecorationActors, updateTextType);
+  CommonTextUtils::RenderText(Self(), mRenderer, mController, mDecorator, mAlignmentOffset, mRenderableActor, mBackgroundActor, mStencil, mClippingDecorationActors, mAnchorActors, updateTextType);
 }
 
 void TextField::OnKeyInputFocusGained()
@@ -1120,10 +1128,20 @@ TextField::~TextField()
   }
 }
 
+Vector<Vector2> TextField::GetTextSize(const uint32_t startIndex, const uint32_t endIndex) const
+{
+  return mController->GetTextSize(startIndex, endIndex);
+}
+
+Vector<Vector2> TextField::GetTextPosition(const uint32_t startIndex, const uint32_t endIndex) const
+{
+  return mController->GetTextPosition(startIndex, endIndex);
+}
+
 std::string TextField::AccessibleImpl::GetName()
 {
   auto self = Toolkit::TextField::DownCast(Self());
-  if (IsHiddenInput(self))
+  if(IsHiddenInput(self))
   {
     return {};
   }
@@ -1185,8 +1203,8 @@ bool TextField::AccessibleImpl::SetCursorOffset(size_t offset)
 Dali::Accessibility::Range TextField::AccessibleImpl::GetTextAtOffset(
   size_t offset, Dali::Accessibility::TextBoundary boundary)
 {
-  auto self     = Toolkit::TextField::DownCast(Self());
-  auto range    = Dali::Accessibility::Range{};
+  auto self  = Toolkit::TextField::DownCast(Self());
+  auto range = Dali::Accessibility::Range{};
 
   if(IsHiddenInput(self))
   {
@@ -1289,14 +1307,14 @@ Dali::Accessibility::Range TextField::AccessibleImpl::GetRangeOfSelection(size_t
     return {};
   }
 
-  auto self = Toolkit::TextField::DownCast(Self());
+  auto self       = Toolkit::TextField::DownCast(Self());
   auto controller = Dali::Toolkit::GetImpl(self).GetTextController();
-  auto indices = controller->GetSelectionIndexes();
+  auto indices    = controller->GetSelectionIndexes();
 
   auto startOffset = static_cast<size_t>(indices.first);
-  auto endOffset = static_cast<size_t>(indices.second);
+  auto endOffset   = static_cast<size_t>(indices.second);
 
-  if (IsHiddenInput(self))
+  if(IsHiddenInput(self))
   {
     return {startOffset, endOffset, std::string(endOffset - startOffset, GetSubstituteCharacter(self))};
   }
@@ -1414,6 +1432,30 @@ bool TextField::AccessibleImpl::SetTextContents(std::string newContents)
   return true;
 }
 
+int32_t TextField::AccessibleImpl::GetLinkCount() const
+{
+  auto self = Toolkit::TextField::DownCast(Self());
+  return Dali::Toolkit::GetImpl(self).mAnchorActors.size();
+}
+
+Accessibility::Hyperlink* TextField::AccessibleImpl::GetLink(int32_t linkIndex) const
+{
+  if(linkIndex < 0 || linkIndex >= GetLinkCount())
+  {
+    return nullptr;
+  }
+  auto self        = Toolkit::TextField::DownCast(Self());
+  auto anchorActor = Dali::Toolkit::GetImpl(self).mAnchorActors[linkIndex];
+  return dynamic_cast<Accessibility::Hyperlink*>(Dali::Accessibility::Accessible::Get(anchorActor));
+}
+
+int32_t TextField::AccessibleImpl::GetLinkIndex(int32_t characterOffset) const
+{
+  auto self       = Toolkit::TextField::DownCast(Self());
+  auto controller = Dali::Toolkit::GetImpl(self).GetTextController();
+  return controller->GetAnchorIndex(static_cast<size_t>(characterOffset));
+}
+
 } // namespace Internal
 
 } // namespace Toolkit