X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;ds=sidebyside;f=dali-toolkit%2Finternal%2Ftext%2Ftext-controller.cpp;h=151539c5adc72072c2d56c424b7d5a253c1130d7;hb=206696d4fd84da01100fe43a9360af48c4f6101e;hp=3981ce15b6ceec359d1f43a7224ef0406838bee5;hpb=40a47ee7e802afa836ba45f481b87d0bd28e34fa;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/text/text-controller.cpp b/dali-toolkit/internal/text/text-controller.cpp index 3981ce1..151539c 100644 --- a/dali-toolkit/internal/text/text-controller.cpp +++ b/dali-toolkit/internal/text/text-controller.cpp @@ -109,7 +109,8 @@ struct Controller::TextInput { INACTIVE, SELECTING, - EDITING + EDITING, + EDITING_WITH_POPUP }; TextInput( LogicalModelPtr logicalModel, @@ -123,8 +124,8 @@ struct Controller::TextInput mSecondaryCursorPosition( 0u ), mDecoratorUpdated( false ), mCursorBlinkEnabled( true ), - mGrabHandleEnabled( false ), - mGrabHandlePopupEnabled( false ), + mGrabHandleEnabled( true ), + mGrabHandlePopupEnabled( true ), mSelectionEnabled( false ), mHorizontalScrollingEnabled( true ), mVerticalScrollingEnabled( false ), @@ -323,13 +324,16 @@ struct Controller::TextInput GetClosestCursorPosition( mPrimaryCursorPosition, xPosition, yPosition, height ); mDecorator->SetPosition( PRIMARY_CURSOR, xPosition, yPosition, height ); - mDecorator->HidePopup(); + //mDecorator->HidePopup(); + ChangeState ( EDITING ); mDecoratorUpdated = true; } else if ( mGrabHandlePopupEnabled && GRAB_HANDLE_RELEASED == state ) { - mDecorator->ShowPopup(); + //mDecorator->ShowPopup(); + ChangeState ( EDITING_WITH_POPUP ); + mDecoratorUpdated = true; } } @@ -345,7 +349,7 @@ struct Controller::TextInput mDecorator->StopCursorBlink(); mDecorator->SetGrabHandleActive( false ); mDecorator->SetSelectionActive( false ); - mDecorator->HidePopup(); + mDecorator->SetPopupActive( false ); mDecoratorUpdated = true; } else if ( SELECTING == mState ) @@ -367,6 +371,28 @@ struct Controller::TextInput { mDecorator->SetGrabHandleActive( true ); } + if( mGrabHandlePopupEnabled ) + { + mDecorator->SetPopupActive( false ); + } + mDecorator->SetSelectionActive( false ); + mDecoratorUpdated = true; + } + else if( EDITING_WITH_POPUP == mState ) + { + mDecorator->SetActiveCursor( ACTIVE_CURSOR_PRIMARY ); + if( mCursorBlinkEnabled ) + { + mDecorator->StartCursorBlink(); + } + if( mGrabHandleEnabled ) + { + mDecorator->SetGrabHandleActive( true ); + } + if( mGrabHandlePopupEnabled ) + { + mDecorator->SetPopupActive( true ); + } mDecorator->SetSelectionActive( false ); mDecoratorUpdated = true; } @@ -383,11 +409,11 @@ struct Controller::TextInput totalHeight += lines[lineIndex].lineSize.height; if( y < totalHeight ) { - break; + return lineIndex; } } - return lineIndex; + return lineIndex-1; } void GetClosestCursorPosition( CharacterIndex& logical, float& visualX, float& visualY, float& height ) @@ -483,7 +509,7 @@ struct Controller::TextInput float visualX( 0.0f ); float visualY( 0.0f ); - LineIndex lineIndex( 0u ); + float height( 0.0f ); const Vector& lineRuns = mVisualModel->mLines; if( cursorGlyph > 0 ) @@ -495,17 +521,19 @@ struct Controller::TextInput visualX += mVisualModel->mGlyphs[ cursorGlyph ].width; // Find the line height - for( GlyphIndex lastGlyph = 0; lineIndex < lineRuns.Count(); ++lineIndex ) + GlyphIndex lastGlyph( 0 ); + for( LineIndex lineIndex = 0u; lineIndex < lineRuns.Count(); ++lineIndex ) { lastGlyph = (lineRuns[lineIndex].glyphIndex + lineRuns[lineIndex].numberOfGlyphs); if( cursorGlyph < lastGlyph ) { + height = lineRuns[lineIndex].lineSize.height; break; } } } - mDecorator->SetPosition( PRIMARY_CURSOR, visualX, visualY, lineRuns[lineIndex].lineSize.height ); + mDecorator->SetPosition( PRIMARY_CURSOR, visualX, visualY, height ); mDecoratorUpdated = true; } @@ -677,6 +705,18 @@ void Controller::SetDefaultFontFamily( const std::string& defaultFontFamily ) mImpl->mFontDefaults->mFontId = 0u; // Remove old font ID mImpl->mOperationsPending = ALL_OPERATIONS; mImpl->mRecalculateNaturalSize = true; + + // Clear the font-specific data + mImpl->mLogicalModel->mFontRuns.Clear(); + mImpl->mVisualModel->mGlyphs.Clear(); + mImpl->mVisualModel->mGlyphsToCharacters.Clear(); + mImpl->mVisualModel->mCharactersToGlyph.Clear(); + mImpl->mVisualModel->mCharactersPerGlyph.Clear(); + mImpl->mVisualModel->mGlyphsPerCharacter.Clear(); + mImpl->mVisualModel->mGlyphPositions.Clear(); + mImpl->mVisualModel->mLines.Clear(); + + RequestRelayout(); } const std::string& Controller::GetDefaultFontFamily() const @@ -700,6 +740,18 @@ void Controller::SetDefaultFontStyle( const std::string& defaultFontStyle ) mImpl->mFontDefaults->mFontId = 0u; // Remove old font ID mImpl->mOperationsPending = ALL_OPERATIONS; mImpl->mRecalculateNaturalSize = true; + + // Clear the font-specific data + mImpl->mLogicalModel->mFontRuns.Clear(); + mImpl->mVisualModel->mGlyphs.Clear(); + mImpl->mVisualModel->mGlyphsToCharacters.Clear(); + mImpl->mVisualModel->mCharactersToGlyph.Clear(); + mImpl->mVisualModel->mCharactersPerGlyph.Clear(); + mImpl->mVisualModel->mGlyphsPerCharacter.Clear(); + mImpl->mVisualModel->mGlyphPositions.Clear(); + mImpl->mVisualModel->mLines.Clear(); + + RequestRelayout(); } const std::string& Controller::GetDefaultFontStyle() const @@ -723,6 +775,18 @@ void Controller::SetDefaultPointSize( float pointSize ) mImpl->mFontDefaults->mFontId = 0u; // Remove old font ID mImpl->mOperationsPending = ALL_OPERATIONS; mImpl->mRecalculateNaturalSize = true; + + // Clear the font-specific data + mImpl->mLogicalModel->mFontRuns.Clear(); + mImpl->mVisualModel->mGlyphs.Clear(); + mImpl->mVisualModel->mGlyphsToCharacters.Clear(); + mImpl->mVisualModel->mCharactersToGlyph.Clear(); + mImpl->mVisualModel->mCharactersPerGlyph.Clear(); + mImpl->mVisualModel->mGlyphsPerCharacter.Clear(); + mImpl->mVisualModel->mGlyphPositions.Clear(); + mImpl->mVisualModel->mLines.Clear(); + + RequestRelayout(); } float Controller::GetDefaultPointSize() const @@ -1546,6 +1610,8 @@ bool Controller::KeyEvent( const Dali::KeyEvent& keyEvent ) mImpl->mModifyEvents.push_back( event ); } + mImpl->mTextInput->ChangeState( TextInput::EDITING ); // todo Confirm this is the best place to change the state of + RequestRelayout(); }