X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Ftext-controls%2Ftext-editor-impl.cpp;h=1e4d168491f1c7503781d420ea55e8c205957abf;hb=354a975a68a9989a45344f2a3d2827fcc716111f;hp=e1037025e93ba7e0a4c91d1b0c2c5b70cc2f89fe;hpb=52bf7f299f84eb2a64e744f2b9183d560689caf2;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 e103702..1e4d168 100644 --- a/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -138,6 +139,8 @@ DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "pixelSize", DALI_DEVEL_PROPERTY_REGISTRATION_READ_ONLY( Toolkit, TextEditor, "lineCount", INTEGER, LINE_COUNT ) DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "placeholderText", STRING, PLACEHOLDER_TEXT ) DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "placeholderTextColor", VECTOR4, PLACEHOLDER_TEXT_COLOR ) +DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "enableSelection", BOOLEAN, ENABLE_SELECTION ) +DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "placeholder", MAP, PLACEHOLDER ) DALI_SIGNAL_REGISTRATION( Toolkit, TextEditor, "textChanged", SIGNAL_TEXT_CHANGED ) DALI_SIGNAL_REGISTRATION( Toolkit, TextEditor, "inputStyleChanged", SIGNAL_INPUT_STYLE_CHANGED ) @@ -690,6 +693,25 @@ void TextEditor::SetProperty( BaseObject* object, Property::Index index, const P } break; } + case Toolkit::DevelTextEditor::Property::ENABLE_SELECTION: + { + if( impl.mController ) + { + const bool enableSelection = value.Get< bool >(); + DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p ENABLE_SELECTION %d\n", impl.mController.Get(), enableSelection ); + impl.mController->SetSelectionEnabled( enableSelection ); + } + break; + } + case Toolkit::DevelTextEditor::Property::PLACEHOLDER: + { + const Property::Map* map = value.GetMap(); + if( map ) + { + impl.mController->SetPlaceholderProperty( *map ); + } + break; + } } // switch } // texteditor } @@ -1051,6 +1073,21 @@ Property::Value TextEditor::GetProperty( BaseObject* object, Property::Index ind } break; } + case Toolkit::DevelTextEditor::Property::ENABLE_SELECTION: + { + if( impl.mController ) + { + value = impl.mController->IsSelectionEnabled(); + } + break; + } + case Toolkit::DevelTextEditor::Property::PLACEHOLDER: + { + Property::Map map; + impl.mController->GetPlaceholderProperty( map ); + value = map; + break; + } } //switch } @@ -1091,6 +1128,11 @@ Toolkit::TextEditor::InputStyleChangedSignalType& TextEditor::InputStyleChangedS return mInputStyleChangedSignal; } +Toolkit::DevelTextEditor::ScrollStateChangedSignalType& TextEditor::ScrollStateChangedSignal() +{ + return mScrollStateChangedSignal; +} + void TextEditor::OnInitialize() { Actor self = Self(); @@ -1151,8 +1193,8 @@ void TextEditor::OnInitialize() // Creates an extra control to be used as stencil buffer. mStencil = Control::New(); - mStencil.SetAnchorPoint( AnchorPoint::CENTER ); - mStencil.SetParentOrigin( ParentOrigin::CENTER ); + mStencil.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + mStencil.SetParentOrigin( ParentOrigin::TOP_LEFT ); // Creates a background visual. Even if the color is transparent it updates the stencil. mStencil.SetProperty( Toolkit::Control::Property::BACKGROUND, @@ -1206,14 +1248,32 @@ Vector3 TextEditor::GetNaturalSize() float TextEditor::GetHeightForWidth( float width ) { - return mController->GetHeightForWidth( width ); + Padding padding; + Self().GetPadding( padding ); + return mController->GetHeightForWidth( width ) + padding.top + padding.bottom; } void TextEditor::OnRelayout( const Vector2& size, RelayoutContainer& container ) { DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor OnRelayout\n"); - const Text::Controller::UpdateTextType updateTextType = mController->Relayout( size ); + Actor self = Self(); + Padding padding; + + self.GetPadding( padding ); + Vector2 contentSize( size.x - ( padding.left + padding.right ), size.y - ( padding.top + padding.bottom ) ); + + if( mStencil ) + { + mStencil.SetPosition( padding.left , padding.top ); + } + if( mActiveLayer ) + { + mActiveLayer.SetPosition( padding.left , padding.top ); + } + + + const Text::Controller::UpdateTextType updateTextType = mController->Relayout( contentSize ); if( ( Text::Controller::NONE_UPDATED != updateTextType ) || !mRenderer ) @@ -1232,6 +1292,7 @@ void TextEditor::OnRelayout( const Vector2& size, RelayoutContainer& container ) } RenderText( updateTextType ); + } // The text-editor emits signals when the input style changes. These changes of style are @@ -1285,6 +1346,7 @@ void TextEditor::RenderText( Text::Controller::UpdateTextType updateTextType ) ++it ) { self.Add( *it ); + DevelActor::LowerToBottom( *it ); } mClippingDecorationActors.clear(); @@ -1354,7 +1416,9 @@ void TextEditor::OnTap( const TapGesture& gesture ) mImfManager.Activate(); // Deliver the tap before the focus event to controller; this allows us to detect when focus is gained due to tap-gestures - mController->TapEvent( gesture.numberOfTaps, gesture.localPoint.x, gesture.localPoint.y ); + Padding padding; + Self().GetPadding( padding ); + mController->TapEvent( gesture.numberOfTaps, gesture.localPoint.x - padding.left, gesture.localPoint.y - padding.top ); SetKeyInputFocus(); } @@ -1368,7 +1432,9 @@ void TextEditor::OnLongPress( const LongPressGesture& gesture ) { mImfManager.Activate(); - mController->LongPressEvent( gesture.state, gesture.localPoint.x, gesture.localPoint.y ); + Padding padding; + Self().GetPadding( padding ); + mController->LongPressEvent( gesture.state, gesture.localPoint.x - padding.left, gesture.localPoint.y - padding.top ); SetKeyInputFocus(); } @@ -1471,7 +1537,10 @@ void TextEditor::AddDecoration( Actor& actor, bool needsClipping ) } else { + actor.SetParentOrigin( ParentOrigin::TOP_LEFT ); + actor.SetAnchorPoint( AnchorPoint::TOP_LEFT ); Self().Add( actor ); + mActiveLayer = actor; } } } @@ -1516,6 +1585,15 @@ void TextEditor::UpdateScrollBar() mScrollBar.SetScrollPropertySource(self, propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize); + // Set style name of ScrollBar for styling + mScrollBar.SetStyleName("TextEditorScrollBar"); + Toolkit::Control scrollIndicator = Toolkit::Control::DownCast( mScrollBar.GetScrollIndicator() ); + if( scrollIndicator ) + { + // Set style name of ScrollBarIndicator for styling + scrollIndicator.SetStyleName("TextEditorScrollBarIndicator"); + } + self.Add( mScrollBar ); } else @@ -1529,6 +1607,14 @@ void TextEditor::UpdateScrollBar() self.SetProperty( propertyScrollContentSize, layoutSize ); } + // If scrolling is not started, start scrolling and emit ScrollStateChangedSignal + if( !mScrollStarted ) + { + mScrollStarted = true; + Dali::Toolkit::TextEditor handle( GetOwner() ); + mScrollStateChangedSignal.Emit( handle, DevelTextEditor::Scroll::STARTED ); + } + Actor indicator = mScrollBar.GetScrollIndicator(); if( mAnimation ) { @@ -1541,6 +1627,18 @@ void TextEditor::UpdateScrollBar() indicator.SetOpacity(1.0f); mAnimation.AnimateTo( Property( indicator, Actor::Property::COLOR_ALPHA ), 0.0f, AlphaFunction::EASE_IN, mAnimationPeriod ); mAnimation.Play(); + mAnimation.FinishedSignal().Connect( this, &TextEditor::OnScrollIndicatorAnimationFinished ); +} + +void TextEditor::OnScrollIndicatorAnimationFinished( Animation& animation ) +{ + // If animation is successfully ended, then emit ScrollStateChangedSignal + if( animation.GetCurrentProgress() == 0.0f ) + { + mScrollStarted = false; + Dali::Toolkit::TextEditor handle( GetOwner() ); + mScrollStateChangedSignal.Emit( handle, DevelTextEditor::Scroll::FINISHED ); + } } void TextEditor::OnStageConnect( Dali::Actor actor ) @@ -1658,7 +1756,8 @@ TextEditor::TextEditor() mRenderingBackend( DEFAULT_RENDERING_BACKEND ), mHasBeenStaged( false ), mScrollAnimationEnabled( false ), - mScrollBarEnabled( false ) + mScrollBarEnabled( false ), + mScrollStarted( false ) { }