X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;ds=sidebyside;f=base%2Fdali-toolkit%2Finternal%2Fcontrols%2Ftext-input%2Ftext-input-text-highlight-impl.cpp;h=7475678f0e34e12769839c9840727ad083ec2eae;hb=b8c93847cc736bfc69876fd087ab06474fbfbe47;hp=90a799d860f435663a2f0fd235d605bda237b405;hpb=680c5587a1478717393d3a03cf6a17801edd00e0;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/base/dali-toolkit/internal/controls/text-input/text-input-text-highlight-impl.cpp b/base/dali-toolkit/internal/controls/text-input/text-input-text-highlight-impl.cpp index 90a799d..7475678 100644 --- a/base/dali-toolkit/internal/controls/text-input/text-input-text-highlight-impl.cpp +++ b/base/dali-toolkit/internal/controls/text-input/text-input-text-highlight-impl.cpp @@ -28,7 +28,6 @@ // INTERNAL INCLUDES using namespace Dali; -using namespace std; namespace { @@ -101,7 +100,6 @@ void TextHighlight::GetVisualTextSelection(std::vector& selectedVisualText TextHighlight::HighlightInfo TextHighlight::CalculateHighlightInfo( std::size_t handlePositionStart, std::size_t handlePositionEnd, Toolkit::TextView::TextLayoutInfo& textLayoutInfo ) { // At the moment there is no public API to modify the block alignment option. - const bool blockAlignEnabled = true; TextHighlight::HighlightInfo newHighlightInfo; //newHighlightInfo.mQuadList.clear(); // clear last quad information. @@ -171,7 +169,7 @@ TextHighlight::HighlightInfo TextHighlight::CalculateHighlightInfo( std::size_t float rowTop = rowBottom - rowSize.height; // Still selected, and block-align mode then set rowRight to max, so it can be clamped afterwards - if(charSelected && blockAlignEnabled) + if(charSelected) { rowRight = std::numeric_limits::max(); } @@ -183,7 +181,7 @@ TextHighlight::HighlightInfo TextHighlight::CalculateHighlightInfo( std::size_t if( charSelected ) { // if block-align mode then set rowLeft to min, so it can be clamped afterwards - rowLeft = blockAlignEnabled ? 0.0f : charInfo.mPosition.x - textLayoutInfo.mScrollOffset.x; + rowLeft = 0.0f; rowRight = ( charInfo.mPosition.x - textLayoutInfo.mScrollOffset.x ) + charInfo.mSize.width; selectionState = SelectionStarted; } @@ -206,16 +204,19 @@ TextHighlight::HighlightInfo TextHighlight::CalculateHighlightInfo( std::size_t { // finished selection. Vector2 min, max; - if(lastIt->mIsNewParagraphChar) + if(lastIt != end && lastIt->mIsNewParagraphChar) { lastIt = std::max( textLayoutInfo.mCharacterLayoutInfoTable.begin(), lastIt - 1 ); } - const Size rowSize( mTextViewCharacterPositioning.GetRowRectFromCharacterPosition( lastIt - textLayoutInfo.mCharacterLayoutInfoTable.begin(), min, max ) ); - maxRowLeft = std::min(maxRowLeft, min.x); - maxRowRight = std::max(maxRowRight, max.x); - float rowBottom = lastIt->mPosition.y - textLayoutInfo.mScrollOffset.y; - float rowTop = rowBottom - rowSize.height; - newHighlightInfo.AddQuad( rowLeft, rowTop, rowRight, rowBottom ); + if( lastIt != end ) + { + const Size rowSize( mTextViewCharacterPositioning.GetRowRectFromCharacterPosition( lastIt - textLayoutInfo.mCharacterLayoutInfoTable.begin(), min, max ) ); + maxRowLeft = std::min(maxRowLeft, min.x); + maxRowRight = std::max(maxRowRight, max.x); + float rowBottom = lastIt->mPosition.y - textLayoutInfo.mScrollOffset.y; + float rowTop = rowBottom - rowSize.height; + newHighlightInfo.AddQuad( rowLeft, rowTop, rowRight, rowBottom ); + } } } @@ -228,8 +229,6 @@ TextHighlight::HighlightInfo TextHighlight::CalculateHighlightInfo( std::size_t newHighlightInfo.Clamp2D( topLeft, bottomRight ); // For block-align align Further Clamp quads to max left and right extents - if(blockAlignEnabled) - { // BlockAlign: Will adjust highlight to block: // i.e. // H[ello] (top row right = max of all rows right) @@ -244,9 +243,8 @@ TextHighlight::HighlightInfo TextHighlight::CalculateHighlightInfo( std::size_t // [is some] // [text] // (common in regular text editors/web browser selection) - newHighlightInfo.Clamp2D( Vector2(maxRowLeft, topLeft.y), Vector2(maxRowRight, bottomRight.y ) ); - } + } return newHighlightInfo;