From dc1fc0c680e49688cd9e673dab5665e651266fde Mon Sep 17 00:00:00 2001 From: Joogab Yun Date: Tue, 31 Dec 2019 14:20:09 +0900 Subject: [PATCH] [Tizen] If matchSystemLanguageDirection is set, it must follow the direction of the stage. Change-Id: I05d25ad67d43a2303d4902f120a026b14e1ac2e4 --- .../utc-Dali-Text-Controller.cpp | 22 ++++++++++++++ .../controls/text-controls/text-editor-impl.cpp | 2 +- .../controls/text-controls/text-field-impl.cpp | 2 +- .../controls/text-controls/text-label-impl.cpp | 6 ++-- dali-toolkit/internal/text/text-controller.cpp | 35 +++++++++++++--------- dali-toolkit/internal/text/text-controller.h | 3 +- dali-toolkit/internal/visuals/text/text-visual.cpp | 4 +-- 7 files changed, 49 insertions(+), 25 deletions(-) diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Controller.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Controller.cpp index 11584a9..e819f7d 100755 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Controller.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Controller.cpp @@ -1187,3 +1187,25 @@ int UtcDaliTextControllerMaxLengthSetText(void) END_TEST; } + +int UtcDaliTextControllerDirectionCoverage(void) +{ + tet_infoline(" UtcDaliTextControllerDirectionCoverage"); + ToolkitTestApplication application; + + // Creates a text controller. + ControllerPtr controller = Controller::New(); + + ConfigureTextLabel(controller); + + controller->SetMatchSystemLanguageDirection( true ); + controller->SetLayoutDirection( Dali::LayoutDirection::RIGHT_TO_LEFT ); + + // Perform a relayout + const Size size( Dali::Stage::GetCurrent().GetSize() ); + controller->Relayout(size); + + tet_result(TET_PASS); + + END_TEST; +} diff --git a/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp index 3444c39..3c5333d 100755 --- a/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp @@ -1373,7 +1373,7 @@ void TextEditor::OnRelayout( const Vector2& size, RelayoutContainer& container ) mActiveLayer.SetPosition( padding.start, padding.top ); } - const Text::Controller::UpdateTextType updateTextType = mController->Relayout( contentSize, layoutDirection ); + const Text::Controller::UpdateTextType updateTextType = mController->Relayout( contentSize ); if( ( Text::Controller::NONE_UPDATED != updateTextType ) || !mRenderer ) diff --git a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp index 3f2becd..91aa5a6 100755 --- a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp @@ -1419,7 +1419,7 @@ void TextField::OnRelayout( const Vector2& size, RelayoutContainer& container ) mActiveLayer.SetPosition( padding.start, padding.top ); } - const Text::Controller::UpdateTextType updateTextType = mController->Relayout( contentSize, layoutDirection ); + const Text::Controller::UpdateTextType updateTextType = mController->Relayout( contentSize ); if( ( Text::Controller::NONE_UPDATED != updateTextType ) || !mRenderer ) diff --git a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp index c521817..c1fb31f 100755 --- a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp @@ -965,10 +965,7 @@ void TextLabel::OnRelayout( const Vector2& size, RelayoutContainer& container ) mController->SetTextFitContentSize( contentSize ); } - // Support Right-To-Left - Dali::LayoutDirection::Type layoutDirection = static_cast( Self().GetProperty( Dali::Actor::Property::LAYOUT_DIRECTION ).Get() ); - - const Text::Controller::UpdateTextType updateTextType = mController->Relayout( contentSize, layoutDirection ); + const Text::Controller::UpdateTextType updateTextType = mController->Relayout( contentSize ); if( ( Text::Controller::NONE_UPDATED != ( Text::Controller::MODEL_UPDATED & updateTextType ) ) || mTextUpdateNeeded ) @@ -979,6 +976,7 @@ void TextLabel::OnRelayout( const Vector2& size, RelayoutContainer& container ) TextVisual::EnableRendererUpdate( mVisual ); // Support Right-To-Left of padding + Dali::LayoutDirection::Type layoutDirection = static_cast( Self().GetProperty( Dali::Actor::Property::LAYOUT_DIRECTION ).Get() ); if( Dali::LayoutDirection::RIGHT_TO_LEFT == layoutDirection ) { std::swap( padding.start, padding.end ); diff --git a/dali-toolkit/internal/text/text-controller.cpp b/dali-toolkit/internal/text/text-controller.cpp index ff038f4..6f9fe15 100755 --- a/dali-toolkit/internal/text/text-controller.cpp +++ b/dali-toolkit/internal/text/text-controller.cpp @@ -23,6 +23,8 @@ #include #include #include +#include +#include #include #include #include @@ -2475,7 +2477,7 @@ void Controller::SetVerticalLineAlignment( Toolkit::DevelText::VerticalLineAlign // public : Relayout. -Controller::UpdateTextType Controller::Relayout( const Size& size, Dali::LayoutDirection::Type layoutDirection ) +Controller::UpdateTextType Controller::Relayout( const Size& size ) { DALI_LOG_INFO( gLogFilter, Debug::Verbose, "-->Controller::Relayout %p size %f,%f, autoScroll[%s]\n", this, size.width, size.height, mImpl->mIsAutoScrollEnabled ?"true":"false" ); @@ -2548,20 +2550,25 @@ Controller::UpdateTextType Controller::Relayout( const Size& size, Dali::LayoutD mImpl->mTextUpdateInfo.mCharacterIndex = 0u; } - if( mImpl->mModel->mMatchSystemLanguageDirection && mImpl->mLayoutDirection != layoutDirection ) + if( mImpl->mModel->mMatchSystemLanguageDirection ) { - // Clear the update info. This info will be set the next time the text is updated. - mImpl->mTextUpdateInfo.mClearAll = true; - // Apply modifications to the model - // Shape the text again is needed because characters like '()[]{}' have to be mirrored and the glyphs generated again. - mImpl->mOperationsPending = static_cast( mImpl->mOperationsPending | - GET_GLYPH_METRICS | - SHAPE_TEXT | - UPDATE_DIRECTION | - LAYOUT | - BIDI_INFO | - REORDER ); - mImpl->mLayoutDirection = layoutDirection; + Dali::LayoutDirection::Type layoutDirection = static_cast( Dali::Stage::GetCurrent().GetRootLayer().GetProperty( Dali::Actor::Property::LAYOUT_DIRECTION ).Get() ); + + if( mImpl->mLayoutDirection != layoutDirection ) + { + // Clear the update info. This info will be set the next time the text is updated. + mImpl->mTextUpdateInfo.mClearAll = true; + // Apply modifications to the model + // Shape the text again is needed because characters like '()[]{}' have to be mirrored and the glyphs generated again. + mImpl->mOperationsPending = static_cast( mImpl->mOperationsPending | + GET_GLYPH_METRICS | + SHAPE_TEXT | + UPDATE_DIRECTION | + LAYOUT | + BIDI_INFO | + REORDER ); + mImpl->mLayoutDirection = layoutDirection; + } } // Make sure the model is up-to-date before layouting. diff --git a/dali-toolkit/internal/text/text-controller.h b/dali-toolkit/internal/text/text-controller.h index 82a7a15..4e3f5a0 100755 --- a/dali-toolkit/internal/text/text-controller.h +++ b/dali-toolkit/internal/text/text-controller.h @@ -1384,11 +1384,10 @@ public: // Relayout. * * @note UI Controls are expected to minimize calls to this method e.g. call once after size negotiation. * @param[in] size A the size of a bounding box to layout text within. - * @param[in] layoutDirection The direction of the system language. * * @return Whether the text model or decorations were updated. */ - UpdateTextType Relayout( const Size& size, Dali::LayoutDirection::Type layoutDirection = Dali::LayoutDirection::LEFT_TO_RIGHT ); + UpdateTextType Relayout( const Size& size ); /** * @brief Request a relayout using the ControlInterface. diff --git a/dali-toolkit/internal/visuals/text/text-visual.cpp b/dali-toolkit/internal/visuals/text/text-visual.cpp index 1171033..a328e8f 100755 --- a/dali-toolkit/internal/visuals/text/text-visual.cpp +++ b/dali-toolkit/internal/visuals/text/text-visual.cpp @@ -626,9 +626,7 @@ void TextVisual::UpdateRenderer() return; } - Dali::LayoutDirection::Type layoutDirection = static_cast( control.GetProperty( Dali::Actor::Property::LAYOUT_DIRECTION ).Get() ); - - const Text::Controller::UpdateTextType updateTextType = mController->Relayout( relayoutSize, layoutDirection ); + const Text::Controller::UpdateTextType updateTextType = mController->Relayout( relayoutSize ); if( Text::Controller::NONE_UPDATED != ( Text::Controller::MODEL_UPDATED & updateTextType ) || mRendererUpdateNeeded ) -- 2.7.4