[Tizen] code clean up : Relayout again for LTR / RTL order when layout direction is 51/193551/2
authorJoogab Yun <joogab.yun@samsung.com>
Wed, 21 Nov 2018 05:10:41 +0000 (14:10 +0900)
committerJoogab Yun <joogab.yun@samsung.com>
Thu, 22 Nov 2018 09:00:29 +0000 (18:00 +0900)
changed.

Change-Id: Iaf226f4128b6b0a2572eb5af5ae1e9bfcb5e8f96

dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp
dali-toolkit/internal/controls/text-controls/text-editor-impl.h
dali-toolkit/internal/controls/text-controls/text-field-impl.cpp
dali-toolkit/internal/controls/text-controls/text-field-impl.h
dali-toolkit/internal/controls/text-controls/text-label-impl.cpp
dali-toolkit/internal/controls/text-controls/text-label-impl.h
dali-toolkit/internal/text/text-controller.cpp
dali-toolkit/internal/text/text-controller.h

index d125510..7ca679c 100755 (executable)
@@ -1244,11 +1244,10 @@ void TextEditor::OnInitialize()
   mController->SetNoTextLongPressAction( Controller::NoTextTap::HIGHLIGHT );
 
   // Sets layoutDirection value
-  Dali::LayoutDirection::Type layoutDirection = static_cast<Dali::LayoutDirection::Type>( self.GetProperty( Dali::Actor::Property::LAYOUT_DIRECTION ).Get<int>() );
+  Dali::Stage stage = Dali::Stage::GetCurrent();
+  Dali::LayoutDirection::Type layoutDirection = static_cast<Dali::LayoutDirection::Type>( stage.GetRootLayer().GetProperty( Dali::Actor::Property::LAYOUT_DIRECTION ).Get<int>() );
   mController->SetLayoutDirection( layoutDirection );
 
-  self.LayoutDirectionChangedSignal().Connect( this, &TextEditor::OnLayoutDirectionChanged );
-
   // Forward input events to controller
   EnableGestureDetection( static_cast<Gesture::Type>( 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");
index 24a5ddc..d878d66 100755 (executable)
@@ -22,6 +22,7 @@
 #include <dali/devel-api/adaptor-framework/clipboard-event-notifier.h>
 #include <dali/devel-api/adaptor-framework/input-method-context.h>
 #include <dali/public-api/animation/animation.h>
+#include <dali/public-api/common/stage.h>
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/public-api/controls/control-impl.h>
@@ -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();
index cc1df34..2b76083 100755 (executable)
@@ -1304,11 +1304,10 @@ void TextField::OnInitialize()
   mController->SetNoTextLongPressAction( Controller::NoTextTap::HIGHLIGHT );
 
   // Sets layoutDirection value
-  Dali::LayoutDirection::Type layoutDirection = static_cast<Dali::LayoutDirection::Type>( self.GetProperty( Dali::Actor::Property::LAYOUT_DIRECTION ).Get<int>() );
+  Dali::Stage stage = Dali::Stage::GetCurrent();
+  Dali::LayoutDirection::Type layoutDirection = static_cast<Dali::LayoutDirection::Type>( stage.GetRootLayer().GetProperty( Dali::Actor::Property::LAYOUT_DIRECTION ).Get<int>() );
   mController->SetLayoutDirection( layoutDirection );
 
-  self.LayoutDirectionChangedSignal().Connect( this, &TextField::OnLayoutDirectionChanged );
-
   // Forward input events to controller
   EnableGestureDetection( static_cast<Gesture::Type>( 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");
index 7adcb8f..a9a1af6 100755 (executable)
@@ -21,6 +21,7 @@
 // EXTERNAL INCLUDES
 #include <dali/devel-api/adaptor-framework/clipboard-event-notifier.h>
 #include <dali/devel-api/adaptor-framework/input-method-context.h>
+#include <dali/public-api/common/stage.h>
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/public-api/controls/control-impl.h>
@@ -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();
index eddec25..d88b714 100755 (executable)
@@ -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<Dali::LayoutDirection::Type>( self.GetProperty( Dali::Actor::Property::LAYOUT_DIRECTION ).Get<int>() );
+  Dali::Stage stage = Dali::Stage::GetCurrent();
+  Dali::LayoutDirection::Type layoutDirection = static_cast<Dali::LayoutDirection::Type>( stage.GetRootLayer().GetProperty( Dali::Actor::Property::LAYOUT_DIRECTION ).Get<int>() );
   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");
index b9f3bf8..b94f70f 100755 (executable)
@@ -20,6 +20,7 @@
 
 // EXTERNAL INCLUDES
 #include <dali/public-api/object/property-map.h>
+#include <dali/public-api/common/stage.h>
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/public-api/controls/control-impl.h>
@@ -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
 
   /**
index 6a32646..76c7690 100755 (executable)
@@ -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<OperationsMask>( 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<OperationsMask>( mImpl->mOperationsPending |
-                                                                           BIDI_INFO );
-  mImpl->RequestRelayout();
-}
-
 // private : Private contructors & copy operator.
 
 Controller::Controller()
index c3b8375..33f1f8f 100755 (executable)
@@ -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.
 
   /**