From 309dec1120f1f4ff528f615d3607da8422464107 Mon Sep 17 00:00:00 2001 From: Joogab Yun Date: Sat, 17 Nov 2018 08:39:06 +0900 Subject: [PATCH] Relayout again for LTR / RTL order when layout direction is changed. Change-Id: Idf8e74af65e29bbc6d5ade7860ac7795ce31c446 --- .../controls/text-controls/text-editor-impl.cpp | 3 ++- .../internal/controls/text-controls/text-field-impl.cpp | 3 ++- .../internal/controls/text-controls/text-label-impl.cpp | 4 +++- dali-toolkit/internal/text/text-controller.cpp | 17 ++++++++++++++++- 4 files changed, 23 insertions(+), 4 deletions(-) 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 b065e99..7ca679c 100755 --- a/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp @@ -1244,7 +1244,8 @@ void TextEditor::OnInitialize() mController->SetNoTextLongPressAction( Controller::NoTextTap::HIGHLIGHT ); // Sets layoutDirection value - Dali::LayoutDirection::Type layoutDirection = static_cast( self.GetProperty( Dali::Actor::Property::LAYOUT_DIRECTION ).Get() ); + Dali::Stage stage = Dali::Stage::GetCurrent(); + Dali::LayoutDirection::Type layoutDirection = static_cast( stage.GetRootLayer().GetProperty( Dali::Actor::Property::LAYOUT_DIRECTION ).Get() ); mController->SetLayoutDirection( layoutDirection ); // Forward input events to controller 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 655c335..2b76083 100755 --- a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp @@ -1304,7 +1304,8 @@ void TextField::OnInitialize() mController->SetNoTextLongPressAction( Controller::NoTextTap::HIGHLIGHT ); // Sets layoutDirection value - Dali::LayoutDirection::Type layoutDirection = static_cast( self.GetProperty( Dali::Actor::Property::LAYOUT_DIRECTION ).Get() ); + Dali::Stage stage = Dali::Stage::GetCurrent(); + Dali::LayoutDirection::Type layoutDirection = static_cast( stage.GetRootLayer().GetProperty( Dali::Actor::Property::LAYOUT_DIRECTION ).Get() ); mController->SetLayoutDirection( layoutDirection ); // Forward input events to controller 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 79dc2cb..473730d 100755 --- a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp @@ -20,6 +20,7 @@ // EXTERNAL INCLUDES #include +#include #include #include #include @@ -884,7 +885,8 @@ void TextLabel::OnInitialize() mController->SetTextElideEnabled( true ); // If false then text larger than control will overflow // Sets layoutDirection value - Dali::LayoutDirection::Type layoutDirection = static_cast( self.GetProperty( Dali::Actor::Property::LAYOUT_DIRECTION ).Get() ); + Dali::Stage stage = Dali::Stage::GetCurrent(); + Dali::LayoutDirection::Type layoutDirection = static_cast( stage.GetRootLayer().GetProperty( Dali::Actor::Property::LAYOUT_DIRECTION ).Get() ); mController->SetLayoutDirection( layoutDirection ); Layout::Engine& engine = mController->GetLayoutEngine(); diff --git a/dali-toolkit/internal/text/text-controller.cpp b/dali-toolkit/internal/text/text-controller.cpp index 13d0ab2..6849f33 100755 --- a/dali-toolkit/internal/text/text-controller.cpp +++ b/dali-toolkit/internal/text/text-controller.cpp @@ -2250,7 +2250,6 @@ Controller::UpdateTextType Controller::Relayout( const Size& size, Dali::LayoutD UpdateTextType updateTextType = NONE_UPDATED; - mImpl->mLayoutDirection = layoutDirection; if( ( size.width < Math::MACHINE_EPSILON_1000 ) || ( size.height < Math::MACHINE_EPSILON_1000 ) ) { if( 0u != mImpl->mModel->mVisualModel->mGlyphPositions.Count() ) @@ -2318,6 +2317,22 @@ Controller::UpdateTextType Controller::Relayout( const Size& size, Dali::LayoutD mImpl->mTextUpdateInfo.mCharacterIndex = 0u; } + if( mImpl->mModel->mMatchSystemLanguageDirection && 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. ProcessModifyEvents(); bool updated = mImpl->UpdateModel( mImpl->mOperationsPending ); -- 2.7.4