Merge "Applyed text padding to TextLabel, Field, Editor" into devel/master
authorJinho, Lee <jeano.lee@samsung.com>
Thu, 13 Jul 2017 04:16:14 +0000 (04:16 +0000)
committerGerrit Code Review <gerrit@review.ap-northeast-2.compute.internal>
Thu, 13 Jul 2017 04:16:14 +0000 (04:16 +0000)
automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp
dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp
dali-toolkit/internal/controls/text-controls/text-editor-impl.h
dali-toolkit/internal/controls/text-controls/text-field-impl.cpp
dali-toolkit/internal/controls/text-controls/text-field-impl.h
dali-toolkit/internal/controls/text-controls/text-label-impl.cpp

index 19e9fd6..b1f4d07 100644 (file)
@@ -1728,6 +1728,16 @@ int utcDaliTextFieldEvent02(void)
   // Should not be a renderer.
   DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
 
+  // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
+  field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
+  field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
+
+  application.SendNotification();
+  application.Render();
+
+  // There are renderer and decorator layer
+  DALI_TEST_EQUALS( field.GetChildCount(), 2u, TEST_LOCATION );
+
   END_TEST;
 }
 
index 53b0683..1e4d168 100644 (file)
@@ -1193,8 +1193,8 @@ void TextEditor::OnInitialize()
 
   // Creates an extra control to be used as stencil buffer.
   mStencil = Control::New();
-  mStencil.SetAnchorPoint( AnchorPoint::CENTER );
-  mStencil.SetParentOrigin( ParentOrigin::CENTER );
+  mStencil.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+  mStencil.SetParentOrigin( ParentOrigin::TOP_LEFT );
 
   // Creates a background visual. Even if the color is transparent it updates the stencil.
   mStencil.SetProperty( Toolkit::Control::Property::BACKGROUND,
@@ -1248,14 +1248,32 @@ Vector3 TextEditor::GetNaturalSize()
 
 float TextEditor::GetHeightForWidth( float width )
 {
-  return mController->GetHeightForWidth( width );
+  Padding padding;
+  Self().GetPadding( padding );
+  return mController->GetHeightForWidth( width ) + padding.top + padding.bottom;
 }
 
 void TextEditor::OnRelayout( const Vector2& size, RelayoutContainer& container )
 {
   DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor OnRelayout\n");
 
-  const Text::Controller::UpdateTextType updateTextType = mController->Relayout( size );
+  Actor self = Self();
+  Padding padding;
+
+  self.GetPadding( padding );
+  Vector2 contentSize( size.x - ( padding.left + padding.right ), size.y - ( padding.top + padding.bottom ) );
+
+  if( mStencil )
+  {
+    mStencil.SetPosition( padding.left , padding.top  );
+  }
+  if( mActiveLayer )
+  {
+    mActiveLayer.SetPosition( padding.left , padding.top  );
+  }
+
+
+  const Text::Controller::UpdateTextType updateTextType = mController->Relayout( contentSize );
 
   if( ( Text::Controller::NONE_UPDATED != updateTextType ) ||
       !mRenderer )
@@ -1274,6 +1292,7 @@ void TextEditor::OnRelayout( const Vector2& size, RelayoutContainer& container )
     }
 
     RenderText( updateTextType );
+
   }
 
   // The text-editor emits signals when the input style changes. These changes of style are
@@ -1397,7 +1416,9 @@ void TextEditor::OnTap( const TapGesture& gesture )
   mImfManager.Activate();
 
   // Deliver the tap before the focus event to controller; this allows us to detect when focus is gained due to tap-gestures
-  mController->TapEvent( gesture.numberOfTaps, gesture.localPoint.x, gesture.localPoint.y );
+  Padding padding;
+  Self().GetPadding( padding );
+  mController->TapEvent( gesture.numberOfTaps, gesture.localPoint.x - padding.left, gesture.localPoint.y - padding.top );
 
   SetKeyInputFocus();
 }
@@ -1411,7 +1432,9 @@ void TextEditor::OnLongPress( const LongPressGesture& gesture )
 {
   mImfManager.Activate();
 
-  mController->LongPressEvent( gesture.state, gesture.localPoint.x, gesture.localPoint.y );
+  Padding padding;
+  Self().GetPadding( padding );
+  mController->LongPressEvent( gesture.state, gesture.localPoint.x - padding.left, gesture.localPoint.y - padding.top );
 
   SetKeyInputFocus();
 }
@@ -1514,7 +1537,10 @@ void TextEditor::AddDecoration( Actor& actor, bool needsClipping )
     }
     else
     {
+      actor.SetParentOrigin( ParentOrigin::TOP_LEFT );
+      actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
       Self().Add( actor );
+      mActiveLayer = actor;
     }
   }
 }
index 3c2cec4..6fbced9 100644 (file)
@@ -296,6 +296,7 @@ private: // Data
   std::vector<Actor> mClippingDecorationActors;   ///< Decoration actors which need clipping.
 
   Actor mRenderableActor;
+  Actor mActiveLayer;
   CallbackBase* mIdleCallback;
 
   float mAlignmentOffset;
index 1faa17f..d392b92 100644 (file)
@@ -1316,14 +1316,31 @@ Vector3 TextField::GetNaturalSize()
 
 float TextField::GetHeightForWidth( float width )
 {
-  return mController->GetHeightForWidth( width );
+  Padding padding;
+  Self().GetPadding( padding );
+  return mController->GetHeightForWidth( width ) + padding.top + padding.bottom;
 }
 
 void TextField::OnRelayout( const Vector2& size, RelayoutContainer& container )
 {
   DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField OnRelayout\n");
 
-  const Text::Controller::UpdateTextType updateTextType = mController->Relayout( size );
+  Actor self = Self();
+  Padding padding;
+
+  self.GetPadding( padding );
+  Vector2 contentSize( size.x - ( padding.left + padding.right ), size.y - ( padding.top + padding.bottom ) );
+
+  if( mStencil )
+  {
+    mStencil.SetPosition( padding.left , padding.top  );
+  }
+  if( mActiveLayer )
+  {
+    mActiveLayer.SetPosition( padding.left , padding.top  );
+  }
+
+  const Text::Controller::UpdateTextType updateTextType = mController->Relayout( contentSize );
 
   if( ( Text::Controller::NONE_UPDATED != updateTextType ) ||
       !mRenderer )
@@ -1342,6 +1359,7 @@ void TextField::OnRelayout( const Vector2& size, RelayoutContainer& container )
     }
 
     RenderText( updateTextType );
+
   }
 
   // The text-field emits signals when the input style changes. These changes of style are
@@ -1388,7 +1406,17 @@ void TextField::RenderText( Text::Controller::UpdateTextType updateTextType )
   {
     const Vector2& scrollOffset = mController->GetTextModel()->GetScrollPosition();
 
-    mRenderableActor.SetPosition( scrollOffset.x + mAlignmentOffset, scrollOffset.y );
+    if( mStencil )
+    {
+       mRenderableActor.SetPosition( scrollOffset.x + mAlignmentOffset, scrollOffset.y );
+    }
+    else
+    {
+       Padding padding;
+       Self().GetPadding( padding );
+       mRenderableActor.SetPosition( scrollOffset.x + mAlignmentOffset + padding.left, scrollOffset.y + padding.top );
+    }
+
 
     // Make sure the actors are parented correctly with/without clipping
     Actor self = mStencil ? mStencil : Self();
@@ -1467,7 +1495,9 @@ void TextField::OnTap( const TapGesture& gesture )
   mImfManager.Activate();
 
   // Deliver the tap before the focus event to controller; this allows us to detect when focus is gained due to tap-gestures
-  mController->TapEvent( gesture.numberOfTaps, gesture.localPoint.x, gesture.localPoint.y );
+  Padding padding;
+  Self().GetPadding( padding );
+  mController->TapEvent( gesture.numberOfTaps, gesture.localPoint.x - padding.left, gesture.localPoint.y - padding.top );
 
   SetKeyInputFocus();
 }
@@ -1481,7 +1511,9 @@ void TextField::OnLongPress( const LongPressGesture& gesture )
 {
   mImfManager.Activate();
 
-  mController->LongPressEvent( gesture.state, gesture.localPoint.x, gesture.localPoint.y );
+  Padding padding;
+  Self().GetPadding( padding );
+  mController->LongPressEvent( gesture.state, gesture.localPoint.x - padding.left, gesture.localPoint.y - padding.top );
 
   SetKeyInputFocus();
 }
@@ -1581,7 +1613,10 @@ void TextField::AddDecoration( Actor& actor, bool needsClipping )
     }
     else
     {
+      actor.SetParentOrigin( ParentOrigin::TOP_LEFT );
+      actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
       Self().Add( actor );
+      mActiveLayer = actor;
     }
   }
 }
@@ -1625,8 +1660,8 @@ void TextField::EnableClipping()
   {
     // Creates an extra control to be used as stencil buffer.
     mStencil = Control::New();
-    mStencil.SetAnchorPoint( AnchorPoint::CENTER );
-    mStencil.SetParentOrigin( ParentOrigin::CENTER );
+    mStencil.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+    mStencil.SetParentOrigin( ParentOrigin::TOP_LEFT );
 
     // Creates a background visual. Even if the color is transparent it updates the stencil.
     mStencil.SetProperty( Toolkit::Control::Property::BACKGROUND,
index 0b7b629..b8f49ee 100644 (file)
@@ -274,6 +274,7 @@ private: // Data
   Dali::InputMethodOptions mInputMethodOptions;
 
   Actor mRenderableActor;
+  Actor mActiveLayer;
   CallbackBase* mIdleCallback;
 
   float mAlignmentOffset;
index 5f17f00..784a5c8 100644 (file)
@@ -814,14 +814,21 @@ Vector3 TextLabel::GetNaturalSize()
 
 float TextLabel::GetHeightForWidth( float width )
 {
-  return mController->GetHeightForWidth( width );
+  Padding padding;
+  Self().GetPadding( padding );
+  return mController->GetHeightForWidth( width ) + padding.top + padding.bottom;
 }
 
 void TextLabel::OnRelayout( const Vector2& size, RelayoutContainer& container )
 {
   DALI_LOG_INFO( gLogFilter, Debug::General, "TextLabel::OnRelayout\n" );
 
-  const Text::Controller::UpdateTextType updateTextType = mController->Relayout( size );
+  Padding padding;
+  Self().GetPadding( padding );
+  Vector2 contentSize( size.x - ( padding.left + padding.right ), size.y - ( padding.top + padding.bottom ) );
+
+
+  const Text::Controller::UpdateTextType updateTextType = mController->Relayout( contentSize );
 
   if( ( Text::Controller::NONE_UPDATED != ( Text::Controller::MODEL_UPDATED & updateTextType ) ) ||
       !mRenderer )
@@ -861,7 +868,9 @@ void TextLabel::RenderText()
     if( renderableActor )
     {
       const Vector2& scrollOffset = mController->GetTextModel()->GetScrollPosition();
-      renderableActor.SetPosition( scrollOffset.x + alignmentOffset, scrollOffset.y );
+      Padding padding;
+      self.GetPadding( padding );
+      renderableActor.SetPosition( scrollOffset.x + alignmentOffset + padding.left, scrollOffset.y + padding.top );
 
       self.Add( renderableActor );
     }