From 7a468f3e7d88baee85125d11e8f02e1f24b273d3 Mon Sep 17 00:00:00 2001 From: Joogab Yun Date: Sat, 17 Nov 2018 08:39:06 +0900 Subject: [PATCH] [Tizen] Relayout again for LTR / RTL order when layout direction is changed. Change-Id: Idf8e74af65e29bbc6d5ade7860ac7795ce31c446 --- dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp | 7 +++++++ dali-toolkit/internal/controls/text-controls/text-editor-impl.h | 7 +++++++ dali-toolkit/internal/controls/text-controls/text-field-impl.cpp | 7 +++++++ dali-toolkit/internal/controls/text-controls/text-field-impl.h | 7 +++++++ dali-toolkit/internal/controls/text-controls/text-label-impl.cpp | 7 +++++++ dali-toolkit/internal/controls/text-controls/text-label-impl.h | 7 +++++++ dali-toolkit/internal/text/text-controller.cpp | 8 ++++++++ dali-toolkit/internal/text/text-controller.h | 5 +++++ 8 files changed, 55 insertions(+) mode change 100644 => 100755 dali-toolkit/internal/controls/text-controls/text-label-impl.h 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..d125510 100755 --- a/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp @@ -1247,6 +1247,8 @@ void TextEditor::OnInitialize() Dali::LayoutDirection::Type layoutDirection = static_cast( self.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 ); @@ -1293,6 +1295,11 @@ 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 5595e18..24a5ddc 100755 --- a/dali-toolkit/internal/controls/text-controls/text-editor-impl.h +++ b/dali-toolkit/internal/controls/text-controls/text-editor-impl.h @@ -261,6 +261,13 @@ 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 655c335..cc1df34 100755 --- a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp @@ -1307,6 +1307,8 @@ void TextField::OnInitialize() Dali::LayoutDirection::Type layoutDirection = static_cast( self.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 ); @@ -1339,6 +1341,11 @@ 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 495f789..7adcb8f 100755 --- a/dali-toolkit/internal/controls/text-controls/text-field-impl.h +++ b/dali-toolkit/internal/controls/text-controls/text-field-impl.h @@ -242,6 +242,13 @@ 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 376709a..eddec25 100755 --- a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp @@ -888,10 +888,17 @@ void TextLabel::OnInitialize() Dali::LayoutDirection::Type layoutDirection = static_cast( self.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 old mode 100644 new mode 100755 index 85e94ab..b9f3bf8 --- a/dali-toolkit/internal/controls/text-controls/text-label-impl.h +++ b/dali-toolkit/internal/controls/text-controls/text-label-impl.h @@ -119,6 +119,13 @@ 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 5d0543c..51d8059 100755 --- a/dali-toolkit/internal/text/text-controller.cpp +++ b/dali-toolkit/internal/text/text-controller.cpp @@ -4077,6 +4077,14 @@ 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 33f1f8f..c3b8375 100755 --- a/dali-toolkit/internal/text/text-controller.h +++ b/dali-toolkit/internal/text/text-controller.h @@ -1361,6 +1361,11 @@ 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