GetNaturalSize() to restore ControlSize after relayouting, Scrolling Gap from float... 87/69987/2
authorAgnelo Vaz <agnelo.vaz@samsung.com>
Tue, 17 May 2016 13:07:00 +0000 (14:07 +0100)
committerAgnelo Vaz <agnelo.vaz@samsung.com>
Tue, 17 May 2016 13:40:45 +0000 (14:40 +0100)
GetNaturalSize was changing the controlSize to MAX_FLOAT before relayout but only restoring the control width, now does height too.
Gap for AutoScrolling changed from float to int, don't want less than a pixel.

Change-Id: I0c1c391e5565eee8b45d4f28492129d1211d8de8

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

index 6a39ee7..32afaf0 100644 (file)
@@ -681,12 +681,13 @@ void TextLabel::RenderText()
 
 void TextLabel::SetUpAutoScrolling()
 {
-  const Size& controlSize = mController->GetView().GetControlSize(); // Needs to be a ref as the control-size can be changed by GetNaturalSize()
+  const Size& controlSize = mController->GetView().GetControlSize();
   const Size offScreenSize = GetNaturalSize().GetVectorXY(); // As relayout of text may not be done at this point natural size is used to get size. Single line scrolling only.
   const Vector2& alignmentOffset = mController->GetAlignmentOffset();
   const Text::CharacterDirection direction = mController->GetAutoScrollDirection();
 
-  DALI_LOG_INFO( gLogFilter, Debug::General, "TextLabel::SetUpAutoScrolling alignmentOffset[%f] offScreenSize[%f]\n", alignmentOffset.x, offScreenSize.width);
+  DALI_LOG_INFO( gLogFilter, Debug::General, "TextLabel::SetUpAutoScrolling alignmentOffset[%f,%f] offScreenSize[%f,%f] controlSize[%f,%f]\n",
+                 alignmentOffset.x, alignmentOffset.y, offScreenSize.x,offScreenSize.y , controlSize.x,controlSize.y);
 
   if ( !mTextScroller )
   {
index 36c293e..268519b 100644 (file)
@@ -1112,8 +1112,8 @@ Vector3 Controller::GetNaturalSize()
     mImpl->mTextUpdateInfo.mParagraphCharacterIndex = 0u;
     mImpl->mTextUpdateInfo.mRequestedNumberOfCharacters = mImpl->mLogicalModel->mText.Count();
 
-    // Store the actual control's width.
-    const float actualControlWidth = mImpl->mVisualModel->mControlSize.width;
+    // Store the actual control's size to restore later.
+    const Size actualControlSize = mImpl->mVisualModel->mControlSize;
 
     DoRelayout( Size( MAX_FLOAT, MAX_FLOAT ),
                 static_cast<OperationsMask>( onlyOnceOperations |
@@ -1138,8 +1138,8 @@ Vector3 Controller::GetNaturalSize()
     // Clear the update info. This info will be set the next time the text is updated.
     mImpl->mTextUpdateInfo.Clear();
 
-    // Restore the actual control's width.
-    mImpl->mVisualModel->mControlSize.width = actualControlWidth;
+    // Restore the actual control's size.
+    mImpl->mVisualModel->mControlSize = actualControlSize;
 
     DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::GetNaturalSize calculated %f,%f,%f\n", naturalSize.x, naturalSize.y, naturalSize.z );
   }
index 5b7b99b..a8180fc 100644 (file)
@@ -194,13 +194,13 @@ TextScrollerPtr TextScroller::New( ScrollerInterface& scrollerInterface )
   return textScroller;
 }
 
-void TextScroller::SetGap( float gap )
+void TextScroller::SetGap( int gap )
 {
-  DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextScroller::SetGap gap[%f]\n", gap );
+  DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextScroller::SetGap gap[%d]\n", gap );
   mWrapGap = gap;
 }
 
-float TextScroller::GetGap() const
+int TextScroller::GetGap() const
 {
   return mWrapGap;
 }
@@ -252,7 +252,7 @@ TextScroller::TextScroller( ScrollerInterface& scrollerInterface ) : mScrollerIn
                             mScrollDeltaIndex( Property::INVALID_INDEX ),
                             mScrollSpeed( MINIMUM_SCROLL_SPEED ),
                             mLoopCount( 1 ),
-                            mWrapGap( 0.0f )
+                            mWrapGap( 0 )
 {
   DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextScroller Default Constructor\n" );
 }
@@ -286,7 +286,7 @@ void TextScroller::SetParameters( Actor sourceActor, const Size& controlSize, co
 
   mOffscreenCameraActor.SetY( offScreenSize.height * 0.5f );
 
-  DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextScroller::SetParameters mWrapGap[%f]\n", mWrapGap )
+  DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextScroller::SetParameters mWrapGap[%d]\n", mWrapGap )
 
   mScrollingTextActor = Actor::New();
   mScrollingTextActor.AddRenderer( renderer );
index aefecdf..d4f92b9 100644 (file)
@@ -71,13 +71,13 @@ public:
    * @brief Set the gap distance to elapse before the text wraps around
    * @param[in] gap distance to elapse
    */
-  void SetGap( float gap );
+  void SetGap( int gap );
 
   /**
-   * @brief Get the distance before scrolling waps
+   * @brief Get the distance before scrolling wraps
    * @return gap distance to elapse
    */
-  float GetGap() const;
+  int GetGap() const;
 
   /**
    * @brief Set speed the text should scroll
@@ -161,9 +161,9 @@ private:
   Property::Index    mScrollDeltaIndex;         // Property used by shader to represent distance to scroll
   Animation          mScrollAnimation;          // Animation used to update the mScrollDeltaIndex
 
-  int   mScrollSpeed;            ///< Speed which text should automatically scroll at
-  int   mLoopCount;              ///< Number of time the text should scroll
-  float mWrapGap;                ///< Gap before text wraps around when scrolling
+  int mScrollSpeed;            ///< Speed which text should automatically scroll at
+  int mLoopCount;              ///< Number of time the text should scroll
+  int mWrapGap;                ///< Gap before text wraps around when scrolling
 
 }; // TextScroller class