From 348f6480ca53f0a1c869d2da077ee3b5e3e405eb Mon Sep 17 00:00:00 2001 From: Agnelo Vaz Date: Tue, 17 May 2016 14:07:00 +0100 Subject: [PATCH 1/1] GetNaturalSize() to restore ControlSize after relayouting, Scrolling Gap from float to int 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 --- .../internal/controls/text-controls/text-label-impl.cpp | 5 +++-- dali-toolkit/internal/text/text-controller.cpp | 8 ++++---- dali-toolkit/internal/text/text-scroller.cpp | 10 +++++----- dali-toolkit/internal/text/text-scroller.h | 12 ++++++------ 4 files changed, 18 insertions(+), 17 deletions(-) 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 6a39ee7..32afaf0 100644 --- a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp @@ -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 ) { diff --git a/dali-toolkit/internal/text/text-controller.cpp b/dali-toolkit/internal/text/text-controller.cpp index 36c293e..268519b 100644 --- a/dali-toolkit/internal/text/text-controller.cpp +++ b/dali-toolkit/internal/text/text-controller.cpp @@ -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( 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 ); } diff --git a/dali-toolkit/internal/text/text-scroller.cpp b/dali-toolkit/internal/text/text-scroller.cpp index 5b7b99b..a8180fc 100644 --- a/dali-toolkit/internal/text/text-scroller.cpp +++ b/dali-toolkit/internal/text/text-scroller.cpp @@ -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 ); diff --git a/dali-toolkit/internal/text/text-scroller.h b/dali-toolkit/internal/text/text-scroller.h index aefecdf..d4f92b9 100644 --- a/dali-toolkit/internal/text/text-scroller.h +++ b/dali-toolkit/internal/text/text-scroller.h @@ -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 -- 2.7.4