X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Ftext-controls%2Ftext-editor-impl.cpp;h=8f7916c1e77399c4e720ef5ea406d3261d5a2e77;hb=d00a250741411c386d988e7ac34525cf94a1918e;hp=a029c833fa9fa26ada4ec105b91f151c278b2729;hpb=07f42751dbdbf750111752a824ec989fc25f64fe;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 a029c83..8f7916c 100644 --- a/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp @@ -25,13 +25,14 @@ #include #include #include -#include +#include #include // INTERNAL INCLUDES #include #include #include +#include #include #include #include @@ -51,10 +52,11 @@ namespace // unnamed namespace { #if defined(DEBUG_ENABLED) - Debug::Filter* gLogFilter = Debug::Filter::New(Debug::Concise, true, "LOG_TEXT_CONTROLS"); +Debug::Filter* gLogFilter = Debug::Filter::New(Debug::Concise, true, "LOG_TEXT_CONTROLS"); #endif - const unsigned int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND; +const unsigned int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND; +const float DEFAULT_SCROLL_SPEED = 1200.f; ///< The default scroll speed for the text editor in pixels/second. } // unnamed namespace namespace @@ -107,6 +109,16 @@ DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "inputColor", DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "inputFontFamily", STRING, INPUT_FONT_FAMILY ) DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "inputFontStyle", STRING, INPUT_FONT_STYLE ) DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "inputPointSize", FLOAT, INPUT_POINT_SIZE ) +DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "lineSpacing", FLOAT, LINE_SPACING ) +DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "inputLineSpacing", FLOAT, INPUT_LINE_SPACING ) +DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "underline", STRING, UNDERLINE ) +DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "inputUnderline", STRING, INPUT_UNDERLINE ) +DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "shadow", STRING, SHADOW ) +DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "inputShadow", STRING, INPUT_SHADOW ) +DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "emboss", STRING, EMBOSS ) +DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "inputEmboss", STRING, INPUT_EMBOSS ) +DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "outline", STRING, OUTLINE ) +DALI_PROPERTY_REGISTRATION( Toolkit, TextEditor, "inputOutline", STRING, INPUT_OUTLINE ) DALI_SIGNAL_REGISTRATION( Toolkit, TextEditor, "textChanged", SIGNAL_TEXT_CHANGED ) @@ -482,6 +494,98 @@ void TextEditor::SetProperty( BaseObject* object, Property::Index index, const P } break; } + case Toolkit::TextEditor::Property::LINE_SPACING: + { + if( impl.mController ) + { + const float lineSpacing = value.Get(); + impl.mController->SetDefaultLineSpacing( lineSpacing ); + impl.mRenderer.Reset(); + } + break; + } + case Toolkit::TextEditor::Property::INPUT_LINE_SPACING: + { + if( impl.mController ) + { + const float lineSpacing = value.Get(); + impl.mController->SetInputLineSpacing( lineSpacing ); + impl.mRenderer.Reset(); + } + break; + } + case Toolkit::TextEditor::Property::UNDERLINE: + { + const bool update = SetUnderlineProperties( impl.mController, value, Text::EffectStyle::DEFAULT ); + if( update ) + { + impl.mRenderer.Reset(); + } + break; + } + case Toolkit::TextEditor::Property::INPUT_UNDERLINE: + { + const bool update = SetUnderlineProperties( impl.mController, value, Text::EffectStyle::INPUT ); + if( update ) + { + impl.mRenderer.Reset(); + } + break; + } + case Toolkit::TextEditor::Property::SHADOW: + { + const bool update = SetShadowProperties( impl.mController, value, Text::EffectStyle::DEFAULT ); + if( update ) + { + impl.mRenderer.Reset(); + } + break; + } + case Toolkit::TextEditor::Property::INPUT_SHADOW: + { + const bool update = SetShadowProperties( impl.mController, value, Text::EffectStyle::INPUT ); + if( update ) + { + impl.mRenderer.Reset(); + } + break; + } + case Toolkit::TextEditor::Property::EMBOSS: + { + const bool update = SetEmbossProperties( impl.mController, value, Text::EffectStyle::DEFAULT ); + if( update ) + { + impl.mRenderer.Reset(); + } + break; + } + case Toolkit::TextEditor::Property::INPUT_EMBOSS: + { + const bool update = SetEmbossProperties( impl.mController, value, Text::EffectStyle::INPUT ); + if( update ) + { + impl.mRenderer.Reset(); + } + break; + } + case Toolkit::TextEditor::Property::OUTLINE: + { + const bool update = SetOutlineProperties( impl.mController, value, Text::EffectStyle::DEFAULT ); + if( update ) + { + impl.mRenderer.Reset(); + } + break; + } + case Toolkit::TextEditor::Property::INPUT_OUTLINE: + { + const bool update = SetOutlineProperties( impl.mController, value, Text::EffectStyle::INPUT ); + if( update ) + { + impl.mRenderer.Reset(); + } + break; + } } // switch } // texteditor } @@ -727,6 +831,62 @@ Property::Value TextEditor::GetProperty( BaseObject* object, Property::Index ind } break; } + case Toolkit::TextEditor::Property::LINE_SPACING: + { + if( impl.mController ) + { + value = impl.mController->GetDefaultLineSpacing(); + } + break; + } + case Toolkit::TextEditor::Property::INPUT_LINE_SPACING: + { + if( impl.mController ) + { + value = impl.mController->GetInputLineSpacing(); + } + break; + } + case Toolkit::TextEditor::Property::UNDERLINE: + { + GetUnderlineProperties( impl.mController, value, Text::EffectStyle::DEFAULT ); + break; + } + case Toolkit::TextEditor::Property::INPUT_UNDERLINE: + { + GetUnderlineProperties( impl.mController, value, Text::EffectStyle::INPUT ); + break; + } + case Toolkit::TextEditor::Property::SHADOW: + { + GetShadowProperties( impl.mController, value, Text::EffectStyle::DEFAULT ); + break; + } + case Toolkit::TextEditor::Property::INPUT_SHADOW: + { + GetShadowProperties( impl.mController, value, Text::EffectStyle::INPUT ); + break; + } + case Toolkit::TextEditor::Property::EMBOSS: + { + GetEmbossProperties( impl.mController, value, Text::EffectStyle::DEFAULT ); + break; + } + case Toolkit::TextEditor::Property::INPUT_EMBOSS: + { + GetEmbossProperties( impl.mController, value, Text::EffectStyle::INPUT ); + break; + } + case Toolkit::TextEditor::Property::OUTLINE: + { + GetOutlineProperties( impl.mController, value, Text::EffectStyle::DEFAULT ); + break; + } + case Toolkit::TextEditor::Property::INPUT_OUTLINE: + { + GetOutlineProperties( impl.mController, value, Text::EffectStyle::INPUT ); + break; + } } //switch } @@ -769,15 +929,25 @@ void TextEditor::OnInitialize() mController->GetLayoutEngine().SetLayout( LayoutEngine::MULTI_LINE_BOX ); + // Enables the text input. mController->EnableTextInput( mDecorator ); + // Enables the vertical scrolling after the text input has been enabled. + mController->SetVerticalScrollEnabled( true ); + + // Disables the horizontal scrolling. + mController->SetHorizontalScrollEnabled( false ); + mController->SetMaximumNumberOfCharacters( std::numeric_limits::max() ); + // Enable the smooth handle panning. + mController->SetSmoothHandlePanEnabled( true ); + // Forward input events to controller EnableGestureDetection( static_cast( Gesture::Tap | Gesture::Pan | Gesture::LongPress ) ); GetTapGestureDetector().SetMaximumTapsRequired( 2 ); - self.TouchedSignal().Connect( this, &TextEditor::OnTouched ); + self.TouchSignal().Connect( this, &TextEditor::OnTouched ); // Set BoundingBox to stage size if not already set. Rect boundingBox; @@ -789,8 +959,11 @@ void TextEditor::OnInitialize() mDecorator->SetBoundingBox( Rect( 0.0f, 0.0f, stageSize.width, stageSize.height ) ); } - // Flip vertically the 'left' selection handle - mDecorator->FlipHandleVertically( LEFT_SELECTION_HANDLE, true ); + // Whether to flip the selection handles as soon as they cross. + mDecorator->FlipSelectionHandlesOnCrossEnabled( true ); + + // Set the default scroll speed. + mDecorator->SetScrollSpeed( DEFAULT_SCROLL_SPEED ); // Fill-parent area by default self.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); @@ -802,34 +975,34 @@ void TextEditor::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange: { DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor::OnStyleChange\n"); - switch ( change ) - { - case StyleChange::DEFAULT_FONT_CHANGE: - { - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor::OnStyleChange DEFAULT_FONT_CHANGE\n"); - std::string newFont = styleManager.GetDefaultFontFamily(); - // Property system did not set the font so should update it. - mController->UpdateAfterFontChange( newFont ); - break; - } - - case StyleChange::DEFAULT_FONT_SIZE_CHANGE: - { - DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor::OnStyleChange StyleChange::DEFAULT_FONT_SIZE_CHANGE (%f)\n", mController->GetDefaultPointSize() ); - - if ( (mController->GetDefaultPointSize() <= 0.0f) ) // If DefaultPointSize not set by Property system it will be 0.0f - { - // Property system did not set the PointSize so should update it. - // todo instruct text-controller to update model - } - break; - } - case StyleChange::THEME_CHANGE: - { - GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) ); - break; - } - } + switch ( change ) + { + case StyleChange::DEFAULT_FONT_CHANGE: + { + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor::OnStyleChange DEFAULT_FONT_CHANGE\n"); + const std::string& newFont = GetImpl( styleManager ).GetDefaultFontFamily(); + // Property system did not set the font so should update it. + mController->UpdateAfterFontChange( newFont ); + break; + } + + case StyleChange::DEFAULT_FONT_SIZE_CHANGE: + { + DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor::OnStyleChange StyleChange::DEFAULT_FONT_SIZE_CHANGE (%f)\n", mController->GetDefaultPointSize() ); + + if ( (mController->GetDefaultPointSize() <= 0.0f) ) // If DefaultPointSize not set by Property system it will be 0.0f + { + // Property system did not set the PointSize so should update it. + // todo instruct text-controller to update model + } + break; + } + case StyleChange::THEME_CHANGE: + { + GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) ); + break; + } + } } Vector3 TextEditor::GetNaturalSize() @@ -846,12 +1019,15 @@ void TextEditor::OnRelayout( const Vector2& size, RelayoutContainer& container ) { DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor OnRelayout\n"); - if( mController->Relayout( size ) || + const Text::Controller::UpdateTextType updateTextType = mController->Relayout( size ); + + if( ( Text::Controller::NONE_UPDATED != updateTextType ) || !mRenderer ) { DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor::OnRelayout %p Displaying new contents\n", mController.Get() ); - if( mDecorator ) + if( mDecorator && + ( Text::Controller::NONE_UPDATED != ( Text::Controller::DECORATOR_UPDATED & updateTextType ) ) ) { mDecorator->Relayout( size ); } @@ -862,30 +1038,34 @@ void TextEditor::OnRelayout( const Vector2& size, RelayoutContainer& container ) } EnableClipping( true, size ); - RenderText(); + RenderText( updateTextType ); } } -void TextEditor::RenderText() +void TextEditor::RenderText( Text::Controller::UpdateTextType updateTextType ) { Actor self = Self(); Actor renderableActor; - if( mRenderer ) - { - renderableActor = mRenderer->Render( mController->GetView(), DepthIndex::TEXT ); - } - if( renderableActor != mRenderableActor ) + if( Text::Controller::NONE_UPDATED != ( Text::Controller::MODEL_UPDATED & updateTextType ) ) { - UnparentAndReset( mRenderableActor ); - mRenderableActor = renderableActor; + if( mRenderer ) + { + renderableActor = mRenderer->Render( mController->GetView(), DepthIndex::TEXT ); + } + + if( renderableActor != mRenderableActor ) + { + UnparentAndReset( mRenderableActor ); + mRenderableActor = renderableActor; + } } if( mRenderableActor ) { - const Vector2 offset = mController->GetScrollPosition() + mController->GetAlignmentOffset(); + const Vector2& scrollOffset = mController->GetScrollPosition(); - mRenderableActor.SetPosition( offset.x, offset.y ); + mRenderableActor.SetPosition( scrollOffset.x, scrollOffset.y ); Actor clipRootActor; if( mClipper ) @@ -1066,7 +1246,7 @@ void TextEditor::OnStageConnect( Dali::Actor actor ) { if ( mHasBeenStaged ) { - RenderText(); + RenderText( static_cast( Text::Controller::MODEL_UPDATED | Text::Controller::DECORATOR_UPDATED ) ); } else { @@ -1108,7 +1288,7 @@ void TextEditor::EnableClipping( bool clipping, const Vector2& size ) mClipper = Clipper::New( size ); self.Add( mClipper->GetRootActor() ); - self.Add( mClipper->GetImageActor() ); + self.Add( mClipper->GetImageView() ); } else if ( mClipper ) { @@ -1118,7 +1298,7 @@ void TextEditor::EnableClipping( bool clipping, const Vector2& size ) } else { - // Note - this will automatically remove the root & image actors + // Note - this will automatically remove the root actor & the image view mClipper.Reset(); } } @@ -1154,7 +1334,7 @@ void TextEditor::OnStageConnection( int depth ) // The depth of the text renderer is set in the RenderText() called from OnRelayout(). } -bool TextEditor::OnTouched( Actor actor, const TouchEvent& event ) +bool TextEditor::OnTouched( Actor actor, const TouchData& touch ) { return true; }