X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Ftext-controls%2Ftext-field-impl.cpp;h=e9d1fe4d1f56a5624f338b6b11e8a23bdf18d1ea;hb=f3ea2bdc5952936d35a00322557e3279c168c857;hp=8099556b1c6c83cd355d9309bf7977fde0797b84;hpb=9495858e5104686a6e09fb29b77355f8a6e8f0c6;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp index 8099556..e9d1fe4 100755 --- a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2019 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,7 +27,6 @@ #include #include #include -#include #include // INTERNAL INCLUDES @@ -38,8 +37,6 @@ #include #include #include -#include -#include #include #include #include @@ -47,6 +44,7 @@ #include #include #include +#include using namespace Dali::Toolkit::Text; @@ -136,6 +134,7 @@ DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextField, "enableShiftSelection", DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextField, "enableGrabHandle", BOOLEAN, ENABLE_GRAB_HANDLE ) DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextField, "matchSystemLanguageDirection", BOOLEAN, MATCH_SYSTEM_LANGUAGE_DIRECTION ) DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextField, "enableGrabHandlePopup", BOOLEAN, ENABLE_GRAB_HANDLE_POPUP ) +DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextField, "textBackground", VECTOR4, BACKGROUND ) DALI_SIGNAL_REGISTRATION( Toolkit, TextField, "textChanged", SIGNAL_TEXT_CHANGED ) DALI_SIGNAL_REGISTRATION( Toolkit, TextField, "maxLengthReached", SIGNAL_MAX_LENGTH_REACHED ) @@ -769,7 +768,7 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr } case Toolkit::DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP: { - if (impl.mController) + if( impl.mController ) { const bool grabHandlePopupEnabled = value.Get(); DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p ENABLE_GRAB_HANDLE_POPUP %d\n", impl.mController.Get(), grabHandlePopupEnabled); @@ -778,6 +777,18 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr break; } } + case Toolkit::DevelTextField::Property::BACKGROUND: + { + if( impl.mController ) + { + const Vector4 backgroundColor = value.Get< Vector4 >(); + DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p BACKGROUND %f,%f,%f,%f\n", impl.mController.Get(), backgroundColor.r, backgroundColor.g, backgroundColor.b, backgroundColor.a ); + + impl.mController->SetBackgroundEnabled( true ); + impl.mController->SetBackgroundColor( backgroundColor ); + } + break; + } } // switch } // textfield } @@ -1187,12 +1198,20 @@ Property::Value TextField::GetProperty( BaseObject* object, Property::Index inde } case Toolkit::DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP: { - if (impl.mController) + if( impl.mController ) { value = impl.mController->IsGrabHandlePopupEnabled(); } break; } + case Toolkit::DevelTextField::Property::BACKGROUND: + { + if( impl.mController ) + { + value = impl.mController->GetBackgroundColor(); + } + break; + } } //switch } @@ -1269,7 +1288,7 @@ void TextField::OnInitialize() mDecorator = Text::Decorator::New( *mController, *mController ); - mInputMethodContext = InputMethodContext::New(); + mInputMethodContext = InputMethodContext::New( self ); mController->GetLayoutEngine().SetLayout( Layout::Engine::SINGLE_LINE_BOX ); @@ -1465,8 +1484,14 @@ void TextField::RenderText( Text::Controller::UpdateTextType updateTextType ) if( renderableActor != mRenderableActor ) { + UnparentAndReset( mBackgroundActor ); UnparentAndReset( mRenderableActor ); mRenderableActor = renderableActor; + + if ( mRenderableActor ) + { + mBackgroundActor = mController->CreateBackgroundActor(); + } } } @@ -1474,9 +1499,12 @@ void TextField::RenderText( Text::Controller::UpdateTextType updateTextType ) { const Vector2& scrollOffset = mController->GetTextModel()->GetScrollPosition(); + float renderableActorPositionX, renderableActorPositionY; + if( mStencil ) { - mRenderableActor.SetPosition( scrollOffset.x + mAlignmentOffset, scrollOffset.y ); + renderableActorPositionX = scrollOffset.x + mAlignmentOffset; + renderableActorPositionY = scrollOffset.y; } else { @@ -1490,13 +1518,17 @@ void TextField::RenderText( Text::Controller::UpdateTextType updateTextType ) std::swap( padding.start, padding.end ); } - mRenderableActor.SetPosition( scrollOffset.x + mAlignmentOffset + padding.start, scrollOffset.y + padding.top ); + renderableActorPositionX = scrollOffset.x + mAlignmentOffset + padding.start; + renderableActorPositionY = scrollOffset.y + padding.top; } + mRenderableActor.SetPosition( renderableActorPositionX, renderableActorPositionY ); // Make sure the actors are parented correctly with/without clipping Actor self = mStencil ? mStencil : Self(); + Actor highlightActor; + for( std::vector::iterator it = mClippingDecorationActors.begin(), endIt = mClippingDecorationActors.end(); it != endIt; @@ -1504,17 +1536,38 @@ void TextField::RenderText( Text::Controller::UpdateTextType updateTextType ) { self.Add( *it ); it->LowerToBottom(); + + if ( it->GetName() == "HighlightActor" ) + { + highlightActor = *it; + } } mClippingDecorationActors.clear(); self.Add( mRenderableActor ); + + if ( mBackgroundActor ) + { + if ( mDecorator && mDecorator->IsHighlightVisible() ) + { + self.Add( mBackgroundActor ); + mBackgroundActor.SetPosition( renderableActorPositionX, renderableActorPositionY); // In text field's coords. + mBackgroundActor.LowerBelow( highlightActor ); + } + else + { + mRenderableActor.Add( mBackgroundActor ); + mBackgroundActor.SetPosition( 0.0f, 0.0f ); // In renderable actor's coords. + mBackgroundActor.LowerToBottom(); + } + } } } void TextField::OnKeyInputFocusGained() { DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnKeyInputFocusGained %p\n", mController.Get() ); - if( mInputMethodContext ) + if ( mInputMethodContext ) { mInputMethodContext.ApplyOptions( mInputMethodOptions ); @@ -1528,30 +1581,13 @@ void TextField::OnKeyInputFocusGained() // When window gain lost focus, the inputMethodContext is deactivated. Thus when window gain focus again, the inputMethodContext must be activated. mInputMethodContext.SetRestoreAfterFocusLost( true ); } - ClipboardEventNotifier notifier( ClipboardEventNotifier::Get() ); - if( notifier ) + + if ( notifier ) { notifier.ContentSelectedSignal().Connect( this, &TextField::OnClipboardTextSelected ); } - Toolkit::Control control = Toolkit::Control::DownCast( Self() ); - Internal::Control& controlImpl = GetImplementation( control ); - Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( controlImpl ); - bool enableAutofill = controlDataImpl.IsAutofillEnabled(); - if( enableAutofill ) - { - Toolkit::AutofillContainer container = controlDataImpl.GetAutofillContainer(); - container.SetFocusedControl( control ); - - Internal::AutofillContainer& containerImpl = GetImpl( container ); - Dali::AutofillGroup containerGroup = containerImpl.GetAutofillGroup(); - if( containerGroup != nullptr ) - { - containerGroup.RequestAuthentication(); - } - - } mController->KeyboardFocusGainEvent(); // Called in the case of no virtual keyboard to trigger this event EmitKeyInputFocusSignal( true ); // Calls back into the Control hence done last.