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-impl.cpp;h=bfce755af9e735aba1ff8c859ca1688bc7c864cc;hp=c39d5e85d94313ed43b191f64fde4b7dab732a88;hb=d3a888997fb0ab17fc994eed2854bcad8be32623;hpb=590ede8c5f4771821ff5ac3f3acef0d189525008 diff --git a/dali-toolkit/internal/text/text-controller-impl.cpp b/dali-toolkit/internal/text/text-controller-impl.cpp old mode 100755 new mode 100644 index c39d5e8..bfce755 --- a/dali-toolkit/internal/text/text-controller-impl.cpp +++ b/dali-toolkit/internal/text/text-controller-impl.cpp @@ -159,7 +159,8 @@ EventData::EventData( DecoratorPtr decorator, InputMethodContext& inputMethodCon mIsPlaceholderElideEnabled( false ), mPlaceholderEllipsisFlag( false ), mShiftSelectionFlag( true ), - mUpdateAlignment( false ) + mUpdateAlignment( false ), + mEditingEnabled( true ) { } @@ -221,6 +222,11 @@ bool Controller::Impl::ProcessInputEvents() OnSelectAllEvent(); break; } + case Event::SELECT_NONE: + { + OnSelectNoneEvent(); + break; + } } } } @@ -1086,16 +1092,16 @@ bool Controller::Impl::UpdateModel( OperationsMask operationsRequired ) mEventData->mPreEditFlag && ( 0u != mModel->mVisualModel->mCharactersToGlyph.Count() ) ) { - Vector< Dali::InputMethodContext::PreeditAttributeData > attrs; + Dali::InputMethodContext::PreEditAttributeDataContainer attrs; mEventData->mInputMethodContext.GetPreeditStyle( attrs ); Dali::InputMethodContext::PreeditStyle type = Dali::InputMethodContext::PreeditStyle::NONE; // Check the type of preedit and run it. - for( Vector::Iterator it = attrs.Begin(), endIt = attrs.End(); it != endIt; it++ ) + for( Dali::InputMethodContext::PreEditAttributeDataContainer::Iterator it = attrs.Begin(), endIt = attrs.End(); it != endIt; it++ ) { Dali::InputMethodContext::PreeditAttributeData attrData = *it; DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::UpdateModel PreeditStyle type : %d start %d end %d \n", attrData.preeditType, attrData.startIndex, attrData.endIndex ); - type = attrData.preeditType; + type = attrData.preeditType; // Check the number of commit characters for the start position. unsigned int numberOfCommit = mEventData->mPrimaryCursorPosition - mEventData->mPreEditLength; @@ -1108,7 +1114,7 @@ bool Controller::Impl::UpdateModel( OperationsMask operationsRequired ) // Add the underline for the pre-edit text. GlyphRun underlineRun; underlineRun.glyphIndex = attrData.startIndex + numberOfCommit; - underlineRun.numberOfGlyphs = attrData.endIndex - attrData.startIndex; + underlineRun.numberOfGlyphs = numberOfIndices; mModel->mVisualModel->mUnderlineRuns.PushBack( underlineRun ); break; } @@ -1152,7 +1158,7 @@ bool Controller::Impl::UpdateModel( OperationsMask operationsRequired ) GlyphRun underlineRun; underlineRun.glyphIndex = attrData.startIndex + numberOfCommit; - underlineRun.numberOfGlyphs = attrData.endIndex - attrData.startIndex; + underlineRun.numberOfGlyphs = numberOfIndices; mModel->mVisualModel->mUnderlineRuns.PushBack( underlineRun ); break; } @@ -1167,7 +1173,7 @@ bool Controller::Impl::UpdateModel( OperationsMask operationsRequired ) GlyphRun underlineRun; underlineRun.glyphIndex = attrData.startIndex + numberOfCommit; - underlineRun.numberOfGlyphs = attrData.endIndex - attrData.startIndex; + underlineRun.numberOfGlyphs = numberOfIndices; mModel->mVisualModel->mUnderlineRuns.PushBack( underlineRun ); break; } @@ -1182,7 +1188,7 @@ bool Controller::Impl::UpdateModel( OperationsMask operationsRequired ) GlyphRun underlineRun; underlineRun.glyphIndex = attrData.startIndex + numberOfCommit; - underlineRun.numberOfGlyphs = attrData.endIndex - attrData.startIndex; + underlineRun.numberOfGlyphs = numberOfIndices; mModel->mVisualModel->mUnderlineRuns.PushBack( underlineRun ); break; } @@ -1197,7 +1203,7 @@ bool Controller::Impl::UpdateModel( OperationsMask operationsRequired ) GlyphRun underlineRun; underlineRun.glyphIndex = attrData.startIndex + numberOfCommit; - underlineRun.numberOfGlyphs = attrData.endIndex - attrData.startIndex; + underlineRun.numberOfGlyphs = numberOfIndices; mModel->mVisualModel->mUnderlineRuns.PushBack( underlineRun ); break; } @@ -1596,17 +1602,16 @@ void Controller::Impl::OnPanEvent( const Event& event ) return; } - const int state = event.p1.mInt; - + const GestureState state = static_cast( event.p1.mInt ); switch( state ) { - case Gesture::Started: + case GestureState::STARTED: { // Will remove the cursor, handles or text's popup, ... ChangeState( EventData::TEXT_PANNING ); break; } - case Gesture::Continuing: + case GestureState::CONTINUING: { const Vector2& layoutSize = mModel->mVisualModel->GetLayoutSize(); const Vector2 currentScroll = mModel->mScrollPosition; @@ -1630,8 +1635,8 @@ void Controller::Impl::OnPanEvent( const Event& event ) mEventData->mDecorator->UpdatePositions( mModel->mScrollPosition - currentScroll ); break; } - case Gesture::Finished: - case Gesture::Cancelled: // FALLTHROUGH + case GestureState::FINISHED: + case GestureState::CANCELLED: // FALLTHROUGH { // Will go back to the previous state to show the cursor, handles, the text's popup, ... ChangeState( mEventData->mPreviousState ); @@ -2015,6 +2020,88 @@ void Controller::Impl::OnSelectAllEvent() } } +void Controller::Impl::OnSelectNoneEvent() +{ + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "OnSelectNoneEvent mEventData->mSelectionEnabled%s \n", mEventData->mSelectionEnabled?"true":"false"); + + if( NULL == mEventData ) + { + // Nothing to do if there is no text. + return; + } + + if( mEventData->mSelectionEnabled && mEventData->mState == EventData::SELECTING) + { + mEventData->mPrimaryCursorPosition = 0u; + mEventData->mLeftSelectionPosition = mEventData->mRightSelectionPosition = mEventData->mPrimaryCursorPosition; + ChangeState( EventData::INACTIVE ); + mEventData->mUpdateCursorPosition = true; + mEventData->mUpdateInputStyle = true; + mEventData->mScrollAfterUpdatePosition = true; + } +} + +void Controller::Impl::SetTextSelectionRange(const uint32_t *pStart, const uint32_t *pEnd) +{ + if( nullptr == mEventData ) + { + // Nothing to do if there is no text. + return; + } + + if( mEventData->mSelectionEnabled && (pStart || pEnd)) + { + uint32_t length = static_cast(mModel->mLogicalModel->mText.Count()); + + if (pStart) + { + mEventData->mLeftSelectionPosition = std::min(*pStart, length); + } + if (pEnd) + { + mEventData->mRightSelectionPosition = std::min(*pEnd, length); + } + + if (mEventData->mLeftSelectionPosition == mEventData->mRightSelectionPosition) + { + ChangeState( EventData::EDITING ); + mEventData->mPrimaryCursorPosition = mEventData->mLeftSelectionPosition = mEventData->mRightSelectionPosition; + mEventData->mUpdateCursorPosition = true; + } + else + { + ChangeState( EventData::SELECTING ); + mEventData->mUpdateHighlightBox = true; + } + } +} + +Uint32Pair Controller::Impl::GetTextSelectionRange() const +{ + Uint32Pair range; + + if( mEventData ) + { + range.first = mEventData->mLeftSelectionPosition; + range.second = mEventData->mRightSelectionPosition; + } + + return range; +} + +bool Controller::Impl::IsEditable() const +{ + return mEventData && mEventData->mEditingEnabled; +} + +void Controller::Impl::SetEditable( bool editable ) +{ + if( mEventData) + { + mEventData->mEditingEnabled = editable; + } +} + void Controller::Impl::RetrieveSelection( std::string& selectedText, bool deleteAfterRetrieval ) { if( mEventData->mLeftSelectionPosition == mEventData->mRightSelectionPosition ) @@ -2620,15 +2707,23 @@ void Controller::Impl::SetPopupButtons() * If EDITING_WITH_POPUP : SELECT & SELECT_ALL */ + bool isEditable = IsEditable(); TextSelectionPopup::Buttons buttonsToShow = TextSelectionPopup::NONE; if( EventData::SELECTING == mEventData->mState ) { - buttonsToShow = TextSelectionPopup::Buttons( TextSelectionPopup::CUT | TextSelectionPopup::COPY ); + buttonsToShow = TextSelectionPopup::Buttons( TextSelectionPopup::COPY ); + if(isEditable) + { + buttonsToShow = TextSelectionPopup::Buttons( buttonsToShow | TextSelectionPopup::CUT ); + } if( !IsClipboardEmpty() ) { - buttonsToShow = TextSelectionPopup::Buttons ( ( buttonsToShow | TextSelectionPopup::PASTE ) ); + if(isEditable) + { + buttonsToShow = TextSelectionPopup::Buttons ( ( buttonsToShow | TextSelectionPopup::PASTE ) ); + } buttonsToShow = TextSelectionPopup::Buttons ( ( buttonsToShow | TextSelectionPopup::CLIPBOARD ) ); } @@ -2646,7 +2741,10 @@ void Controller::Impl::SetPopupButtons() if( !IsClipboardEmpty() ) { - buttonsToShow = TextSelectionPopup::Buttons ( ( buttonsToShow | TextSelectionPopup::PASTE ) ); + if(isEditable) + { + buttonsToShow = TextSelectionPopup::Buttons ( ( buttonsToShow | TextSelectionPopup::PASTE ) ); + } buttonsToShow = TextSelectionPopup::Buttons ( ( buttonsToShow | TextSelectionPopup::CLIPBOARD ) ); } } @@ -2654,7 +2752,10 @@ void Controller::Impl::SetPopupButtons() { if ( !IsClipboardEmpty() ) { - buttonsToShow = TextSelectionPopup::Buttons ( ( buttonsToShow | TextSelectionPopup::PASTE ) ); + if(isEditable) + { + buttonsToShow = TextSelectionPopup::Buttons ( ( buttonsToShow | TextSelectionPopup::PASTE ) ); + } buttonsToShow = TextSelectionPopup::Buttons ( ( buttonsToShow | TextSelectionPopup::CLIPBOARD ) ); } } @@ -3359,7 +3460,7 @@ Actor Controller::Impl::CreateBackgroundActor() quadVertexFormat[ "aPosition" ] = Property::VECTOR2; quadVertexFormat[ "aColor" ] = Property::VECTOR4; - PropertyBuffer quadVertices = PropertyBuffer::New( quadVertexFormat ); + VertexBuffer quadVertices = VertexBuffer::New( quadVertexFormat ); quadVertices.SetData( &mesh.mVertices[ 0 ], mesh.mVertices.Size() ); Geometry quadGeometry = Geometry::New(); @@ -3376,11 +3477,11 @@ Actor Controller::Impl::CreateBackgroundActor() renderer.SetProperty( Dali::Renderer::Property::DEPTH_INDEX, DepthIndex::CONTENT ); actor = Actor::New(); - actor.SetName( "TextBackgroundColorActor" ); - actor.SetParentOrigin( ParentOrigin::TOP_LEFT ); - actor.SetAnchorPoint( AnchorPoint::TOP_LEFT ); - actor.SetSize( textSize ); - actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR ); + actor.SetProperty( Dali::Actor::Property::NAME, "TextBackgroundColorActor" ); + actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT ); + actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT ); + actor.SetProperty( Actor::Property::SIZE, textSize ); + actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR ); actor.AddRenderer( renderer ); } }