From ba02d015c159c2bfd5b6f76856b194ed333e8118 Mon Sep 17 00:00:00 2001 From: Joogab Yun Date: Wed, 21 Nov 2018 14:10:41 +0900 Subject: [PATCH] [Tizen] code clean up : Relayout again for LTR / RTL order when layout direction is changed. Change-Id: Iaf226f4128b6b0a2572eb5af5ae1e9bfcb5e8f96 --- .../controls/text-controls/text-editor-impl.cpp | 10 ++------- .../controls/text-controls/text-editor-impl.h | 8 +------ .../controls/text-controls/text-field-impl.cpp | 10 ++------- .../controls/text-controls/text-field-impl.h | 8 +------ .../controls/text-controls/text-label-impl.cpp | 10 ++------- .../controls/text-controls/text-label-impl.h | 8 +------ dali-toolkit/internal/text/text-controller.cpp | 25 ++++++++++++++-------- dali-toolkit/internal/text/text-controller.h | 5 ----- 8 files changed, 25 insertions(+), 59 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 d125510..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,11 +1244,10 @@ 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 ); - self.LayoutDirectionChangedSignal().Connect( this, &TextEditor::OnLayoutDirectionChanged ); - // Forward input events to controller EnableGestureDetection( static_cast( Gesture::Tap | Gesture::Pan | Gesture::LongPress ) ); GetTapGestureDetector().SetMaximumTapsRequired( 2 ); @@ -1295,11 +1294,6 @@ void TextEditor::OnInitialize() self.Add( mStencil ); } -void TextEditor::OnLayoutDirectionChanged( Dali::Actor actor, Dali::LayoutDirection::Type type ) -{ - mController->UpdateLayoutDirectionChanged( type ); -} - void TextEditor::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Type change ) { DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor::OnStyleChange\n"); diff --git a/dali-toolkit/internal/controls/text-controls/text-editor-impl.h b/dali-toolkit/internal/controls/text-controls/text-editor-impl.h index 24a5ddc..d878d66 100755 --- a/dali-toolkit/internal/controls/text-controls/text-editor-impl.h +++ b/dali-toolkit/internal/controls/text-controls/text-editor-impl.h @@ -22,6 +22,7 @@ #include #include #include +#include // INTERNAL INCLUDES #include @@ -261,13 +262,6 @@ private: // Implementation void OnScrollIndicatorAnimationFinished( Animation& animation ); /** - * @brief Callbacks when the layout direction changes - * @param[in] actor The actor whose layoutDirection is changed. - * @param[in] type The layoutDirection. - */ - void OnLayoutDirectionChanged( Dali::Actor actor, Dali::LayoutDirection::Type type ); - - /** * Construct a new TextEditor. */ TextEditor(); 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 cc1df34..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,11 +1304,10 @@ 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 ); - self.LayoutDirectionChangedSignal().Connect( this, &TextField::OnLayoutDirectionChanged ); - // Forward input events to controller EnableGestureDetection( static_cast( Gesture::Tap | Gesture::Pan | Gesture::LongPress ) ); GetTapGestureDetector().SetMaximumTapsRequired( 2 ); @@ -1341,11 +1340,6 @@ void TextField::OnInitialize() } } -void TextField::OnLayoutDirectionChanged( Dali::Actor actor, Dali::LayoutDirection::Type type ) -{ - mController->UpdateLayoutDirectionChanged( type ); -} - void TextField::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Type change ) { DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnStyleChange\n"); diff --git a/dali-toolkit/internal/controls/text-controls/text-field-impl.h b/dali-toolkit/internal/controls/text-controls/text-field-impl.h index 7adcb8f..a9a1af6 100755 --- a/dali-toolkit/internal/controls/text-controls/text-field-impl.h +++ b/dali-toolkit/internal/controls/text-controls/text-field-impl.h @@ -21,6 +21,7 @@ // EXTERNAL INCLUDES #include #include +#include // INTERNAL INCLUDES #include @@ -242,13 +243,6 @@ private: // Implementation void OnIdleSignal(); /** - * @brief Callbacks when the layout direction changes - * @param[in] actor The actor whose layoutDirection is changed. - * @param[in] type The layoutDirection. - */ - void OnLayoutDirectionChanged( Dali::Actor actor, Dali::LayoutDirection::Type type ); - - /** * Construct a new TextField. */ TextField(); 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 eddec25..d88b714 100755 --- a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp @@ -885,20 +885,14 @@ 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 ); - self.LayoutDirectionChangedSignal().Connect( this, &TextLabel::OnLayoutDirectionChanged ); - Layout::Engine& engine = mController->GetLayoutEngine(); engine.SetCursorWidth( 0u ); // Do not layout space for the cursor. } -void TextLabel::OnLayoutDirectionChanged( Dali::Actor actor, Dali::LayoutDirection::Type type ) -{ - mController->UpdateLayoutDirectionChanged( type ); -} - void TextLabel::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Type change ) { DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextLabel::OnStyleChange\n"); diff --git a/dali-toolkit/internal/controls/text-controls/text-label-impl.h b/dali-toolkit/internal/controls/text-controls/text-label-impl.h index b9f3bf8..b94f70f 100755 --- a/dali-toolkit/internal/controls/text-controls/text-label-impl.h +++ b/dali-toolkit/internal/controls/text-controls/text-label-impl.h @@ -20,6 +20,7 @@ // EXTERNAL INCLUDES #include +#include // INTERNAL INCLUDES #include @@ -119,13 +120,6 @@ private: // from TextScroller */ virtual void ScrollingFinished(); - /** - * @brief Callbacks when the layout direction changes - * @param[in] actor The actor whose layoutDirection is changed. - * @param[in] type The layoutDirection. - */ - void OnLayoutDirectionChanged( Dali::Actor actor, Dali::LayoutDirection::Type type ); - private: // Implementation /** diff --git a/dali-toolkit/internal/text/text-controller.cpp b/dali-toolkit/internal/text/text-controller.cpp index 6a32646..76c7690 100755 --- a/dali-toolkit/internal/text/text-controller.cpp +++ b/dali-toolkit/internal/text/text-controller.cpp @@ -2250,7 +2250,7 @@ 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 +2318,21 @@ 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 + 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 ); @@ -4078,14 +4093,6 @@ bool Controller::ShouldClearFocusOnEscape() const return mImpl->mShouldClearFocusOnEscape; } -void Controller::UpdateLayoutDirectionChanged( Dali::LayoutDirection::Type type ) -{ - mImpl->mLayoutDirection = type; - mImpl->mOperationsPending = static_cast( mImpl->mOperationsPending | - BIDI_INFO ); - mImpl->RequestRelayout(); -} - // private : Private contructors & copy operator. Controller::Controller() diff --git a/dali-toolkit/internal/text/text-controller.h b/dali-toolkit/internal/text/text-controller.h index c3b8375..33f1f8f 100755 --- a/dali-toolkit/internal/text/text-controller.h +++ b/dali-toolkit/internal/text/text-controller.h @@ -1361,11 +1361,6 @@ public: // Text-input Event Queuing. */ bool ShouldClearFocusOnEscape() const; - /** - * @brief UpdateLayoutDirectionChanged - */ - void UpdateLayoutDirectionChanged( Dali::LayoutDirection::Type type ); - protected: // Inherit from Text::Decorator::ControllerInterface. /** -- 2.7.4