X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Ftext-controls%2Ftext-editor-impl.cpp;h=469ea3e61f319d982cf97e47fdf0be8bee5c1ddd;hb=c8992f93caecf9a341baa7343e81b5e147508634;hp=aab4f959944a1973c1ddaf807ed8dd55a547749b;hpb=e65245a8ddc5d1fe018b4f890c6927974955e2a7;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp index aab4f95..469ea3e 100644 --- a/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -33,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -122,6 +124,8 @@ DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "emboss", DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "inputEmboss", MAP, INPUT_EMBOSS ) DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "outline", MAP, OUTLINE ) DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "inputOutline", MAP, INPUT_OUTLINE ) +DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "smoothScroll", BOOLEAN, SMOOTH_SCROLL ) +DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "smoothScrollDuration", FLOAT, SMOOTH_SCROLL_DURATION ) DALI_SIGNAL_REGISTRATION( Toolkit, TextEditor, "textChanged", SIGNAL_TEXT_CHANGED ) DALI_SIGNAL_REGISTRATION( Toolkit, TextEditor, "inputStyleChanged", SIGNAL_INPUT_STYLE_CHANGED ) @@ -590,6 +594,26 @@ void TextEditor::SetProperty( BaseObject* object, Property::Index index, const P } break; } + case Toolkit::DevelTextEditor::Property::SMOOTH_SCROLL: + { + const bool enable = value.Get< bool >(); + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor SMOOTH_SCROLL %d\n", enable ); + + impl.mScrollAnimationEnabled = enable; + break; + } + case Toolkit::DevelTextEditor::Property::SMOOTH_SCROLL_DURATION: + { + const float duration = value.Get< float >(); + DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor SMOOTH_SCROLL_DURATION %f\n", duration ); + + impl.mScrollAnimationDuration = duration; + if ( impl.mTextVerticalScroller ) + { + impl.mTextVerticalScroller->SetDuration( duration ); + } + break; + } } // switch } // texteditor } @@ -891,6 +915,16 @@ Property::Value TextEditor::GetProperty( BaseObject* object, Property::Index ind GetOutlineProperties( impl.mController, value, Text::EffectStyle::INPUT ); break; } + case Toolkit::DevelTextEditor::Property::SMOOTH_SCROLL: + { + value = impl.mScrollAnimationEnabled; + break; + } + case Toolkit::DevelTextEditor::Property::SMOOTH_SCROLL_DURATION: + { + value = impl.mScrollAnimationDuration; + break; + } } //switch } @@ -1094,7 +1128,7 @@ void TextEditor::RenderText( Text::Controller::UpdateTextType updateTextType ) { renderableActor = mRenderer->Render( mController->GetView(), mAlignmentOffset, - DepthIndex::TEXT ); + DepthIndex::CONTENT ); } if( renderableActor != mRenderableActor ) @@ -1106,10 +1140,6 @@ void TextEditor::RenderText( Text::Controller::UpdateTextType updateTextType ) if( mRenderableActor ) { - const Vector2& scrollOffset = mController->GetTextModel()->GetScrollPosition(); - - mRenderableActor.SetPosition( scrollOffset.x + mAlignmentOffset, scrollOffset.y ); - // Make sure the actors are parented correctly with/without clipping Actor self = mStencil ? mStencil : Self(); @@ -1123,6 +1153,8 @@ void TextEditor::RenderText( Text::Controller::UpdateTextType updateTextType ) mClippingDecorationActors.clear(); self.Add( mRenderableActor ); + + ApplyScrollPosition(); } } @@ -1227,7 +1259,12 @@ bool TextEditor::OnKeyEvent( const KeyEvent& event ) if( Dali::DALI_KEY_ESCAPE == event.keyCode ) // Make a Dali key code for this { - ClearKeyInputFocus(); + // Make sure ClearKeyInputFocus when only key is up + if( event.state == KeyEvent::Up ) + { + ClearKeyInputFocus(); + } + return true; } @@ -1397,12 +1434,42 @@ void TextEditor::OnIdleSignal() mIdleCallback = NULL; } +void TextEditor::ApplyScrollPosition() +{ + const Vector2& scrollOffset = mController->GetTextModel()->GetScrollPosition(); + float scrollAmount = 0.0f; + + if ( mScrollAnimationEnabled ) + { + scrollAmount = mController->GetScrollAmountByUserInput(); + } + if ( mTextVerticalScroller ) + { + mTextVerticalScroller->CheckStartAnimation( mRenderableActor, scrollOffset.x + mAlignmentOffset, scrollOffset.y - scrollAmount, scrollAmount ); + } + else if ( Equals( scrollAmount, 0.0f, Math::MACHINE_EPSILON_1 )) + { + mRenderableActor.SetPosition( scrollOffset.x + mAlignmentOffset, scrollOffset.y - scrollAmount ); + } + else + { + mTextVerticalScroller = Text::TextVerticalScroller::New(); + if ( !Equals( mScrollAnimationDuration, 0.0f, Math::MACHINE_EPSILON_1 )) + { + mTextVerticalScroller->SetDuration( mScrollAnimationDuration ); + } + mTextVerticalScroller->CheckStartAnimation( mRenderableActor, scrollOffset.x + mAlignmentOffset, scrollOffset.y - scrollAmount, scrollAmount ); + } +} + TextEditor::TextEditor() : Control( ControlBehaviour( CONTROL_BEHAVIOUR_DEFAULT ) ), mIdleCallback( NULL ), mAlignmentOffset( 0.f ), + mScrollAnimationDuration( 0.f ), mRenderingBackend( DEFAULT_RENDERING_BACKEND ), - mHasBeenStaged( false ) + mHasBeenStaged( false ), + mScrollAnimationEnabled( false ) { }