X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftext%2Ftext-controller.cpp;h=4cc9d900713b9c3d72a9ec91fe0b3e70d7a3115d;hp=482cfc32a8d052bdac2bf35b7c4974d60d7b3f8c;hb=6bc33c55ece7fc30d8229f35e6e9f8b807a9a437;hpb=8ab2d332de0eb2854d47b7729cd5ec25b73a1d06 diff --git a/dali-toolkit/internal/text/text-controller.cpp b/dali-toolkit/internal/text/text-controller.cpp index 482cfc3..4cc9d90 100755 --- a/dali-toolkit/internal/text/text-controller.cpp +++ b/dali-toolkit/internal/text/text-controller.cpp @@ -54,6 +54,7 @@ const char * const PLACEHOLDER_FONT_FAMILY = "placeholderFontFamily"; const char * const PLACEHOLDER_FONT_STYLE = "placeholderFontStyle"; const char * const PLACEHOLDER_POINT_SIZE = "placeholderPointSize"; const char * const PLACEHOLDER_PIXEL_SIZE = "placeholderPixelSize"; +const char * const PLACEHOLDER_ELLIPSIS = "placeholderEllipsis"; float ConvertToEven( float value ) { @@ -430,6 +431,24 @@ bool Controller::IsTextElideEnabled() const return mImpl->mModel->mElideEnabled; } +void Controller::SetPlaceholderTextElideEnabled( bool enabled ) +{ + mImpl->mEventData->mIsPlaceholderElideEnabled = enabled; + mImpl->mEventData->mPlaceholderEllipsisFlag = true; + + // Update placeholder if there is no text + if( mImpl->IsShowingPlaceholderText() || + ( 0u == mImpl->mModel->mLogicalModel->mText.Count() ) ) + { + ShowPlaceholderText(); + } +} + +bool Controller::IsPlaceholderTextElideEnabled() const +{ + return mImpl->mEventData->mIsPlaceholderElideEnabled; +} + void Controller::SetSelectionEnabled( bool enabled ) { mImpl->mEventData->mSelectionEnabled = enabled; @@ -2006,6 +2025,12 @@ void Controller::SetPlaceholderProperty( const Property::Map& map ) SetPlaceholderTextFontSize( pixelSize, Text::Controller::PIXEL_SIZE ); } } + else if( key == PLACEHOLDER_ELLIPSIS ) + { + bool ellipsis; + value.Get( ellipsis ); + SetPlaceholderTextElideEnabled( ellipsis ); + } } } @@ -2038,6 +2063,11 @@ void Controller::GetPlaceholderProperty( Property::Map& map ) { map[ PLACEHOLDER_PIXEL_SIZE ] = GetPlaceholderTextFontSize( Text::Controller::PIXEL_SIZE ); } + + if( mImpl->mEventData->mPlaceholderEllipsisFlag ) + { + map[ PLACEHOLDER_ELLIPSIS ] = IsPlaceholderTextElideEnabled(); + } } } @@ -2095,6 +2125,20 @@ Controller::UpdateTextType Controller::Relayout( const Size& size ) COLOR ); } + // Set the update info to elide the text. + if( mImpl->mModel->mElideEnabled || + ( ( NULL != mImpl->mEventData ) && mImpl->mEventData->mIsPlaceholderElideEnabled ) ) + { + // Update Text layout for applying elided + mImpl->mOperationsPending = static_cast( mImpl->mOperationsPending | + ALIGN | + LAYOUT | + UPDATE_LAYOUT_SIZE | + REORDER ); + mImpl->mTextUpdateInfo.mFullRelayoutNeeded = true; + mImpl->mTextUpdateInfo.mCharacterIndex = 0u; + } + // Make sure the model is up-to-date before layouting. ProcessModifyEvents(); bool updated = mImpl->UpdateModel( mImpl->mOperationsPending ); @@ -3279,13 +3323,35 @@ bool Controller::DoRelayout( const Size& size, layoutParameters.startLineIndex = mImpl->mTextUpdateInfo.mStartLineIndex; layoutParameters.estimatedNumberOfLines = mImpl->mTextUpdateInfo.mEstimatedNumberOfLines; + // Update the ellipsis + bool elideTextEnabled = mImpl->mModel->mElideEnabled; + + if( NULL != mImpl->mEventData ) + { + if( mImpl->mEventData->mPlaceholderEllipsisFlag && mImpl->IsShowingPlaceholderText() ) + { + elideTextEnabled = mImpl->mEventData->mIsPlaceholderElideEnabled; + } + else if( EventData::INACTIVE != mImpl->mEventData->mState ) + { + // Disable ellipsis when editing + elideTextEnabled = false; + } + + // Reset the scroll position in inactive state + if( elideTextEnabled && ( mImpl->mEventData->mState == EventData::INACTIVE ) ) + { + ResetScrollPosition(); + } + } + // Update the visual model. Size newLayoutSize; viewUpdated = mImpl->mLayoutEngine.LayoutText( layoutParameters, glyphPositions, mImpl->mModel->mVisualModel->mLines, newLayoutSize, - mImpl->mModel->mElideEnabled ); + elideTextEnabled ); viewUpdated = viewUpdated || ( newLayoutSize != layoutSize );