Fixed issue where only the last line was aligned in the case of a multiline input... 38/215238/6
authorJoogab Yun <joogab.yun@samsung.com>
Fri, 4 Oct 2019 02:04:11 +0000 (11:04 +0900)
committerJoogab Yun <joogab.yun@samsung.com>
Fri, 4 Oct 2019 09:56:36 +0000 (18:56 +0900)
If you try to ALIGNMENT after entering multilines, only the last line is aligned.
So when the _ALIGNMENT property is entered, we modify it to be a full aligned.

ex)
    textEditor2 = TextEditor::New();
    textEditor2.SetBackgroundColor( Color::CYAN );
    textEditor2.SetProperty( TextEditor::Property::TEXT_COLOR, Color::YELLOW );
    textEditor2.SetSize( 500.f, 500.f );
    textEditor2.SetPosition( 900.f, 150.f );
    textEditor2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
    textEditor2.SetProperty( TextEditor::Property::TEXT, "test test " );
    stage.Add( textEditor2 );

    Control control2 = Control::New();
    control2.SetSize(80,80);
    control2.SetBackgroundColor(Color::YELLOW);
    control2.SetPosition(750,200);
    control2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
    control2.TouchSignal().Connect(this, &HelloWorldController::OnTouch3);
    stage.Add( control2 );

  bool OnTouch3( Actor actor, const TouchData& touch )
  {
    textEditor2.SetProperty( TextEditor::Property::TEXT_COLOR, Color::RED );
    textEditor2.SetColor(Color::BLUE );
    textEditor2.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "END" );
    return true;
  }

Change-Id: Icc98d04d7c556a4d33b5de8640c2fc29587c1b35

dali-toolkit/internal/text/text-controller-impl.cpp
dali-toolkit/internal/text/text-controller-impl.h
dali-toolkit/internal/text/text-controller.cpp

index 90eb88c..2686153 100755 (executable)
@@ -110,7 +110,8 @@ EventData::EventData( DecoratorPtr decorator, InputMethodContext& inputMethodCon
   mIsPlaceholderPixelSize( false ),
   mIsPlaceholderElideEnabled( false ),
   mPlaceholderEllipsisFlag( false ),
-  mShiftSelectionFlag( true )
+  mShiftSelectionFlag( true ),
+  mUpdateAlignment( false )
 {
 }
 
index 5527870..5dd231a 100755 (executable)
@@ -167,6 +167,7 @@ struct EventData
   bool mIsPlaceholderElideEnabled       : 1;   ///< True if the placeholder text's elide is enabled.
   bool mPlaceholderEllipsisFlag         : 1;   ///< True if the text controller sets the placeholder ellipsis.
   bool mShiftSelectionFlag              : 1;   ///< True if the text selection using Shift key is enabled.
+  bool mUpdateAlignment                 : 1;   ///< True if the whole text needs to be full aligned..
 };
 
 struct ModifyEvent
index fee1690..44a6788 100755 (executable)
@@ -396,6 +396,11 @@ void Controller::SetHorizontalAlignment( Text::HorizontalAlignment::Type alignme
     // Set the flag to redo the alignment operation.
     mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending | ALIGN );
 
+    if( mImpl->mEventData )
+    {
+      mImpl->mEventData->mUpdateAlignment = true;
+    }
+
     mImpl->RequestRelayout();
   }
 }
@@ -3945,11 +3950,23 @@ bool Controller::DoRelayout( const Size& size,
     // The laid-out lines.
     Vector<LineRun>& lines = mImpl->mModel->mVisualModel->mLines;
 
+    CharacterIndex alignStartIndex = startIndex;
+    Length alignRequestedNumberOfCharacters = requestedNumberOfCharacters;
+
+    // the whole text needs to be full aligned.
+    // If you do not do a full aligned, only the last line of the multiline input is aligned.
+    if(  mImpl->mEventData && mImpl->mEventData->mUpdateAlignment )
+    {
+      alignStartIndex = 0u;
+      alignRequestedNumberOfCharacters = mImpl->mModel->mLogicalModel->mText.Count();
+      mImpl->mEventData->mUpdateAlignment = false;
+    }
+
     // Need to align with the control's size as the text may contain lines
     // starting either with left to right text or right to left.
     mImpl->mLayoutEngine.Align( size,
-                                startIndex,
-                                requestedNumberOfCharacters,
+                                alignStartIndex,
+                                alignRequestedNumberOfCharacters,
                                 mImpl->mModel->mHorizontalAlignment,
                                 lines,
                                 mImpl->mModel->mAlignmentOffset,