Add GetCharacterIndexAtPosition API
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / text-controls / text-editor-impl.cpp
index 42153dc..ea5f43c 100644 (file)
@@ -159,6 +159,8 @@ DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit,           TextEditor, "strikethrough",
 DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit,           TextEditor, "inputStrikethrough",                   MAP,       INPUT_STRIKETHROUGH                 )
 DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit,           TextEditor, "characterSpacing",                     FLOAT,     CHARACTER_SPACING                   )
 DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit,           TextEditor, "relativeLineSize",                     FLOAT,     RELATIVE_LINE_SIZE                  )
+DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit,           TextEditor, "verticalAlignment",                    STRING,    VERTICAL_ALIGNMENT                  )
+DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit,           TextEditor, "selectionPopupStyle",                  MAP,       SELECTION_POPUP_STYLE               )
 
 DALI_SIGNAL_REGISTRATION(Toolkit, TextEditor, "textChanged",           SIGNAL_TEXT_CHANGED           )
 DALI_SIGNAL_REGISTRATION(Toolkit, TextEditor, "inputStyleChanged",     SIGNAL_INPUT_STYLE_CHANGED    )
@@ -231,10 +233,10 @@ Toolkit::TextEditor::InputStyle::Mask ConvertInputStyle(Text::InputStyle::Mask i
 
 } // namespace
 
-Toolkit::TextEditor TextEditor::New()
+Toolkit::TextEditor TextEditor::New(ControlBehaviour additionalBehaviour)
 {
   // Create the implementation, temporarily owned by this handle on stack
-  IntrusivePtr<TextEditor> impl = new TextEditor();
+  IntrusivePtr<TextEditor> impl = new TextEditor(additionalBehaviour);
 
   // Pass ownership to CustomActor handle
   Toolkit::TextEditor handle(*impl);
@@ -362,6 +364,26 @@ Vector<Vector2> TextEditor::GetTextPosition(const uint32_t startIndex, const uin
   return mController->GetTextPosition(startIndex, endIndex);
 }
 
+Rect<float> TextEditor::GetLineBoundingRectangle(const uint32_t lineIndex) const
+{
+  return mController->GetLineBoundingRectangle(lineIndex);
+}
+
+Rect<float> TextEditor::GetCharacterBoundingRectangle(const uint32_t charIndex) const
+{
+  return mController->GetCharacterBoundingRectangle(charIndex);
+}
+
+int TextEditor::GetCharacterIndexAtPosition(float visualX, float visualY) const
+{
+  return mController->GetCharacterIndexAtPosition(visualX, visualY);
+}
+
+void TextEditor::SetSpannedText(const Text::Spanned& spannedText)
+{
+  mController->SetSpannedText(spannedText);
+}
+
 string TextEditor::GetSelectedText() const
 {
   string selectedText = "";
@@ -892,7 +914,7 @@ void TextEditor::OnTap(const TapGesture& gesture)
   mController->AnchorEvent(localPoint.x - padding.start, localPoint.y - padding.top);
 
   Dali::Toolkit::KeyboardFocusManager keyboardFocusManager = Dali::Toolkit::KeyboardFocusManager::Get();
-  if (keyboardFocusManager)
+  if(keyboardFocusManager)
   {
     keyboardFocusManager.SetCurrentFocusActor(Self());
   }
@@ -902,6 +924,10 @@ void TextEditor::OnTap(const TapGesture& gesture)
 void TextEditor::OnPan(const PanGesture& gesture)
 {
   mController->PanEvent(gesture.GetState(), gesture.GetDisplacement());
+  if(gesture.GetState() == GestureState::STARTED && !mController->IsScrollable(gesture.GetDisplacement()))
+  {
+    Dali::DevelActor::SetNeedGesturePropagation(Self(), true);
+  }
 }
 
 void TextEditor::OnLongPress(const LongPressGesture& gesture)
@@ -928,7 +954,7 @@ bool TextEditor::OnKeyEvent(const KeyEvent& event)
     if(event.GetState() == KeyEvent::UP)
     {
       Dali::Toolkit::KeyboardFocusManager keyboardFocusManager = Dali::Toolkit::KeyboardFocusManager::Get();
-      if (keyboardFocusManager)
+      if(keyboardFocusManager)
       {
         keyboardFocusManager.ClearFocus();
       }
@@ -1345,8 +1371,8 @@ void TextEditor::OnLayoutDirectionChanged(Actor actor, LayoutDirection::Type typ
   mController->ChangedLayoutDirection();
 }
 
-TextEditor::TextEditor()
-: Control(ControlBehaviour(CONTROL_BEHAVIOUR_DEFAULT)),
+TextEditor::TextEditor(ControlBehaviour additionalBehaviour)
+: Control(ControlBehaviour(CONTROL_BEHAVIOUR_DEFAULT | additionalBehaviour)),
   mAnimationPeriod(0.0f, 0.0f),
   mIdleCallback(NULL),
   mAlignmentOffset(0.f),